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


C# TinyIoCContainer.Resolve方法代码示例

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


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

示例1: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {

            base.ApplicationStartup(container, pipelines);

            var configuration = new BasicAuthenticationConfiguration(container.Resolve<IUserValidator>(), "test-realm");
            BasicAuthentication.Enable(pipelines,configuration);

            var stateless = new StatelessAuthenticationConfiguration(c =>
            {
                const string key = "X-Auth-Token";
                string token = null;

                if (c.Request.Headers.Authorization == null || !c.Request.Headers.Authorization.Any())
                {
                    _log.ErrorFormat("No request headers are present in the request {0}", c);
                    return null;
                }

                if (c.Request.Headers.FirstOrDefault(f => f.Key == key).Value == null ||
                    string.IsNullOrEmpty(c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First()))
                {
                    _log.ErrorFormat("No Key present in the request headers");
                    return null;
                }

                token = c.Request.Headers.FirstOrDefault(f => f.Key == key).Value.First();
                _log.InfoFormat("Token used {0}", token);

                var user = container.Resolve<IUserApiMapper>();
                return user.GetUserFromToken(token);

            });
            StatelessAuthentication.Enable(pipelines, stateless);
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:35,代码来源:Bootstrapper.cs

示例2: RequestStartup

        protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
        {
            pipelines.BeforeRequest += (ctx) =>
            {
                Log.Request(ctx.Request);
                var applicationService = container.Resolve<IApplicationService>();
                var applicationId = context.Request.GetParam("applicationid");
                if (!applicationService.IsRegistered(applicationId))
                {
                    Log.Write("Warning: Unauthorized Access Attempt. ApplicationId = " + applicationId);
                    return HttpStatusCode.Unauthorized;
                }
                return null;
            };

            pipelines.OnError += (ctx, ex) =>
            {
                Log.Error("Unhandled error on request: " + context.Request.Url, ex);
                return null;
            };

            pipelines.AfterRequest += (ctx) =>
            {
                if (ctx.Response.StatusCode == HttpStatusCode.OK) container.Resolve<IRavenSessionProvider>().SaveChangesAfterRequest();
                Log.Response(ctx.Response);
            };

            base.RequestStartup(container, pipelines, context);
        }
开发者ID:biofractal,项目名称:ThumbsUp,代码行数:29,代码来源:ThumbsUpBootstrapper.cs

示例3: ViewModelLocator

        public ViewModelLocator()
        {
            _container = TinyIoCContainer.Current;
            _container.Register<ClockViewModel>().AsSingleton();
            _container.Register<AirportsViewModel>().AsSingleton();
            _container.Register<IGetAirports, AirportNamesService>().AsSingleton();
            _container.Register<IDispatchOnUIThread, DispatchAdapter>().AsSingleton();
            _container.Register<IStoreObjects, ObjectStore>().AsSingleton();

            #if DEBUG
            _container.Register<IGeolocation>(new PresetLocationService(63.433281, 10.419294, _container.Resolve<IDispatchOnUIThread>()));
            #else
            _container.Register<IGeolocation, MonoMobile.Extensions.Geolocation>();
            #endif
            _container.Register(new NearestAirportService(_container.Resolve<IGeolocation>(), _container.Resolve<ITinyMessengerHub>()));

            if (DesignerProperties.IsInDesignTool)
            {
                //_container.Register<IStoreObjects, DesignTimeObjectStore>().AsSingleton();
                _container.Register<IGetFlights, DesignTimeFlightsService>().AsSingleton();
                _container.Register<IFlightsViewModel, FlightsDesignTimeViewModel>().AsSingleton();
            }
            else
            {
                _container.Register<IGetFlights, FlightsService>().AsSingleton();
                _container.Register<IFlightsViewModel, FlightsViewModel>().AsSingleton();
            }
        }
开发者ID:ravihansen,项目名称:FlightsNorway,代码行数:28,代码来源:ViewModelLocator.cs

示例4: ConfigureContainer

        public static void ConfigureContainer(TinyIoCContainer container)
        {
            var opts = container.Resolve<Options>();

            container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton();
            container.Register<InMemorySessionManager>().AsSingleton();

            var sessionManager = container.Resolve<InMemorySessionManager>();
            container.Register<ISessionHandler, InMemorySessionManager>(sessionManager);

            container.RegisterMultiple<IMessageLifecycleCallbackHandler>(new List<Type>()
            {
                typeof (SessionMessageLifecycleCallback),
                typeof (SpamManager)
            }).AsSingleton();

            IPAddress ipAddress;

            if (IPAddress.TryParse(opts.IPAddress, out ipAddress) == false)
            {
                throw new ArgumentException("Failed to parse IP Address: " + opts.IPAddress);
            }

            container.Register(typeof(TorqueMasterServer),
                new TorqueMasterServer(container, new IPEndPoint(ipAddress, opts.Port)));
        }
开发者ID:souxiaosou,项目名称:TorqueMasterServer,代码行数:26,代码来源:Program.cs

示例5: ConfigureApplicationContainer

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

            Persistence.Config.Init();
            Domain.Config.Init(container.Resolve<IEventBus>(), container.Resolve<IViewRepository>());
        }
开发者ID:yarikzub,项目名称:Ligas,代码行数:7,代码来源:Bootstrapper.cs

示例6: Initialize

        public static TinyIoCContainer Initialize(InputOptions inputOptions,
            ILogger overrideLogger = null)
        {
            if (inputOptions == null) throw new ArgumentNullException("inputOptions");
            var ioc = new TinyIoCContainer();
            ILogger logger = overrideLogger ?? GetLogger(inputOptions.IsRequestingDebug);
            ioc.Register(logger);

            ioc.Resolve<SettingsOverrideApplicator>()
                .ApplySettingsFrom(inputOptions.SettingsOverride, Properties.Settings.Default);

            inputOptions.DumpValuesForDebug(logger);
            ioc.Register(ioc);
            ioc.Register(inputOptions);
            ioc.Register<WebServerLocation>().AsSingleton();
            ioc.Register<IStatLightRunnerFactory, StatLightRunnerFactory>();

            var eventAggregator = ioc.Resolve<EventAggregatorFactory>().Create();
            ioc.Register(eventAggregator);
            ioc.Register<IEventPublisher>(eventAggregator);
            ioc.Register<IEventSubscriptionManager>(eventAggregator);

            ioc.Register<ResponseFactory>().AsSingleton();

            ioc.Register<IPostHandler, PostHandler>().AsSingleton();
            ioc.Register<ICurrentStatLightConfiguration, CurrentStatLightConfiguration>();

            return ioc;
        }
开发者ID:staxmanade,项目名称:StatLight,代码行数:29,代码来源:BootStrapper.cs

示例7: Register

        protected void Register(TinyIoCContainer container)
        {
            Configure(container);

            container.Register<IMappingProvider>(new DefaultMappingProvider(container.ResolveAll<IMap>()));
            container.Register<IConnectionStringProvider>(new DefaultConnectionStringProvider("ApplicationConnectionString"));
            container.Register<IDatabaseFactory>(new DatabaseFactory(container.Resolve<IConnectionStringProvider>(), container.Resolve<IMappingProvider>()));
            container.Register<IDatabase>(container.Resolve<IDatabaseFactory>().GetDatabase());
        }
开发者ID:bytefish,项目名称:GcmSample,代码行数:9,代码来源:TransactionalTestBase.cs

示例8: InitializeContext

 private static void InitializeContext(TinyIoCContainer container)
 {
     container.Register<FeatureContext>().AsSingleton();
     container.Register<ScenarioContext>().AsSingleton();
     container.Register<StepContext>().AsSingleton();
     container.Register<IContextHandler, ContextHandler>().AsSingleton();
     var r = new RunContext(container.Resolve<IContextHandler>(), container.Resolve<HooksHandler>());
     container.Register<IRunContext>(r);
     container.Register<IRunContextEvents>(r);
 }
开发者ID:smhabdoli,项目名称:NBehave,代码行数:10,代码来源:NBehaveInitializer.cs

示例9: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            _logger.Info("Starting NzbDrone API");

            RegisterPipelines(pipelines);

            container.Resolve<DatabaseTarget>().Register();
            container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());

            ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve<NzbDroneErrorPipeline>().HandleException);
        }
开发者ID:peterlandry,项目名称:NzbDrone,代码行数:11,代码来源:NancyBootstrapper.cs

示例10: RequestStartup

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

            var formsAuthenticationConfiguration = new FormsAuthenticationConfiguration
            {
                RedirectUrl = Route.Login,
                UserMapper = container.Resolve<IUserMapper>(),
            };
            FormsAuthentication.Enable( pipelines, formsAuthenticationConfiguration );

            LayoutViewBagInitializer.Enable( pipelines, container.Resolve<IDatabase>() );
        }
开发者ID:Breeto,项目名称:MatchMaker,代码行数:13,代码来源:Bootstrapper.cs

示例11: Install

        public void Install(TinyIoCContainer container)
        {
            serviceProvider = container.Resolve<IServiceProvider>();

            menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (menuCommandService == null) return;
            pluginConfiguration = container.Resolve<IPluginConfiguration>();
            pluginConfiguration.PropertyChanged += SetButtonState;
            solutionEvents = container.Resolve<ISolutionEventsListener>();
            solutionEvents.AfterSolutionLoaded += SolutionLoaded;
            solutionEvents.BeforeSolutionClosed += SolutionClosed;
            var vs = container.Resolve<IVisualStudioService>();
            InstallMenuCommands(vs.IsSolutionOpen);
        }
开发者ID:smhabdoli,项目名称:NBehave,代码行数:14,代码来源:MenuCommandTask.cs

示例12: ApplicationStartup

    protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
    {
      base.ApplicationStartup(container, pipelines);
      container.Register<ISearchService<BlogPost>, SearchService>();

      if (!Directory.Exists(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["IndexPath"])))
      {
        var searchService = container.Resolve<ISearchService<BlogPost>>();
        var blogService = container.Resolve<IBlogService>();
        new Task(() => searchService.Index(blogService.LoadAll())).Start();
      }

      DiagnosticsHook.Disable(pipelines);
    }
开发者ID:garethrhughes,项目名称:grhughes.com.Website,代码行数:14,代码来源:Bootstrapper.cs

示例13: CreateHelperLogBuilderContainer

 private static TinyIoCContainer CreateHelperLogBuilderContainer(TinyIoCContainer container)
 {
     var logContainer = new TinyIoCContainer();
     logContainer.Register<IClientMessenger>((c, p) => container.Resolve<IClientMessenger>());
     logContainer.Register<IMemoryLog>((c, p) => container.Resolve<IMemoryLog>());
     logContainer.Register<FileLogFileNameProvider>();
     logContainer.Register<FileLog>();
     logContainer.Register<ILog>((c,p) => new CompositeLog(new List<ILog>()
         {
             c.Resolve<IMemoryLog>(),
             c.Resolve<FileLog>()
         }));
     return logContainer;
 }
开发者ID:TomPeters,项目名称:chooie,代码行数:14,代码来源:StartupContainerBuilder.cs

示例14: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            Logger.Info("Starting NzbDrone API");

            if (RuntimeInfoBase.IsProduction)
            {
                DiagnosticsHook.Disable(pipelines);
            }

            RegisterPipelines(pipelines);

            container.Resolve<DatabaseTarget>().Register();
            container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
        }
开发者ID:drewfreyling,项目名称:NzbDrone,代码行数:14,代码来源:NancyBootstrapper.cs

示例15: StatLightRunnerFactory

        public StatLightRunnerFactory(ILogger logger, TinyIoCContainer ioc)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (ioc == null) throw new ArgumentNullException("ioc");

            _ioc = ioc;
            _logger = logger;

            _eventSubscriptionManager = ioc.Resolve<IEventSubscriptionManager>();
            _eventPublisher = ioc.Resolve<IEventPublisher>();

            _ioc.ResolveAndAddToEventAggregator<ConsoleDebugListener>();

            _ioc.Resolve<ExtensionResolver>().AddExtensionsToEventAggregator();
        }
开发者ID:remogloor,项目名称:StatLight,代码行数:15,代码来源:StatLightRunnerFactory.cs


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