本文整理汇总了C#中TinyIoCContainer.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# TinyIoCContainer.Resolve方法的具体用法?C# TinyIoCContainer.Resolve怎么用?C# TinyIoCContainer.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TinyIoCContainer
的用法示例。
在下文中一共展示了TinyIoCContainer.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: RequestStartup
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
{
pipelines.BeforeRequest += (ctx) =>
{
Log.Request(ctx.Request);
var applicationService = container.Resolve<IApplicationService>();
var applicationId = context.Request.GetParam("applicationid");
if (!applicationService.IsRegistered(applicationId))
{
Log.Write("Warning: Unauthorized Access Attempt. ApplicationId = " + applicationId);
return HttpStatusCode.Unauthorized;
}
return null;
};
pipelines.OnError += (ctx, ex) =>
{
Log.Error("Unhandled error on request: " + context.Request.Url, ex);
return null;
};
pipelines.AfterRequest += (ctx) =>
{
if (ctx.Response.StatusCode == HttpStatusCode.OK) container.Resolve<IRavenSessionProvider>().SaveChangesAfterRequest();
Log.Response(ctx.Response);
};
base.RequestStartup(container, pipelines, context);
}
示例3: 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();
}
}
示例4: 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)));
}
示例5: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
Persistence.Config.Init();
Domain.Config.Init(container.Resolve<IEventBus>(), container.Resolve<IViewRepository>());
}
示例6: Initialize
public static TinyIoCContainer Initialize(InputOptions inputOptions,
ILogger overrideLogger = null)
{
if (inputOptions == null) throw new ArgumentNullException("inputOptions");
var ioc = new TinyIoCContainer();
ILogger logger = overrideLogger ?? GetLogger(inputOptions.IsRequestingDebug);
ioc.Register(logger);
ioc.Resolve<SettingsOverrideApplicator>()
.ApplySettingsFrom(inputOptions.SettingsOverride, Properties.Settings.Default);
inputOptions.DumpValuesForDebug(logger);
ioc.Register(ioc);
ioc.Register(inputOptions);
ioc.Register<WebServerLocation>().AsSingleton();
ioc.Register<IStatLightRunnerFactory, StatLightRunnerFactory>();
var eventAggregator = ioc.Resolve<EventAggregatorFactory>().Create();
ioc.Register(eventAggregator);
ioc.Register<IEventPublisher>(eventAggregator);
ioc.Register<IEventSubscriptionManager>(eventAggregator);
ioc.Register<ResponseFactory>().AsSingleton();
ioc.Register<IPostHandler, PostHandler>().AsSingleton();
ioc.Register<ICurrentStatLightConfiguration, CurrentStatLightConfiguration>();
return ioc;
}
示例7: Register
protected void Register(TinyIoCContainer container)
{
Configure(container);
container.Register<IMappingProvider>(new DefaultMappingProvider(container.ResolveAll<IMap>()));
container.Register<IConnectionStringProvider>(new DefaultConnectionStringProvider("ApplicationConnectionString"));
container.Register<IDatabaseFactory>(new DatabaseFactory(container.Resolve<IConnectionStringProvider>(), container.Resolve<IMappingProvider>()));
container.Register<IDatabase>(container.Resolve<IDatabaseFactory>().GetDatabase());
}
示例8: InitializeContext
private static void InitializeContext(TinyIoCContainer container)
{
container.Register<FeatureContext>().AsSingleton();
container.Register<ScenarioContext>().AsSingleton();
container.Register<StepContext>().AsSingleton();
container.Register<IContextHandler, ContextHandler>().AsSingleton();
var r = new RunContext(container.Resolve<IContextHandler>(), container.Resolve<HooksHandler>());
container.Register<IRunContext>(r);
container.Register<IRunContextEvents>(r);
}
示例9: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
_logger.Info("Starting NzbDrone API");
RegisterPipelines(pipelines);
container.Resolve<DatabaseTarget>().Register();
container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve<NzbDroneErrorPipeline>().HandleException);
}
示例10: RequestStartup
protected override void RequestStartup(TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
{
base.RequestStartup(container, pipelines, context);
var formsAuthenticationConfiguration = new FormsAuthenticationConfiguration
{
RedirectUrl = Route.Login,
UserMapper = container.Resolve<IUserMapper>(),
};
FormsAuthentication.Enable( pipelines, formsAuthenticationConfiguration );
LayoutViewBagInitializer.Enable( pipelines, container.Resolve<IDatabase>() );
}
示例11: Install
public void Install(TinyIoCContainer container)
{
serviceProvider = container.Resolve<IServiceProvider>();
menuCommandService = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (menuCommandService == null) return;
pluginConfiguration = container.Resolve<IPluginConfiguration>();
pluginConfiguration.PropertyChanged += SetButtonState;
solutionEvents = container.Resolve<ISolutionEventsListener>();
solutionEvents.AfterSolutionLoaded += SolutionLoaded;
solutionEvents.BeforeSolutionClosed += SolutionClosed;
var vs = container.Resolve<IVisualStudioService>();
InstallMenuCommands(vs.IsSolutionOpen);
}
示例12: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
container.Register<ISearchService<BlogPost>, SearchService>();
if (!Directory.Exists(HostingEnvironment.MapPath(ConfigurationManager.AppSettings["IndexPath"])))
{
var searchService = container.Resolve<ISearchService<BlogPost>>();
var blogService = container.Resolve<IBlogService>();
new Task(() => searchService.Index(blogService.LoadAll())).Start();
}
DiagnosticsHook.Disable(pipelines);
}
示例13: CreateHelperLogBuilderContainer
private static TinyIoCContainer CreateHelperLogBuilderContainer(TinyIoCContainer container)
{
var logContainer = new TinyIoCContainer();
logContainer.Register<IClientMessenger>((c, p) => container.Resolve<IClientMessenger>());
logContainer.Register<IMemoryLog>((c, p) => container.Resolve<IMemoryLog>());
logContainer.Register<FileLogFileNameProvider>();
logContainer.Register<FileLog>();
logContainer.Register<ILog>((c,p) => new CompositeLog(new List<ILog>()
{
c.Resolve<IMemoryLog>(),
c.Resolve<FileLog>()
}));
return logContainer;
}
示例14: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
Logger.Info("Starting NzbDrone API");
if (RuntimeInfoBase.IsProduction)
{
DiagnosticsHook.Disable(pipelines);
}
RegisterPipelines(pipelines);
container.Resolve<DatabaseTarget>().Register();
container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
}
示例15: StatLightRunnerFactory
public StatLightRunnerFactory(ILogger logger, TinyIoCContainer ioc)
{
if (logger == null) throw new ArgumentNullException("logger");
if (ioc == null) throw new ArgumentNullException("ioc");
_ioc = ioc;
_logger = logger;
_eventSubscriptionManager = ioc.Resolve<IEventSubscriptionManager>();
_eventPublisher = ioc.Resolve<IEventPublisher>();
_ioc.ResolveAndAddToEventAggregator<ConsoleDebugListener>();
_ioc.Resolve<ExtensionResolver>().AddExtensionsToEventAggregator();
}