NancyFx中使用自带的IOC容器
Posted b̶i̶n̶g̶.̶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NancyFx中使用自带的IOC容器相关的知识,希望对你有一定的参考价值。
/// <summary> /// Cors扩展 /// </summary> public static class IPipelinesExtensions { /// <summary> /// CORS Enable /// </summary> /// <param name="pipelines">pipelines</param> public static void UserCors(this IPipelines pipelines) { pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) => { ctx.Response.WithHeader("Access-Control-Allow-Origin", "*") .WithHeader("Access-Control-Allow-Methods", "POST,GET") .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type"); }); } } /// <summary> /// Nancyfx Ioc /// </summary> public class MyBootstrapper : DefaultNancyBootstrapper { protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines) { // pipelines.UserCors(); base.ApplicationStartup(container, pipelines); } protected override void ConfigureApplicationContainer(TinyIoCContainer container) { container.Register<ISys_User, Sys_User> base.ConfigureApplicationContainer(container); } }
以上是关于NancyFx中使用自带的IOC容器的主要内容,如果未能解决你的问题,请参考以下文章