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


C# TinyIoCContainer类代码示例

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


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

示例1: RegisterProjections

        private void RegisterProjections(TinyIoCContainer container)
        {
            var itemDetailRepository = new InMemoryItemDetailRepository();
            container.Register<IItemDetailRepository>(itemDetailRepository);
            var itemDetailViewWriter = new InMemoryViewWriter<Guid, ItemDetailViewModel>(itemDetailRepository);
            var itemDetails = new ItemDetailResultProjection(
                itemDetailViewWriter);

            var itemDetailSubscription = new GetEventStoreEventDispatcher(
                EventStoreConnection, serializerSettings, itemDetailViewWriter, bus);
            itemDetailSubscription.Subscribe<ItemTracked>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemPicked>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemLiquidated>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemReceived>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<ItemQuantityAdjusted>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<CycleCountStarted>(itemDetails.Handle);
            itemDetailSubscription.Subscribe<CycleCountCompleted>(itemDetails.Handle);

            itemDetailSubscription.StartDispatching();

            container.Register<IItemSearchRepository>(
                (c, n) => new RavenItemSearchRepository(c.Resolve<IDocumentSession>()));
            var itemSearchSessionObserver = new CatchUpDocumentSessionObserver<ItemSearchResultViewModel>(DocumentStore);
            bus.Register(itemSearchSessionObserver);
            var itemSearch = new ItemSearchResultProjection(
                new RavenDbViewWriter<Guid, ItemSearchResultViewModel>(
                    itemSearchSessionObserver));

            var itemSearchSubscription = new GetEventStoreEventDispatcher(
                EventStoreConnection, serializerSettings, itemSearchSessionObserver, bus);
            itemSearchSubscription.Subscribe<ItemTracked>(itemSearch.Handle);

            itemSearchSubscription.StartDispatching();
        }
开发者ID:haf,项目名称:derp.inventory,代码行数:34,代码来源:Bootstrapper.Wireup.cs

示例2: ConfigureApplicationContainer

        protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            Trace.TraceInformation("Bootstrapper.ConfigureApplicationContainer");
            base.ConfigureApplicationContainer(container);

            container.Register<IDocumentFolder>((c,p)=> new DocumentFolder(_rootDirectory));
        }
开发者ID:rlipscombe,项目名称:vs-welcome-page,代码行数:7,代码来源:Bootstrapper.cs

示例3: 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

示例4: ConfigureApplicationContainer

 // Overriding this just to show how it works, not actually necessary as autoregister
 // takes care of it all.
 protected override void ConfigureApplicationContainer(TinyIoCContainer existingContainer)
 {
     // We don't call base because we don't want autoregister
     // we just register our one known dependency as an application level singleton
     existingContainer.Register<IApplicationDependency, ApplicationDependencyClass>().AsSingleton();
     existingContainer.Register<IRazorConfiguration, MyRazorConfiguration>().AsSingleton();
 }
开发者ID:rhwy,项目名称:Nancy,代码行数:9,代码来源:DemoBootstrapper.cs

示例5: ApplicationStartup

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

            ExceptionlessClient.Default.Configuration.UseTraceLogger();
            ExceptionlessClient.Default.RegisterNancy(pipelines);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:7,代码来源:ExceptionlessBootstrapper.cs

示例6: ConfigureContainer

        private static TinyIoCContainer ConfigureContainer(IEnumerable<IDiagnosticsProvider> providers, IRootPathProvider rootPathProvider, IRequestTracing requestTracing, NancyInternalConfiguration configuration, INancyEnvironment diagnosticsEnvironment)
        {
            var diagContainer = new TinyIoCContainer();

            diagContainer.Register<IInteractiveDiagnostics, InteractiveDiagnostics>();
            diagContainer.Register<IRequestTracing>(requestTracing);
            diagContainer.Register<IRootPathProvider>(rootPathProvider);
            diagContainer.Register<NancyInternalConfiguration>(configuration);
            diagContainer.Register<IModelBinderLocator, DefaultModelBinderLocator>();
            diagContainer.Register<IBinder, DefaultBinder>();
            diagContainer.Register<IFieldNameConverter, DefaultFieldNameConverter>();
            diagContainer.Register<BindingDefaults, BindingDefaults>();
            diagContainer.Register<INancyEnvironment>(diagnosticsEnvironment);
            diagContainer.Register<ISerializer>(new DefaultJsonSerializer(diagnosticsEnvironment));

            foreach (var diagnosticsProvider in providers)
            {
                var key = string.Concat(
                    diagnosticsProvider.GetType().FullName,
                    "_",
                    diagnosticsProvider.DiagnosticObject.GetType().FullName);

                diagContainer.Register<IDiagnosticsProvider>(diagnosticsProvider, key);
            }

            foreach (var moduleType in AppDomainAssemblyTypeScanner.TypesOf<DiagnosticModule>().ToArray())
            {
                diagContainer.Register(typeof(INancyModule), moduleType, moduleType.FullName).AsMultiInstance();
            }

            return diagContainer;
        }
开发者ID:l3m,项目名称:Nancy,代码行数:32,代码来源:DiagnosticsModuleCatalog.cs

示例7: 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

示例8: ConfigureApplicationContainer

 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     base.ConfigureApplicationContainer(container);
     container.Register(_solution);
     container.Register(_fileSystem);
     container.RegisterMultiple<IReferenceProcessor>(new []{typeof(AddProjectReferenceProcessor), typeof(AddFileReferenceProcessor), typeof(AddGacReferenceProcessor)});
 }
开发者ID:kirtgoh,项目名称:vim-ycm-windows,代码行数:7,代码来源:Bootstrapper.cs

示例9: ConfigureApplicationContainer

 protected override void ConfigureApplicationContainer(TinyIoCContainer container)
 {
     var dir = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data"));
     var store = new JsonStore<EventDescriptor>(dir, "store", "events");
     container.Register<IDataStore<EventDescriptor>, JsonStore<EventDescriptor>>(store);
     container.Register<IStore>(new Store(store, new JsonSerializer()));
 }
开发者ID:guillermoAlbarello,项目名称:verdant-kidney,代码行数:7,代码来源:PersistenceBootstrapper.cs

示例10: ApplicationStartup

        protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);
            var buildStepNames = ConfigurationManager.AppSettings["PipelineBuildSteps"].Split(',');

            container.Register(buildStepNames.Select(s => (IBuildStep) new BuildStep(s)).ToArray());
        }
开发者ID:pimterry,项目名称:hipchat-filterer,代码行数:7,代码来源:Bootstrapper.cs

示例11: 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

示例12: RequestStartup

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

            FormsAuthentication.Enable(pipelines, formsAuthConfig);

            pipelines.AfterRequest += ctx =>
            {
                var dbContext = container.Resolve<SmartFlowContext>();
                dbContext.SaveChanges();
            };

            pipelines.OnError += (ctx, ex) =>
            {
                var logger = container.Resolve<TextFileLogger>();
                logger.Write("Error", Enums.LogLevel.ApplicationError, ex);
                return ErrorResponse.FromException(ex);
            };

            base.RequestStartup(container, pipelines, context);
        }
开发者ID:DeanMcgarrigle,项目名称:SmartFlow,代码行数:25,代码来源:Bootstrapper.cs

示例13: ApplicationStartup

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

            // Enable JavaScript Object Notation
            Jsonp.Enable(pipelines);
        }
开发者ID:Jsprsoft,项目名称:SimpleWork,代码行数:7,代码来源:Bootstrapper.cs

示例14: ConfigureRequestContainer

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

            container.Register<IUserMapper, FakeRepository>();
            container.Register<IRepository, FakeRepository>();
        }
开发者ID:markashleybell,项目名称:gtdpad,代码行数:7,代码来源:TestBootstrapper.cs

示例15: ApplicationStartup

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

            JsonSettings.RetainCasing = true;
            JsonSettings.MaxJsonLength = int.MaxValue;
            StaticConfiguration.CaseSensitive = false;

            var sessionManager = new SessionManager(new MemorySessionProvider("Encore", int.Parse(ConfigurationManager.AppSettings["Session.Timeout"])));
            sessionManager.Run(pipelines);

            pipelines.OnError.AddItemToEndOfPipeline((ctx, ex) =>
            {
                log.Error("Unhandled error on request: " + ctx.Request.Url, ex);

                ctx.Items["error"] = new Error
                {
                    ErrorMessage = "An unhandled error occurred",
                    StatusCode = HttpStatusCode.InternalServerError
                };

                return null;
            });

            ConfigureAutoMapper();
        }
开发者ID:alnya,项目名称:Encore-v2,代码行数:26,代码来源:Bootstrapper.cs


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