本文整理汇总了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*}" });
}
示例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;
});
}
示例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);
}
示例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*}" });
}
示例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), "");
}
示例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));
}
示例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");
}
示例8: Register
public void Register(IAppHost appHost)
{
appHost.Register<INativeTypesMetadata>(
new NativeTypesMetadata(appHost.Metadata, MetadataTypesConfig));
appHost.RegisterService<NativeTypesService>();
}
示例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");
}
示例10: Register
public void Register(IAppHost appHost)
{
appHost.RegisterService<RequestLogsService>(AtRestPath);
appHost.Register(RequestLogger
?? new InMemoryRollingRequestLogger(Capacity) {
HideRequestBodyForRequestDtoTypes = HideRequestBodyForRequestDtoTypes
});
}
示例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);
}
示例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);
}
示例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");
}
示例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;
}
示例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;
});
}