本文整理汇总了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));
}
示例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);
}
示例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>();
}
示例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();
});
}
示例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);
}
示例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);
});
}
}
示例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>()));
}
示例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;
}
}
}
}
示例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;
}
}
}
示例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();
}
示例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)));
}
示例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);
});
}
示例13: ShellWindow
public ShellWindow(IWindsorContainer container)
{
InitializeComponent();
_inputContainer.Content = container.Resolve<ISearchInputView>();
_resultsContainer.Content = container.Resolve<SearchResultsView>();
}
示例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();
}
示例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>();
}