当前位置: 首页>>代码示例>>C#>>正文


C# IRouter类代码示例

本文整理汇总了C#中IRouter的典型用法代码示例。如果您正苦于以下问题:C# IRouter类的具体用法?C# IRouter怎么用?C# IRouter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IRouter类属于命名空间,在下文中一共展示了IRouter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EdgeApplication

        // Consumers should use IoC or the Default UseEdge extension method to initialize this.
        public EdgeApplication(
            IFileSystem fileSystem,
            string virtualRoot,
            IRouter router,
            ICompilationManager compiler,
            IPageActivator activator,
            IPageExecutor executor,
            ITraceFactory tracer)
            : this()
        {
            Requires.NotNull(fileSystem, "fileSystem");
            Requires.NotNullOrEmpty(virtualRoot, "virtualRoot");
            Requires.NotNull(router, "router");
            Requires.NotNull(compiler, "compiler");
            Requires.NotNull(activator, "activator");
            Requires.NotNull(executor, "executor");
            Requires.NotNull(tracer, "tracer");

            FileSystem = fileSystem;
            VirtualRoot = virtualRoot;
            Router = router;
            CompilationManager = compiler;
            Executor = executor;
            Activator = activator;
            Tracer = tracer;
        }
开发者ID:anurse,项目名称:Edge,代码行数:27,代码来源:EdgeApplication.cs

示例2: Add

		/// <summary>
		/// Add a new router.
		/// </summary>
		/// <param name="router">Router to add</param>
		/// <exception cref="InvalidOperationException">Server have been started.</exception>
		public void Add(IRouter router)
		{
			if (_isStarted)
				throw new InvalidOperationException("Server have been started.");

			_routers.Add(router);
		}
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:12,代码来源:Server.cs

示例3: Match

        //private string requiredSiteFolder;

        //public SiteFolderRouteConstraint(string folderParam)
        //{
        //    requiredSiteFolder = folderParam;
        //}

        public bool Match(
            HttpContext httpContext,
            IRouter route,
            string parameterName,
            IDictionary<string,object> values,
            RouteDirection routeDirection)
        {
            string requestFolder = RequestSiteResolver.GetFirstFolderSegment(httpContext.Request.Path);
            //return string.Equals(requiredSiteFolder, requestFolder, StringComparison.CurrentCultureIgnoreCase);
            ISiteResolver siteResolver = httpContext.ApplicationServices.GetService<ISiteResolver>();
            if(siteResolver != null)
            {
                try
                {
                    // exceptions expected here until db install scripts have run or if db connection error
                    ISiteSettings site = siteResolver.Resolve();
                    if ((site != null) && (site.SiteFolderName == requestFolder)) { return true; }
                }
                catch
                {
                    // do we need to log this?
                }

            }

            return false;
        }
开发者ID:ludev,项目名称:cloudscribe,代码行数:34,代码来源:SiteFolderRouteConstraint.cs

示例4: NancyRouterModule

 public NancyRouterModule(IRouter router)
 {
     foreach (var route in router.Routes)
     {
         switch (route.Key.Method)
         {
             case Route.RouteMethod.Get:
                 Get[route.Key.Path] = x => (route.Value(CreateOwinContext()));
                 break;
             case Route.RouteMethod.Delete:
                 Delete[route.Key.Path] = x => (route.Value(CreateOwinContext()));
                 break;
             case Route.RouteMethod.Patch:
                 Patch[route.Key.Path] = x => (route.Value(CreateOwinContext()));
                 break;
             case Route.RouteMethod.Post:
                 Post[route.Key.Path] = x => (route.Value(CreateOwinContext()));
                 break;
             case Route.RouteMethod.Put:
                 Put[route.Key.Path] = x => (route.Value(CreateOwinContext()));
                 break;
             default:
                 throw new ArgumentOutOfRangeException();
         }
     }
 }
开发者ID:dcr25568,项目名称:mmbot,代码行数:26,代码来源:NancyRouterModule.cs

示例5: TemplateRoute

        public TemplateRoute(
            IRouter target,
            string routeName,
            string routeTemplate,
            IDictionary<string, object> defaults,
            IDictionary<string, object> constraints,
            IDictionary<string, object> dataTokens,
            IInlineConstraintResolver inlineConstraintResolver)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            _target = target;
            _routeTemplate = routeTemplate ?? string.Empty;
            Name = routeName;

            _dataTokens = dataTokens == null ? RouteValueDictionary.Empty : new RouteValueDictionary(dataTokens);

            // Data we parse from the template will be used to fill in the rest of the constraints or
            // defaults. The parser will throw for invalid routes.
            _parsedTemplate = TemplateParser.Parse(RouteTemplate);

            _constraints = GetConstraints(inlineConstraintResolver, RouteTemplate, _parsedTemplate, constraints);
            _defaults = GetDefaults(_parsedTemplate, defaults);

            _matcher = new TemplateMatcher(_parsedTemplate, Defaults);
            _binder = new TemplateBinder(_parsedTemplate, Defaults);
        }
开发者ID:TerabyteX,项目名称:Routing,代码行数:30,代码来源:TemplateRoute.cs

示例6: TenantRoute

 public TenantRoute(IRouter target, 
     string urlHost, 
     RequestDelegate pipeline) {
     _target = target;
     _urlHost = urlHost;
     _pipeline = pipeline;
 }
开发者ID:Giahim,项目名称:Brochard,代码行数:7,代码来源:TenantRoute.cs

示例7: AttributeRoute

        public AttributeRoute(
            IRouter target,
            IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
            IInlineConstraintResolver constraintResolver,
            ILoggerFactory loggerFactory)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (actionDescriptorsCollectionProvider == null)
            {
                throw new ArgumentNullException(nameof(actionDescriptorsCollectionProvider));
            }

            if (constraintResolver == null)
            {
                throw new ArgumentNullException(nameof(constraintResolver));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _target = target;
            _actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
            _constraintResolver = constraintResolver;

            _routeLogger = loggerFactory.CreateLogger<InnerAttributeRoute>();
            _constraintLogger = loggerFactory.CreateLogger(typeof(RouteConstraintMatcher).FullName);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:33,代码来源:AttributeRoute.cs

示例8: GuidedVNS

        /// <summary>
        /// Creates a new Guided Variable Neighbourhood Search solver.
        /// </summary>
        /// <param name="router"></param>
        /// <param name="max"></param>
        /// <param name="delivery_time"></param>
        /// <param name="threshold_precentage"></param>
        /// <param name="lambda"></param>
        /// <param name="sigma"></param>
        public GuidedVNS(IRouter<RouterPoint> router, Second max, Second delivery_time, 
            float threshold_precentage, float lambda, float sigma)
            : base(max, delivery_time)
        {
            _threshold_percentage = threshold_precentage;
            _lambda = lambda;
            _sigma = sigma;

            _intra_improvements = new List<IImprovement>();
            //_intra_improvements.Add(
            //    new ArbitraryInsertionSolver());
            _intra_improvements.Add(
                new HillClimbing3OptSolver(true, true));

            _inter_improvements = new List<IInterImprovement>();
            _inter_improvements.Add(
                new RelocateImprovement());
            _inter_improvements.Add(
                new ExchangeInterImprovement());
            //_inter_improvements.Add(
            //    new TwoOptInterImprovement());
            _inter_improvements.Add(
                new RelocateExchangeInterImprovement());
            _inter_improvements.Add(
                new CrossExchangeInterImprovement());
        }
开发者ID:jorik041,项目名称:osmsharp,代码行数:35,代码来源:GuidedVNS.cs

示例9: Match

        public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection)
        {
            var context = httpContext.ApplicationServices.GetService<IPantherContext>();
            var url = "/";


            if (context == null)
                return false;

            //if (values.ContainsKey("culture") && !CheckCulture(values["culture"].ToString()))
            //    return false;
           if(values.ContainsKey("url") && values["url"] != null)
                url = values["url"].ToString();

            var canHandle = context.CanHandleUrl(context.Path);

            if (!canHandle)
                return false;

            if (!string.IsNullOrEmpty(context.Current.Controller))
                values["controller"] = context.Current.Controller;

            if (!string.IsNullOrEmpty(context.Current.Action))
                values["action"] = context.Current.Action;

            if (!string.IsNullOrEmpty(context.Current.Route))
                context.Router.AddVirtualRouteValues(context.Current.Route, context.VirtualPath, values);

            values["context"] = context;

            return context.Current != null;
        }
开发者ID:freemsly,项目名称:CMS,代码行数:32,代码来源:HostConstraint.cs

示例10: DefaultRouter

        public DefaultRouter(IRouter defaultHandler, IRouteResolver routeResolver, IVirtualPathResolver virtualPathResolver, RequestCulture defaultRequestCulture)
        {
            if (defaultHandler == null)
            {
                throw new ArgumentNullException(nameof(defaultHandler));
            }

            if (routeResolver == null)
            {
                throw new ArgumentNullException(nameof(routeResolver));
            }

            if (virtualPathResolver == null)
            {
                throw new ArgumentNullException(nameof(virtualPathResolver));
            }

            if (defaultRequestCulture == null)
            {
                throw new ArgumentNullException(nameof(defaultRequestCulture));
            }

            _defaultHandler = defaultHandler;
            _routeResolver = routeResolver;
            _virtualPathResolver = virtualPathResolver;
            _defaultRequestCulture = defaultRequestCulture;
        }
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:27,代码来源:DefaultRouter.cs

示例11: CreateAttributeMegaRoute

        /// <summary>
        /// Creates an attribute route using the provided services and provided target router.
        /// </summary>
        /// <param name="target">The router to invoke when a route entry matches.</param>
        /// <param name="services">The application services.</param>
        /// <returns>An attribute route.</returns>
        public static IRouter CreateAttributeMegaRoute(IRouter target, IServiceProvider services)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorCollectionProvider>();
            var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
            var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
            var urlEncoder = services.GetRequiredService<UrlEncoder>();
            var loggerFactory = services.GetRequiredService<ILoggerFactory>();

            return new AttributeRoute(
                target,
                actionDescriptorProvider,
                inlineConstraintResolver,
                pool,
                urlEncoder,
                loggerFactory);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:32,代码来源:AttributeRouting.cs

示例12: VirtualPathData

 /// <summary>
 ///  Initializes a new instance of the <see cref="VirtualPathData"/> class.
 /// </summary>
 /// <param name="router">The object that is used to generate the URL.</param>
 /// <param name="virtualPath">The generated URL.</param>
 /// <param name="dataTokens">The collection of custom values.</param>
 public VirtualPathData(
     IRouter router,
     string virtualPath,
     IDictionary<string, object> dataTokens)
     : this(router, CreatePathString(virtualPath), dataTokens)
 {
 }
开发者ID:TerabyteX,项目名称:Routing,代码行数:13,代码来源:VirtualPathData.cs

示例13: AddPrefixRoute

 public static IRouteBuilder AddPrefixRoute(this IRouteBuilder routeBuilder,
                                            string prefix,
                                            IRouter handler)
 {
     routeBuilder.Routes.Add(new PrefixRoute(handler, prefix));
     return routeBuilder;
 }
开发者ID:TerabyteX,项目名称:Routing,代码行数:7,代码来源:RouteBuilderExtensions.cs

示例14: RazorApplication

        // Consumers should use IoC or the Default UseRazor extension method to initialize this.
        public RazorApplication(
            AppFunc nextApp,
            IFileSystem fileSystem,
            string virtualRoot,
            IRouter router,
            ICompilationManager compiler,
            IPageActivator activator,
            IPageExecutor executor,
            ITraceFactory tracer)
            : this(nextApp)
        {
            Requires.NotNull(fileSystem, "fileSystem");
            Requires.NotNullOrEmpty(virtualRoot, "virtualRoot");
            Requires.NotNull(router, "router");
            Requires.NotNull(compiler, "compiler");
            Requires.NotNull(activator, "activator");
            Requires.NotNull(executor, "executor");
            Requires.NotNull(tracer, "tracer");

            FileSystem = fileSystem;
            VirtualRoot = virtualRoot;
            Router = router;
            CompilationManager = compiler;
            Executor = executor;
            Activator = activator;
            Tracer = tracer;

            ITrace global = Tracer.ForApplication();
            global.WriteLine("Started at '{0}'", VirtualRoot);
        }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:31,代码来源:RazorApplication.cs

示例15: AddTenantRoute

 public static IRouteBuilder AddTenantRoute(this IRouteBuilder routeBuilder,
                                            string urlHost,
                                            IRouter handler,
                                            RequestDelegate pipeline) {
     routeBuilder.Routes.Add(new TenantRoute(handler, urlHost, pipeline));
     return routeBuilder;
 }
开发者ID:jefth,项目名称:OrchardNoCMS,代码行数:7,代码来源:RouteBuilderExtensions.cs


注:本文中的IRouter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。