本文整理汇总了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();
}
示例2: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
Trace.TraceInformation("Bootstrapper.ConfigureApplicationContainer");
base.ConfigureApplicationContainer(container);
container.Register<IDocumentFolder>((c,p)=> new DocumentFolder(_rootDirectory));
}
示例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)));
}
示例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();
}
示例5: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
ExceptionlessClient.Default.Configuration.UseTraceLogger();
ExceptionlessClient.Default.RegisterNancy(pipelines);
}
示例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;
}
示例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);
}
示例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)});
}
示例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()));
}
示例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());
}
示例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();
}
}
示例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);
}
示例13: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
// Enable JavaScript Object Notation
Jsonp.Enable(pipelines);
}
示例14: ConfigureRequestContainer
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
base.ConfigureRequestContainer(container, context);
container.Register<IUserMapper, FakeRepository>();
container.Register<IRepository, FakeRepository>();
}
示例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();
}