diff --git a/samples/DispatcherSample/DispatcherEndpoint.cs b/samples/DispatcherSample/DispatcherEndpoint.cs
deleted file mode 100644
index b58156eae7..0000000000
--- a/samples/DispatcherSample/DispatcherEndpoint.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using Microsoft.AspNetCore.Dispatcher;
-
-namespace DispatcherSample
-{
- public class DispatcherEndpoint : Endpoint
- {
- public DispatcherEndpoint(string displayName)
- {
- DisplayName = displayName;
- }
-
- public override string DisplayName { get; }
- }
-}
diff --git a/samples/DispatcherSample/DispatcherSample.csproj b/samples/DispatcherSample/DispatcherSample.csproj
index 7151f7ad15..29bcf6c954 100644
--- a/samples/DispatcherSample/DispatcherSample.csproj
+++ b/samples/DispatcherSample/DispatcherSample.csproj
@@ -6,9 +6,6 @@
-
-
-
diff --git a/samples/DispatcherSample/Startup.cs b/samples/DispatcherSample/Startup.cs
index bd1cba2d01..a07f62da66 100644
--- a/samples/DispatcherSample/Startup.cs
+++ b/samples/DispatcherSample/Startup.cs
@@ -1,73 +1,70 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System.Collections.Generic;
+using System;
+using System.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Dispatcher;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-using Microsoft.AspNetCore.Routing.Template;
+using Microsoft.AspNetCore.Routing.Dispatcher;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
namespace DispatcherSample
{
public class Startup
{
+ private readonly static IInlineConstraintResolver ConstraintResolver = new DefaultInlineConstraintResolver(
+ new OptionsManager(
+ new OptionsFactory(
+ Enumerable.Empty>(),
+ Enumerable.Empty>())));
+
public void ConfigureServices(IServiceCollection services)
{
services.Configure(options =>
{
- options.DispatcherEntryList = new List()
- {
- new DispatcherEntry
- {
- RouteTemplate = TemplateParser.Parse("{Endpoint=example}"),
- Endpoints = new []
+ options.Dispatchers.Add(CreateDispatcher(
+ "{Endpoint=example}",
+ new RouteValuesEndpoint(
+ new RouteValueDictionary(new { Endpoint = "First" }),
+ async (context) =>
{
- new RouteValuesEndpoint("example")
- {
- RequiredValues = new RouteValueDictionary(new { Endpoint = "First" }),
- RequestDelegate = async (context) =>
- {
- await context.Response.WriteAsync("Hello from the example!");
- }
- },
- new RouteValuesEndpoint("example2")
- {
- RequiredValues = new RouteValueDictionary(new { Endpoint = "Second" }),
- RequestDelegate = async (context) =>
- {
- await context.Response.WriteAsync("Hello from the second example!");
- }
- },
- }
- },
+ await context.Response.WriteAsync("Hello from the example!");
+ },
+ Array.Empty