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


C# IAppHost.RegisterService方法代码示例

本文整理汇总了C#中IAppHost.RegisterService方法的典型用法代码示例。如果您正苦于以下问题:C# IAppHost.RegisterService方法的具体用法?C# IAppHost.RegisterService怎么用?C# IAppHost.RegisterService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppHost的用法示例。


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

示例1: Register

 public void Register(IAppHost appHost)
 {
     if (ResourceFilterPattern != null)
         SwaggerResourcesService.resourceFilterRegex = new Regex(ResourceFilterPattern, RegexOptions.Compiled);
     appHost.RegisterService(typeof (SwaggerResourcesService), new string[] {"/resources"});
     appHost.RegisterService(typeof(SwaggerApiService), new string[] { "/resource/{Name*}" });
 }
开发者ID:keith512,项目名称:ServiceStack,代码行数:7,代码来源:SwaggerFeature.cs

示例2: Register

        public void Register(IAppHost appHost)
        {
            if (ResourceFilterPattern != null)
                SwaggerResourcesService.resourceFilterRegex = new Regex(ResourceFilterPattern, RegexOptions.Compiled);

            SwaggerApiService.UseCamelCaseModelPropertyNames = UseCamelCaseModelPropertyNames;
            SwaggerApiService.UseLowercaseUnderscoreModelPropertyNames = UseLowercaseUnderscoreModelPropertyNames;
            SwaggerApiService.DisableAutoDtoInBodyParam = DisableAutoDtoInBodyParam;
            SwaggerApiService.ModelFilter = ModelFilter;
            SwaggerApiService.ModelPropertyFilter = ModelPropertyFilter;

            appHost.RegisterService(typeof(SwaggerResourcesService), new[] { "/resources" });
            appHost.RegisterService(typeof(SwaggerApiService), new[] { SwaggerResourcesService.RESOURCE_PATH + "/{Name*}" });

            var swaggerUrl = UseBootstrapTheme
                ? "swagger-ui-bootstrap/"
                : "swagger-ui/";

            appHost.GetPlugin<MetadataFeature>()
                .AddPluginLink(swaggerUrl, "Swagger UI");

            appHost.CatchAllHandlers.Add((httpMethod, pathInfo, filePath) =>
            {
                IVirtualFile indexFile;
                switch (pathInfo)
                {
                    case "/swagger-ui":
                    case "/swagger-ui/":
                    case "/swagger-ui/default.html":
                        indexFile = appHost.VirtualPathProvider.GetFile("/swagger-ui/index.html");
                        break;
                    case "/swagger-ui-bootstrap":
                    case "/swagger-ui-bootstrap/":
                    case "/swagger-ui-bootstrap/index.html":
                        indexFile = appHost.VirtualPathProvider.GetFile("/swagger-ui-bootstrap/index.html");
                        break;
                    default:
                        indexFile = null;
                        break;
                }
                if (indexFile != null)
                {
                    var html = indexFile.ReadAllText();

                    return new CustomResponseHandler((req, res) =>
                    {
                        res.ContentType = MimeTypes.Html;
                        var resourcesUrl = req.ResolveAbsoluteUrl("~/resources");
                        html = html.Replace("http://petstore.swagger.wordnik.com/api/api-docs", resourcesUrl)
                            .Replace("ApiDocs", HostContext.ServiceName)
                            .Replace("{LogoUrl}", LogoUrl);
                        return html;
                    });
                }
                return pathInfo.StartsWith("/swagger-ui") ? new StaticFileHandler() : null;
            });
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:57,代码来源:SwaggerFeature.cs

示例3: Register

        public void Register(IAppHost appHost)
        {
            appHost.RegisterService<AccountType.Service>();
            appHost.RegisterService<Country.Service>();

            //appHost.GetContainer().RegisterAutoWiredType(typeof(Users.Service));

            //appHost.GetContainer().Register<Users.Service>((c) => new Users.Service(c.Resolve<IBus>()));
            appHost.GetContainer().RegisterValidators(typeof(Plugin).Assembly);
        }
开发者ID:org-itbiz,项目名称:DDD.Enterprise.Example,代码行数:10,代码来源:Plugin.cs

示例4: Register

        public void Register(IAppHost appHost)
        {
            if (ResourceFilterPattern != null)
                SwaggerResourcesService.resourceFilterRegex = new Regex(ResourceFilterPattern, RegexOptions.Compiled);

            SwaggerApiService.UseCamelCaseModelPropertyNames = UseCamelCaseModelPropertyNames;
            SwaggerApiService.UseLowercaseUnderscoreModelPropertyNames = UseLowercaseUnderscoreModelPropertyNames;

            appHost.RegisterService(typeof(SwaggerResourcesService), new[] { "/resources" });
            appHost.RegisterService(typeof(SwaggerApiService), new[] { SwaggerResourcesService.RESOURCE_PATH + "/{Name*}" });
        }
开发者ID:JonCanning,项目名称:ServiceStack,代码行数:11,代码来源:SwaggerFeature.cs

示例5: Register

        public void Register(IAppHost appHost)
        {
            appHost.Routes.Add(typeof(GetAssetClassRequest), "/rest/assetclasses", "GET");
            appHost.Routes.Add(typeof(GetAssetClassRequest), "/rest/assetclasses/{AssetClass}", "GET");

            appHost.RegisterService(typeof(AssetClassService), "");
        }
开发者ID:docspy,项目名称:PSplusCFUI,代码行数:7,代码来源:AssetClassPlugin.cs

示例6: Register

 public void Register(IAppHost appHost)
 {
     // Get all of the services in this assembly that inherit from ServiceStackService
     GetType().Assembly.GetTypes().Where(a => a.BaseType == typeof(Service)).ToList()
         // Register the Service
         .Each(service => appHost.RegisterService(service));
 }
开发者ID:ryanhelms,项目名称:ServiceStack.Contrib,代码行数:7,代码来源:UptimeFeature.cs

示例7: Register

        public void Register(IAppHost appHost)
        {
            appHost.RegisterService<RequestLogsService>(AtRestPath);

            var requestLogger = RequestLogger ?? new InMemoryRollingRequestLogger(Capacity);
            requestLogger.EnableSessionTracking = EnableSessionTracking;
            requestLogger.EnableResponseTracking = EnableResponseTracking;
            requestLogger.EnableRequestBodyTracking = EnableRequestBodyTracking;
            requestLogger.EnableErrorTracking = EnableErrorTracking;
            requestLogger.RequiredRoles = RequiredRoles;
            requestLogger.ExcludeRequestDtoTypes = ExcludeRequestDtoTypes;
            requestLogger.HideRequestBodyForRequestDtoTypes = HideRequestBodyForRequestDtoTypes;

            appHost.Register(requestLogger);

            if (EnableRequestBodyTracking)
            {
                appHost.PreRequestFilters.Insert(0, (httpReq, httpRes) => {
                    httpReq.UseBufferedStream = EnableRequestBodyTracking;
                });
            }

            appHost.GetPlugin<MetadataFeature>()
                .AddDebugLink(AtRestPath, "Request Logs");
        }
开发者ID:BilliamBrown,项目名称:ServiceStack,代码行数:25,代码来源:RequestLogsFeature.cs

示例8: Register

        public void Register(IAppHost appHost)
        {
            appHost.Register<INativeTypesMetadata>(
                new NativeTypesMetadata(appHost.Metadata, MetadataTypesConfig));

            appHost.RegisterService<NativeTypesService>();
        }
开发者ID:vebin,项目名称:soa,代码行数:7,代码来源:NativeTypesFeature.cs

示例9: Register

        public void Register(IAppHost appHost)
        {
            // HACK: not great but unsure how to improve
            // throws exception if WebHostUrl isn't set as this is how we get endpoint url:port
            if (appHost.Config?.WebHostUrl == null)
                throw new ApplicationException("appHost.Config.WebHostUrl must be set to use the Consul plugin, this is so consul will know the full external http://url:port for the service");

            // register callbacks
            appHost.AfterInitCallbacks.Add(RegisterService);
            appHost.OnDisposeCallbacks.Add(UnRegisterService);

            appHost.RegisterService<HealthCheckService>();
            appHost.RegisterService<DiscoveryService>();

            // register plugin link
            appHost.GetPlugin<MetadataFeature>()?.AddPluginLink(ConsulUris.LocalAgent.CombineWith("ui"), "Consul Agent WebUI");
        }
开发者ID:MacLeanElectrical,项目名称:servicestack-discovery-consul,代码行数:17,代码来源:ConsulFeature.cs

示例10: Register

 public void Register(IAppHost appHost)
 {
     appHost.RegisterService<RequestLogsService>(AtRestPath);
     appHost.Register(RequestLogger
         ?? new InMemoryRollingRequestLogger(Capacity) {
             HideRequestBodyForRequestDtoTypes = HideRequestBodyForRequestDtoTypes
         });
 }
开发者ID:mnishihan,项目名称:ServiceStack,代码行数:8,代码来源:RequestLogsFeature.cs

示例11: Register

        /// <summary>
        /// Adding the files service routes
        /// </summary>
        /// <param name="appHost">The service stack appHost</param>
        public void Register(IAppHost appHost)
        {
            if (appHost == null)
                throw new ArgumentNullException("appHost");

            appHost.RegisterService<FilesWebService>();
            appHost.Routes.Add<FilesGetRequest>("/files-api", ApplyTo.Get);
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:12,代码来源:FilesServiceStackPlugin.cs

示例12: Register

        /// <summary>
        /// Adding the comments reviews routes
        /// </summary>
        /// <param name="appHost">The service stack appHost</param>
        public void Register(IAppHost appHost)
        {
            if (appHost == null)
                throw new ArgumentNullException("appHost");

            appHost.RegisterService<ReviewsWebService>();
            appHost.Routes.Add<AuthorReviewedGetRequest>(ReviewsServiceStackPlugin.ReviewsServiceUrl, ApplyTo.Get);
            appHost.Routes.Add<ReviewCreateRequest>(ReviewsServiceStackPlugin.ReviewsServiceUrl, ApplyTo.Post);
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:13,代码来源:ReviewsServiceStackPlugin.cs

示例13: Register

        /// <summary>
        /// Adding the SendGrid web hook service routes
        /// </summary>
        /// <param name="appHost">The service stack appHost</param>
        public void Register(IAppHost appHost)
        {
            if (appHost == null)
                throw new ArgumentNullException("appHost");

            appHost.RegisterService(typeof(SendGridEventsInboundService));

            // TODO: A unique string should be added to the URL for security reasons.
            appHost.Routes.Add<SendGridEvent[]>(string.Concat(SendGridWebHookPlugin.SendGridServiceRoute, "/events"), "POST");
        }
开发者ID:Sitefinity,项目名称:NewslettersSendGrid,代码行数:14,代码来源:SendGridWebHookPlugin.cs

示例14: Register

        public void Register(IAppHost appHost)
        {
            appHost.RegisterService<PostmanService>(AtRestPath);

            appHost.GetPlugin<MetadataFeature>()
                   .AddPluginLink(AtRestPath.TrimStart('/'), "Postman Metadata");

            if (EnableSessionExport == null)
                EnableSessionExport = appHost.Config.DebugMode;
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:10,代码来源:PostmanFeature.cs

示例15: Register

        public void Register(IAppHost appHost)
        {
            if (ResourceFilterPattern != null)
                SwaggerResourcesService.resourceFilterRegex = new Regex(ResourceFilterPattern, RegexOptions.Compiled);

            SwaggerApiService.UseCamelCaseModelPropertyNames = UseCamelCaseModelPropertyNames;
            SwaggerApiService.UseLowercaseUnderscoreModelPropertyNames = UseLowercaseUnderscoreModelPropertyNames;
            SwaggerApiService.DisableAutoDtoInBodyParam = DisableAutoDtoInBodyParam;
            SwaggerApiService.ModelFilter = ModelFilter;
            SwaggerApiService.ModelPropertyFilter = ModelPropertyFilter;

            appHost.RegisterService(typeof(SwaggerResourcesService), new[] { "/resources" });
            appHost.RegisterService(typeof(SwaggerApiService), new[] { SwaggerResourcesService.RESOURCE_PATH + "/{Name*}" });

            var metadata = appHost.GetPlugin<MetadataFeature>();
            if (metadata != null)
            {
                metadata.PluginLinks["swagger-ui/"] = "Swagger UI";
            }

            appHost.CatchAllHandlers.Add((httpMethod, pathInfo, filePath) =>
            {
                if (pathInfo == "/swagger-ui" || pathInfo == "/swagger-ui/" || pathInfo == "/swagger-ui/default.html")
                {
                    var indexFile = appHost.VirtualPathProvider.GetFile("/swagger-ui/index.html");
                    if (indexFile != null)
                    {
                        var html = indexFile.ReadAllText();

                        return new CustomResponseHandler((req, res) =>
                        {
                            res.ContentType = MimeTypes.Html;
                            var resourcesUrl = req.ResolveAbsoluteUrl("~/resources");
                            html = html.Replace("http://petstore.swagger.wordnik.com/api/api-docs", resourcesUrl);
                            return html;
                        });
                    }
                }
                return null;
            });
        }
开发者ID:nunopimenta,项目名称:ServiceStack,代码行数:41,代码来源:SwaggerFeature.cs


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