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


C# IWindsorContainer.Resolve方法代码示例

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


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

示例1: MessageLoggingTests

        public MessageLoggingTests()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log_endpoint.esent");
            if (Directory.Exists(path))
                Directory.Delete(path, true);

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
                .UseCastleWindsor(container)
                .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
                .Configure();
            container.Register(Component.For<MessageLoggingModule>());

            messageSerializer = container.Resolve<IMessageSerializer>();
            queue = new QueueManager(new IPEndPoint(IPAddress.Any, 2202), path);
            queue.CreateQueues("log_endpoint");
            queue.Start();
            

            var innerTransport = container.Resolve<ITransport>();
            innerTransport.Start();
            transport = MockRepository.GenerateStub<ITransport>();
            transport.Stub(t => t.Send(null, null)).IgnoreArguments()
                .Do((Delegates.Action<Endpoint, object[]>)(innerTransport.Send));
        }
开发者ID:BiYiTuan,项目名称:rhino-esb,代码行数:25,代码来源:MessageLoggingTests.cs

示例2: RequestStartup

        protected override void RequestStartup(IWindsorContainer container, IPipelines pipelines, NancyContext context)
        {
            pipelines.BeforeRequest.AddItemToEndOfPipeline(nancyContext =>
            {
                this.Info(() => "Api invoked at {0}[{1}]".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url));
                var token = "";
                var cookie = nancyContext.Request.Headers.Cookie.FirstOrDefault(x => (x.Name + "").ToLower() == "token");
                if (cookie != null)
                    token = HttpUtility.UrlDecode(cookie.Value);

                nancyContext.Request.Headers.Authorization = "Token {0}".FormatWith(token);

                var user = container.Resolve<ITokenizer>().Detokenize(token, nancyContext, new DefaultUserIdentityResolver());
                if (user != null)
                {
                    nancyContext.CurrentUser = user;
                }
                return null;
            });
            pipelines.AfterRequest.AddItemToEndOfPipeline(nancyContext => this.Info(() => "Api invoked successfully at {0}[{1}]".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url)));
            pipelines.OnError.AddItemToEndOfPipeline((nancyContext, exception) =>
            {
                this.Error(() => "Error on Api request {0}[{1}] => {2}".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url, exception));
                var errorResponse = ErrorResponse.FromException(exception);
                if (exception is LightstoneAutoException)
                    errorResponse.StatusCode = HttpStatusCode.ImATeapot;

                return errorResponse;
            });
            pipelines.EnableCors(); // cross origin resource sharing

            TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>()));

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

示例3: DailyGrossRepositoryTest

        public DailyGrossRepositoryTest()
        {
            System.Configuration.ConnectionStringSettings cs = System.Configuration.ConfigurationManager.ConnectionStrings["aps"];

            _container = new WindsorContainer();
            _container
                .Register(Component.For<IDatabase>()
                    .ImplementedBy<Database>()
                    .DependsOn(Dependency.OnValue("provider", cs.ProviderName))
                    .DependsOn(Dependency.OnValue("connectionString", cs.ConnectionString))
                    //.DependsOn(Dependency.OnValue("provider", "System.Data.SqlClient"))
                    //.DependsOn(Dependency.OnValue("connectionString", "Data Source=dev-s01;Initial Catalog=aps;User ID=sa;[email protected]"))
                )
                .Register(Component.For<IDailyGrossRepository>()
                    .ImplementedBy<DailyGrossRepository>()
                );

            _now = DateTime.Now;
            _ww = _now.WorkWeek();
            _db = _container.Resolve<IDatabase>();
            TestHelpers.TestData.Reset(_db);
            _employee = TestHelpers.TestData.GetEmployee(_db, "Tom");            

            _repos = _container.Resolve<IDailyGrossRepository>();
        }
开发者ID:jcapuano328,项目名称:aps.mvc,代码行数:25,代码来源:DailyGrossRepositoryTest.cs

示例4: AddTransactionScope

        public static void AddTransactionScope(this IPipelines pipelines, IWindsorContainer container)
        {
            pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx =>
            {
                var session = container.Resolve<ISession>();
                if (session != null)
                {
                    session.BeginTransaction();
                    return null;
                }
                return null;
            });

            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx =>
            {
                var session = container.Resolve<ISession>();
                if (session == null)
                    return;
                if (!session.Transaction.IsActive) 
                    return;
                if (ctx.Response.StatusCode == HttpStatusCode.InternalServerError)
                    session.Transaction.Rollback();
                else
                    session.Transaction.Commit();
            });
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:26,代码来源:PipelineExtensions.cs

示例5: Install

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            var concreteTypes = BuildManager.GetReferencedAssemblies().Cast<Assembly>().Where(assembly => !assembly.GlobalAssemblyCache).ConcreteTypes();

            IList<IModelMetadataConfiguration> configurations = new List<IModelMetadataConfiguration>();

            concreteTypes.Where(type => typeof (IModelMetadataConfiguration).IsAssignableFrom(type))
                         .Each(type =>
                             {
                                 container.Register(Component.For(type).LifestyleTransient());
                                 configurations.Add((IModelMetadataConfiguration) container.Resolve(type));
                             });

            container.Register(Component.For<IModelMetadataRegistry>().ImplementedBy<ModelMetadataRegistry>().LifestyleSingleton());

            var registry = container.Resolve<IModelMetadataRegistry>();

            configurations.Each(configuration => registry.RegisterModelProperties(configuration.ModelType, configuration.Configurations));

            IList<ModelValidatorProvider> validatorProviders = new List<ModelValidatorProvider>(ModelValidatorProviders.Providers);
            validatorProviders.Insert(0, new ExtendedModelValidatorProvider());
            var compositeModelValidatorProvider = new CompositeModelValidatorProvider(validatorProviders.ToArray());

            ModelMetadataProviders.Current = new ExtendedModelMetadataProvider(registry);
            ModelValidatorProviders.Providers.Clear();
            ModelValidatorProviders.Providers.Add(compositeModelValidatorProvider);
        }
开发者ID:v0id24,项目名称:ByndyuSoft.Infrastructure,代码行数:27,代码来源:WindsorInstaller.cs

示例6: GeneratePayslip

        public void GeneratePayslip(
            IWindsorContainer container,
            string inputPath,
            string outputPath,
            string taxTablePath)
        {
            var fileReadAsyncInputData = container.Resolve<IFileReadAsyncAccess<InputData>>();
            var fileWriteOutputData = container.Resolve<IFileWriteAccess<OutputData>>(Container.CsvFileWriteAccess);
            var payslipManager = container.Resolve<ICalculationManager>();
            var taxManager = container.Resolve<ITaxManager>();
            var fileReadTaxData = container.Resolve<IFileReadAccess<Tax>>(Container.CsvFileReadAccess);

            fileWriteOutputData.WriteFile(outputPath, new List<OutputData>());
            var taxList = fileReadTaxData.ReadFile(taxTablePath);

            using (StreamWriter sw = File.AppendText(outputPath))
            {
                fileReadAsyncInputData.ReadFileAsync(inputPath, record =>
                {
                    var outputData = payslipManager.GenerateOutputData(record, taxList, taxManager);
                    string formatedRecord =
                        string.Format($"{outputData.Name},{outputData.PayPeriod},{outputData.GrossIncome},{outputData.IncomeTax},{outputData.NetIncome},{outputData.Super}");
                    sw.WriteLine(formatedRecord);
                });
            }
        }
开发者ID:steven2000nz,项目名称:Projects,代码行数:26,代码来源:PayslipManager.cs

示例7: RequestStartup

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

            pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx =>
            {
                if (ctx.CurrentUser != null) ctx.ViewBag.UserName = ctx.CurrentUser.UserName;
                return null;
            });

            pipelines.BeforeRequest.AddItemToStartOfPipeline(nancyContext =>
            {
                //nancyContext.Request.Headers.UserAgent = "Lightstone";
                var token = "";
                var cookie = nancyContext.Request.Headers.Cookie.FirstOrDefault(x => (x.Name + "").ToLower() == "token");
                if (cookie != null)
                    token = HttpUtility.UrlDecode(cookie.Value);
                    //nancyContext.Request.Headers.Authorization = "Token {0}".FormatWith(HttpUtility.UrlDecode(token.Value));

                var user = container.Resolve<ITokenizer>().Detokenize(token, nancyContext, new DefaultUserIdentityResolver());
                if (user != null)
                    nancyContext.CurrentUser = user;
                return null;
            });
            TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>()));
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:31,代码来源:Bootstrapper.cs

示例8: JobRegistry

        public JobRegistry(IWindsorContainer container)
        {
            var cacheService = container.Resolve<ICacheService>();
            var configurationService = container.Resolve<IConfigurationService>();
            var logger = container.Resolve<ILogger>();

            foreach (var job in configurationService.Jobs)
            {
                if (job.Enabled)
                {
                    switch (job.Name)
                    {
                        case "email":
                            var menu = cacheService.GetMenu();
                            menu.Wait();
                            DateTime submitOrderTime;

                            if (DateTime.TryParse(menu.Result.Vendor.SubmitOrderTime, out submitOrderTime) &&
                                menu.Exception == null)
                            {
                                Schedule<VendorOrderMailJob>().ToRunEvery(0).Days().At(submitOrderTime.Hour, submitOrderTime.Minute);
                                logger.Info($"Order mail job has been scheduled to run every day @ {submitOrderTime.Hour}h{submitOrderTime.Minute}s UTC");
                            }
                            break;
                        case "backup":
                            var hours = 1;
                            var seconds = 0;
                            // run each first hour of the day
                            Schedule<BackupJob>().ToRunEvery(0).Days().At(1,0);
                            logger.Info($"Backup job has been scheduled to run every day @ {hours}h{seconds}s UTC");
                            break;
                    }
                }
            }
        }
开发者ID:CoditEU,项目名称:lunchorder,代码行数:35,代码来源:JobRegistry.cs

示例9: Install

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Component.For<IServiceFacade>().ImplementedBy<ServiceFacade>(),
                Component.For<IConfigurationRestService>().Instance(ConfigurationRestService.Load()),
                Component.For<IServiceConfig>().ImplementedBy<ServiceConfig>());

            var configs = ServiceConfiguration.GetListOfConfigurationsInternal();
            int i = 0;
            foreach (var config in configs)
            {
                i++;
                switch (config.ServiceType)
                {
                    case "VSO":
                        container.Register(
                            Component.For<IHelperClass>()
                                .ImplementedBy<VsoHelperClass>()
                                .DependsOn(Dependency.OnValue<IServiceConfig>(config)).Named("HelperClass" + i));
                        var instanceVso = container.Resolve<IHelperClass>("HelperClass" + i);
                        container.Register(
                            Component.For<IService>().ImplementedBy<VsoRestService>().DependsOn(Dependency.OnValue<IHelperClass>(instanceVso)).Named("VsoRestService"+i));
                        break;
                    case "TFS":
                        container.Register(
                            Component.For<ITfsHelperClass>()
                                .ImplementedBy<TfsHelperClass>()
                                .DependsOn(Dependency.OnValue<IServiceConfig>(config)).Named("HelperClass" + i));
                        var instanceTfs = container.Resolve<ITfsHelperClass>("HelperClass" + i);
                        container.Register(
                            Component.For<IService>().ImplementedBy<TfsService>().DependsOn(Dependency.OnValue<IHelperClass>(instanceTfs)).Named("VsoRestService"+i));
                        break;
                }
            }

        }
开发者ID:iozag,项目名称:Buildscreen,代码行数:35,代码来源:BuildScreenRegistry.cs

示例10: Main

        static void Main(string[] args)
        {
            _container = new WindsorContainer();
            ComponentRegistrar.AddComponentsTo(_container);

            _container.Register(
                Component.For<LinkRanker>(),
                Component.For<LinkIndexer>(),
                Component.For<Miner>(),
                Component.For<FeedSpider>(),
                Component.For<IIndexer>()
                    .ImplementedBy<DeliciousTagIndexer>()
                    .ImplementedBy<PostRankIndexer>()
                    .ImplementedBy<SemanticTagIndexer>()
                    .ImplementedBy<SolrIndexer>()
                );

            var feeds = _container.Resolve<IRepository<Feed>>();

            feeds.SaveOrUpdate(new Feed {Name = "YCombinator", Url = "http://news.ycombinator.com/rss"});
            feeds.DbContext.CommitChanges();

            var miner = _container.Resolve<Miner>(new
            {
                getFeedSpider = new Func<Feed, FeedSpider>(GetFeedSpider)
            });

            miner.Start();
        }
开发者ID:jhollingworth,项目名称:Serendipity,代码行数:29,代码来源:Program.cs

示例11: Before_each_spec

        protected override void Before_each_spec()
        {
            _dispatcher = Create<Dispatcher>();
             _bogusArguments = new string[] {"no-such-command"};
             _mockHelpCommand = Mock<ICommand>();

             _mockContainer = Mock<IWindsorContainer>();

             SetupResult.For(_mockContainer.Resolve<ICommand>("no-such-command"))
            .Throw(new ComponentNotFoundException("no-such-command"));

             SetupResult.For(_mockContainer.Resolve<ICommand>("help"))
            .Return(_mockHelpCommand);

             Locator.InitializeContainer(_mockContainer);

             SetupResult.For(Get<IArgumentParser>().Parse(_bogusArguments))
            .Return(new ArgumentParser().Parse(_bogusArguments));

             SetupResult.For(Get<IArgumentMapFactory>().CreateMap(_dispatcher))
            .Return(new ArgumentMap(typeof (Dispatcher)));

             SetupResult.For(Get<IArgumentMapFactory>().CreateMap(_mockHelpCommand))
            .Return(new ArgumentMap(typeof (ICommand)));
        }
开发者ID:developernotes,项目名称:nu,代码行数:25,代码来源:DispatcherSpecs.cs

示例12: RequestStartup

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

            pipelines.BeforeRequest.AddItemToEndOfPipeline(nancyContext =>
            {
                this.Info(() => "Monitoring API invoked at {0}[{1}]".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url));
                var token = "";
                var cookie = nancyContext.Request.Headers.Cookie.FirstOrDefault(x => (x.Name + "").ToLower() == "token");
                if (cookie != null)
                    token = HttpUtility.UrlDecode(cookie.Value);

                nancyContext.Request.Headers.Authorization = "Token {0}".FormatWith(token);

                var user = container.Resolve<ITokenizer>().Detokenize(token, nancyContext, new DefaultUserIdentityResolver());
                if (user != null)
                {
                    nancyContext.CurrentUser = user;
                }
                return null;
            });

            pipelines.OnError.AddItemToEndOfPipeline((nancyContext, exception) =>
            {
                this.Error(() => "Error on Monitoring request {0}[{1}] => {2}".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url, exception));
                return ErrorResponse.FromException(exception);
            });
            TokenAuthentication.Enable(pipelines, new TokenAuthenticationConfiguration(container.Resolve<ITokenizer>()));

            pipelines.OnError.AddItemToEndOfPipeline((nancyContext, exception) =>
            {
                this.Error(() => "Error on Monitoring request {0}[{1}] => {2}".FormatWith(nancyContext.Request.Method, nancyContext.Request.Url, exception));
                return ErrorResponse.FromException(exception);
            });
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:35,代码来源:Bootstrapper.cs

示例13: ShellWindow

 public ShellWindow(IWindsorContainer container)
 {
     InitializeComponent();
     
     _inputContainer.Content = container.Resolve<ISearchInputView>();
     _resultsContainer.Content = container.Resolve<SearchResultsView>();
 }
开发者ID:PaulStovell,项目名称:presentations,代码行数:7,代码来源:ShellWindow.cs

示例14: RegisterRaven

        private static void RegisterRaven(IWindsorContainer container)
        {
            //frig for injecting a store from tests
            var havestore = false;
            try
            {
                var store = container.Resolve<IDocumentStore>();
                if (store != null)
                    havestore = true;
            }
            catch
            {

            }

            //only need one raven store per app domain
            if (!havestore)
                container.Register(Component.For<IDocumentStore>().Instance(DocumentStoreFactory.GetDocumentStore()));

            //each request gets its own session
            container.Register(Component.For<IDocumentSession>().LifeStyle.Transient.UsingFactoryMethod(c => c.Resolve<IDocumentStore>().OpenSession()));


            var session = container.Resolve<IDocumentSession>();
            session.SaveChanges();
        }
开发者ID:RHMGLtd,项目名称:sourcecode,代码行数:26,代码来源:RavenInstaller.cs

示例15: ConfigMetadata

        private static void ConfigMetadata(IModelRegistrar reg, IWindsorContainer container)
        {
            reg.ModelNamespacePattern("Centros.Model.{0}, Centros.Model");
            reg.RegisterPatterApplier(new IdPatternApplier { IdPropertyName = "Id" });
            reg.RegisterPatterApplier(new ReferencePatternApplier { ExcludeReferenceTypes = new[] { typeof(Horario) } });
            reg.DomainAccessorAccessor(modelType =>
                                       	{
                                       		var providerType = typeof (IDomainAccessor<>).MakeGenericType(modelType);
                                       		return (IDomainAccessor<object>) container.Resolve(providerType);
                                       	}).
                DomainMutatorAccessor(modelType =>
                                      	{
                                      		var providerType = typeof (IDomainMutator<>).MakeGenericType(modelType);
                                      		return (IDomainMutator<object>) container.Resolve(providerType);
                                      	});

            reg.ForType<Centro>();
            reg.ForType<Educador>();
            reg.ForType<Horario>();
            reg.ForType<Institucion>(md => md.Description("Institución"));
            reg.ForType<Jurisdiccion>(md => md.Description("Jurisdicción"));
            reg.ForType<Organizacion>(md => md.Description("Organización"));
            reg.ForType<Participacion>();
            reg.ForType<Participante>();
            reg.ForType<Registro>();
            reg.ForType<Taller>();
        }
开发者ID:carlospeix,项目名称:ConfUi,代码行数:27,代码来源:MetadataBuilderConfig.cs


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