/// <summary> /// Initializes a new instance. /// </summary> /// <param name="primary"></param> public DynamicServiceRouteServiceHostFactory(ServiceHostFactoryBase primary) : base() { if (primary == null) { throw new ArgumentNullException(nameof(primary)); } this.primary = primary; }
/// <summary> /// Routes the given URL pattern to the specified WCF service. /// </summary> /// <param name="self"></param> /// <param name="url"></param> /// <param name="serviceHostFactory"></param> /// <param name="serviceType"></param> /// <param name="defaults"></param> /// <param name="requestHandlerFunc"></param> public static void AddDynamicServiceRoute( this RouteCollection self, string url, ServiceHostFactoryBase serviceHostFactory, Type serviceType, object defaults = null, Func <RequestContext, IHttpHandler> requestHandlerFunc = null) { if (self == null) { throw new ArgumentNullException(nameof(self)); } self.Add(new DynamicServiceRoute(url, defaults, serviceHostFactory, serviceType)); }
public DynamicServiceRoute(string pathPrefix, object defaults, ServiceHostFactoryBase serviceHostFactory, Type serviceType) { if (pathPrefix.IndexOf("{*") >= 0) { throw new ArgumentException("Path prefix can not include catch-all route parameters.", "pathPrefix"); } if (!pathPrefix.EndsWith("/")) { pathPrefix += "/"; } pathPrefix += "{*servicePath}"; virtualPath = serviceType.FullName + "-" + Guid.NewGuid().ToString() + "/"; innerServiceRoute = new ServiceRoute(virtualPath, serviceHostFactory, serviceType); innerRoute = new Route(pathPrefix, new RouteValueDictionary(defaults), this); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="url"></param> /// <param name="defaults"></param> /// <param name="serviceHostFactory"></param> /// <param name="serviceType"></param> /// <param name="requestHandlerFunc"></param> public DynamicServiceRoute(string url, object defaults, ServiceHostFactoryBase serviceHostFactory, Type serviceType, Func <RequestContext, IHttpHandler> requestHandlerFunc = null) { if (url == null) { throw new ArgumentNullException(nameof(url)); } if (string.IsNullOrWhiteSpace(url)) { throw new ArgumentOutOfRangeException(nameof(url)); } if (url.IndexOf("{*") >= 0) { throw new ArgumentException("Url cannot include catch-all route parameters.", nameof(url)); } if (serviceHostFactory == null) { throw new ArgumentNullException(nameof(serviceHostFactory)); } if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } // append separator if (url.EndsWith("/") == false) { url += "/"; } // append service path specification url += "{*servicePath}"; this.url = url; this.requestHandlerFunc = requestHandlerFunc ?? (_ => null); this.serviceHostFactory = serviceHostFactory; this.serviceType = serviceType; this.innerRoute = new Route(url, new RouteValueDictionary(defaults), this); }
/// <summary> /// Gets or adds the service route for the given URL path. /// </summary> /// <param name="url"></param> /// <returns></returns> static ServiceRoute GetServiceRoute(string url, ServiceHostFactoryBase serviceHostFactory, Type serviceType) { return(routes.GetOrAdd(url, _ => new ServiceRoute(_, new DynamicServiceRouteServiceHostFactory(serviceHostFactory), serviceType))); }
public DynamicServiceRoute(string pathPrefix, object defaults, string[] namespaces, ServiceHostFactoryBase serviceHostFactory, Type serviceType) { if (pathPrefix.IndexOf("{*", StringComparison.Ordinal) >= 0) { throw new ArgumentException("Path prefix can not include catch-all route parameters.", "pathPrefix"); } if (!pathPrefix.EndsWith("/")) { pathPrefix += "/"; } pathPrefix += "{*servicePath}"; virtualPath = serviceType.FullName + "-" + Guid.NewGuid().ToString() + "/"; innerServiceRoute = new ServiceRoute(virtualPath, serviceHostFactory, serviceType); innerRoute = new Route(pathPrefix, new RouteValueDictionary(defaults), this) { DataTokens = new RouteValueDictionary() }; if ((namespaces != null) && (namespaces.Length > 0)) { innerRoute.DataTokens["Namespaces"] = namespaces; } }
public AppServiceRoute(string routePrefix, ServiceHostFactoryBase serviceHostFactory, Type serviceType) : base(routePrefix, serviceHostFactory, serviceType) { }