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


C# TinyIoC.Resolve方法代码示例

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


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

示例1: RequestStartup

        protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            base.RequestStartup(container, pipelines, context);

            pipelines.BeforeRequest.AddItemToStartOfPipeline(
                ctx =>
                {
                    var facebookClient = container.Resolve<Facebook.FacebookClient>();
                    var fbUser = context.CurrentUser as IFacebookUser;
                    if (fbUser != null)
                        facebookClient.AccessToken = fbUser.FacebookAccessToken;

                    #region SignedRequest

                    if (context.Request != null)
                    {
                        dynamic signedRequest;
                        var fbApp = container.Resolve<Facebook.IFacebookApplication>();
                        if (context.Request.TryParseFacebookSignedRequest(fbApp.AppId, fbApp.AppSecret, out signedRequest))
                        {
                            if (signedRequest.ContainsKey("oauth_token"))
                                facebookClient.AccessToken = signedRequest.oauth_token;
                        }
                    }

                    #endregion

                    return null;
                });
        }
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:30,代码来源:Bootstrapper.cs

示例2: InitialiseInternal

        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);

            var configuration = new StitchConfiguration()
                                    {
                                        /*Compilers = new[]
                                                        {
                                                            new StitchConfigurationCompiler {Type = typeof (JavaScriptCompiler).AssemblyQualifiedName, Extension = ".js"},
                                                            new StitchConfigurationCompiler {Type = typeof (CoffeeScriptCompiler).AssemblyQualifiedName, Extension = ".coffee"},
                                                            new StitchConfigurationCompiler {Type = typeof (jQueryTemplateCompiler).AssemblyQualifiedName, Extension = ".tmpl"}
                                                        },*/
                                        Files = new[]
                                                    {
                                                        new StitchConfiguration()
                                                            {
                                                                Name = "/Scripts/app.stitch",
                                                                Paths = new[]
                                                                            {
                                                                                "Scripts/App"
                                                                            }
                                                            }
                                                    }
                                    };

            container.Register<IStitchConfiguration>(configuration);

            Stitch.Enable(this, container.Resolve<IRootPathProvider>(), container.Resolve<IStitchConfiguration>());
        }
开发者ID:nathanpalmer,项目名称:Nancy.Stitch,代码行数:29,代码来源:Bootstrapper.cs

示例3: FacebookRequestStartup

        private Response FacebookRequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
        {
            if (context.Request != null)
            {
                string[] perms = null;
                dynamic signedRequest;
                var fbApp = container.Resolve<IFacebookApplication>();
                if (context.TryParseFacebookSignedRequest(fbApp.AppId, fbApp.AppSecret, out signedRequest))
                {
                    if (((System.Collections.Generic.IDictionary<string, object>)signedRequest).ContainsKey("oauth_token"))
                    {
                        var fb = container.Resolve<FacebookClient>();
                        fb.AccessToken = signedRequest.oauth_token;
                        try
                        {
                            var result = (IDictionary<string, object>)fb.Get("me/permissions");
                            perms = ((IDictionary<string, object>)((IList<object>)result["data"])[0]).Keys.ToArray();
                        }
                        catch (FacebookOAuthException)
                        {
                            // access token is invalid so perms=none
                            // but don't throw exception.
                            fb.AccessToken = null;  
                        }
                    }
                }

                context.Items[CustomFacebookExtensions.FacebookPermsKey] = perms ?? new string[0];
            }

            return null;
        }
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:32,代码来源:Facebook.Bootstrapper.cs

示例4: InitialiseInternal

        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    Passphrase = "SuperSecretPass",
                    Salt = "AndVinegarCrisps",
                    HmacPassphrase = "UberSuperSecure",
                    RedirectUrl = "/authentication/login",
                    UsernameMapper = container.Resolve<IUsernameMapper>(),
                };

            FormsAuthentication.Enable(this, formsAuthConfiguration);

            BeforeRequest += ctx =>
            {
                var rootPathProvider =
                    container.Resolve<IRootPathProvider>();

                var staticFileExtensions =
                    new Dictionary<string, string>
                    {
                        { "jpg", "image/jpg" },
                        { "png", "image/png" },
                        { "gif", "image/gif" },
                        { "css", "text/css" },
                        { "js",  "text/javascript" }
                    };

                var requestedExtension =
                    Path.GetExtension(ctx.Request.Uri);

                if (!string.IsNullOrEmpty(requestedExtension))
                {
                    var extensionWithoutDot =
                        requestedExtension.Substring(1);

                    if (staticFileExtensions.Keys.Any(x => x.Equals(extensionWithoutDot, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        var fileName =
                            Path.GetFileName(ctx.Request.Uri);

                        if (fileName == null)
                        {
                            return null;
                        }

                        var filePath =
                            Path.Combine(rootPathProvider.GetRootPath(), "content", fileName);

                        return !File.Exists(filePath) ? null : new StaticFileResponse(filePath, staticFileExtensions[extensionWithoutDot]);
                    }
                }

                return null;
            };
        }
开发者ID:GraemeF,项目名称:NerdBeers,代码行数:58,代码来源:Bootstrapper.cs

示例5: ApplicationStartup

 protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
 {
     base.ApplicationStartup(container, pipelines);
     pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
         container.Resolve<IUserValidator>(),
         "NancyFx"));
 }
开发者ID:seun104,项目名称:AgbaraVOIP,代码行数:7,代码来源:AuthenticationBootstrapper.cs

示例6: ConfigureApplicationContainer

        protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            container.Register<Repositories.IAppUserMapper, Repositories.InMemoryAppUserMapper>().AsSingleton();
            container.Register<IUserMapper>(container.Resolve<Repositories.IAppUserMapper>());
        }
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:7,代码来源:Bootstrapper.cs

示例7: ApplicationStartup

        protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            StaticConfiguration.DisableErrorTraces = false;

            SassAndCoffee.Hooks.Enable(pipelines, new InMemoryCache(), container.Resolve<IRootPathProvider>());
        }
开发者ID:NancyFx,项目名称:Nancy.SassAndCoffee,代码行数:8,代码来源:Bootstrapper.cs

示例8: InitialiseInternal

        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);

            this.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                container.Resolve<IUserValidator>(),
                "MyRealm"));
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:8,代码来源:AuthenticationBootstrapper.cs

示例9: ConfigureApplicationContainer

        protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
        {
            container.Register<IPersistentStore, PersistentStore>().AsSingleton();

            var bus = StickABusInIt(container.Resolve<IPersistentStore>());

            container.Register<ICommandSender, FakeBus>(bus);
            container.Register<IEventPublisher, FakeBus>(bus);
        }
开发者ID:7digital,项目名称:sevendigital-content-ingestion-spike,代码行数:9,代码来源:FakeBusBootstrapper.cs

示例10: ConfigureRequestContainer

        protected override void ConfigureRequestContainer(TinyIoC.TinyIoCContainer container, NancyContext context)
        {
            base.ConfigureRequestContainer(container, context);

            container.Register< BlogService>();
            var ravenSession = container.Resolve< IRavenSessionProvider >().GetSession();
            container.Register( ravenSession );

            container.Register< IBlogService, BlogService >();
        }
开发者ID:andycwk,项目名称:SharpBytes.PersonalBlog,代码行数:10,代码来源:NancyBootStrapper.cs

示例11: ApplicationStartup

        protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var formsAuthConfig = new FormsAuthenticationConfiguration
                                      {
                                          RedirectUrl = "~/facebook/login",
                                          UserMapper = container.Resolve<IUserMapper>()
                                      };
            FormsAuthentication.Enable(pipelines, formsAuthConfig);
        }
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:11,代码来源:Bootstrapper.cs

示例12: RequestStartup

        protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration
                    {
                    RedirectUrl = "~/login",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
            base.RequestStartup(container, pipelines);
        }
开发者ID:markrendle,项目名称:NancyTwitter,代码行数:12,代码来源:Bootstrapper.cs

示例13: InitialiseInternal

        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);

            var formsAuthConfiguration =
                new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UserMapper = container.Resolve<IUserMapper>(),
                };

            FormsAuthentication.Enable(this, formsAuthConfiguration);
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:13,代码来源:FormsAuthBootstrapper.cs

示例14: ApplicationStartup

        protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
                                                    container.Resolve<IUserValidator>(),
                                                    "RateAllTheThings"));

            pipelines.OnError += (context, exception) =>
            {
                exception.SendToAirbrake();
                return null;
            };
        }
开发者ID:FredrikL,项目名称:RateAllTheThingsBackend,代码行数:14,代码来源:RateAllTheThingsBootstrapper.cs

示例15: InitialiseInternal

    protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
    {
        base.InitialiseInternal(container);

        var formsAuthConfiguration =
            new FormsAuthenticationConfiguration()
                {
                    RedirectUrl = "~/login",
                    UsernameMapper = container.Resolve<IUsernameMapper>(),
                };

        FormsAuthentication.Enable(this, formsAuthConfiguration);
        //Adding a check on the pipeline to validate if the user is still authorised by facebook.
        this.BeforeRequest.AddItemToEndOfPipeline(FacebookAuthenticatedCheckPipeline.CheckUserIsNothAuthorisedByFacebookAnymore);
    }
开发者ID:juanfranblanco,项目名称:SocialDemocracy,代码行数:15,代码来源:FormsAuthBootstrapper.cs


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