本文整理汇总了C#中TinyIoCContainer类的典型用法代码示例。如果您正苦于以下问题:C# TinyIoCContainer类的具体用法?C# TinyIoCContainer怎么用?C# TinyIoCContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TinyIoCContainer类属于命名空间,在下文中一共展示了TinyIoCContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Register
/// <summary>
/// Registers components in the React IoC container
/// </summary>
/// <param name="container">Container to register components in</param>
public void Register(TinyIoCContainer container)
{
if (MSBuildUtils.IsInMSBuild())
{
RegisterForMSBuild(container);
}
}
开发者ID:jjridge7,项目名称:React.NET,代码行数:11,代码来源:AssemblyRegistration.cs
示例17: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
CookieBasedSessions.Enable(pipelines);
Conventions.ViewLocationConventions.Add((viewName, model, context) => string.Concat("views/", viewName));
Conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("assets", @"assets")
);
container.Register<IFlexUserStore, FlexMembershipUserStore<User, Role>>();
container.Register(typeof(IDocumentStore), InitDocStore());
container.Register(typeof(IDocumentSession), (c, overloads) =>
c.Resolve<IDocumentStore>().OpenSession());
var cryptographyConfiguration = new CryptographyConfiguration(
new RijndaelEncryptionProvider(new PassphraseKeyGenerator(Configuration.EncryptionKey, new byte[] { 8, 2, 10, 4, 68, 120, 7, 14 })),
new DefaultHmacProvider(new PassphraseKeyGenerator(Configuration.HmacKey, new byte[] { 1, 20, 73, 49, 25, 106, 78, 86 })));
var authenticationConfiguration =
new FormsAuthenticationConfiguration()
{
CryptographyConfiguration = cryptographyConfiguration,
RedirectUrl = "/login",
UserMapper = container.Resolve<IUserMapper>(),
};
FormsAuthentication.Enable(pipelines, authenticationConfiguration);
FlexMembershipProvider.RegisterClient(
new GoogleOpenIdClient(),
"Google", new Dictionary<string, object>());
}
开发者ID:julianjelfs,项目名称:geeks-nancy,代码行数:35,代码来源:Bootstrap.cs
示例18: ApplicationStartup
/// <summary>
/// Applications the startup.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="pipelines">The pipelines.</param>
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.BeforeRequest += ctx =>
{
var identity = (WindowsIdentity)HttpContext.Current.User.Identity;
if (identity.IsAuthenticated)
{
// Resolve<UserManager>
// Get from DB/Cache
// Add user to ICurrentUSerProvider
// Get Claims
ctx.CurrentUser = new DemoUserIdentity
{
UserName = identity.Name,
Claims = new[] { "Basic", "Finance" }
};
}
return null;
};
pipelines.AfterRequest += ctx =>
{
// If status code comes back as Unauthorized then
// forward the user to the unauthorised page
//if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized
// || ctx.Response.StatusCode == HttpStatusCode.Forbidden)
//{
// ctx.Response = new RedirectResponse("/Unauthorised");
//}
};
}
开发者ID:caodaiming,项目名称:Snippets,代码行数:40,代码来源:CustomBootstrapper.cs
示例19: ApplicationStartup
// The bootstrapper enables you to reconfigure the composition of the framework,
// by overriding the various methods and properties.
// For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
container.Register<IStorage, Storage>().AsSingleton();
container.Register<CredentialsStorage>().AsSingleton();
var serverScheduler = new ServerScheduler(container.Resolve<IStorage>());
serverScheduler.Start();
}
开发者ID:Stelmashenko-A,项目名称:CourseWork,代码行数:10,代码来源:Bootstrapper.cs
示例20: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
container.Register<IArticleReader, ArticleReader>();
container.Register<IArticleStorage, ArticleStorage>();
}
开发者ID:sanazbakhtiari,项目名称:public-site,代码行数:7,代码来源:InputSiteBootstrapTest.cs
注:本文中的TinyIoCContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论