本文整理汇总了C#中TinyIoCContainer.ResolveAll方法的典型用法代码示例。如果您正苦于以下问题:C# TinyIoCContainer.ResolveAll方法的具体用法?C# TinyIoCContainer.ResolveAll怎么用?C# TinyIoCContainer.ResolveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TinyIoCContainer
的用法示例。
在下文中一共展示了TinyIoCContainer.ResolveAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MasterServerBase
protected MasterServerBase(TinyIoCContainer container, IPEndPoint endpoint)
: this(endpoint)
{
// Resolve lifecycle callbacks
ApplicationLifecycleCallbacks.AddRange(
container.ResolveAll<IApplicationLifecycleCallbackHandler>().OrderByDescending(s => s.Priority).ToList());
MessageLifecycleCallbacks.AddRange(
container.ResolveAll<IMessageLifecycleCallbackHandler>().OrderByDescending(s => s.Priority).ToList());
}
示例2: ConfigureContainer
public static void ConfigureContainer(TinyIoCContainer container)
{
container.Register(typeof(ILogHandler), typeof(Logger.Log4NetLogger)).AsSingleton();
container.Register(typeof(IMessageRouter<IMessage>), typeof(MessageRouter)).AsSingleton();
container.RegisterMultiple<IClientLifecycleCallbackHandler>(new List<Type>()
{
typeof (BlyncLightManager),
typeof (SkypeManager)
}).AsSingleton();
container.RegisterMultiple<IBlyncLightBehaviour>(new List<Type>()
{
typeof (SkypeStatusResponder),
typeof (BlyncLightScheduler)
});
container.RegisterMultiple<ISkypeBehaviour>(new List<Type>()
{
typeof (CallStatusNotifier),
typeof (UserStatusNotifier),
typeof (OnBreakBehaviour),
typeof (OnLunchBehaviour),
typeof (OnCallBehaviour)
});
//IBlyncLightBehaviour
container.Register(typeof(SkypeStatusResponder),
new SkypeStatusResponder(container.Resolve<IMessageRouter<IMessage>>()));
//IClientLifecycleCallbackHandler
container.Register(typeof(SkypeManager),
new SkypeManager(container.Resolve<ILogHandler>(),
container.Resolve<IMessageRouter<IMessage>>(),
container.ResolveAll<ISkypeBehaviour>().OrderByDescending(s => s.Priority).ToList()));
container.Register(typeof(BlyncLightManager),
new BlyncLightManager(container.Resolve<ILogHandler>(),
container.Resolve<IMessageRouter<IMessage>>(),
container.ResolveAll<IBlyncLightBehaviour>().OrderByDescending(s => s.Priority).ToList()));
//Client
container.Register(typeof(BlyncLightForSkypeClient),
new BlyncLightForSkypeClient());
}
示例3: AppBootstrapper
public AppBootstrapper()
{
Router = new RoutingState();
Kernel = new TinyIoCContainer();
// XXX: This is gross
Kernel.Register<UIViewController>(new RouterUINavigationController(Router), "InitialPage");
Kernel.Register(typeof(IViewFor<iOSPlaygroundViewModel>), typeof(iOSPlaygroundViewController));
Kernel.Register<IScreen>(this);
var toRegister = new Dictionary<Tuple<Type, String>, List<Type>>();
RxApp.ConfigureServiceLocator(
(t, s) => s != null ? Kernel.Resolve(t, s) : Kernel.Resolve(t),
(t, s) => Kernel.ResolveAll(t, true),
(c, t, s) => {
if (toRegister != null) {
var pair = Tuple.Create(t,s);
if (!toRegister.ContainsKey(pair)) {
toRegister[pair] = new List<Type>();
}
toRegister[pair].Add(c);
return;
}
if (s != null) {
Kernel.Register(t, c, s);
} else {
Kernel.Register(t, c);
}
});
foreach(var key in toRegister.Keys) {
var val = toRegister[key].Distinct();
Kernel.RegisterMultiple(key.Item1, val);
}
toRegister = null;
var items = Kernel.ResolveAll(typeof(ICreatesObservableForProperty), true).ToArray();
Router.Navigate.Go<iOSPlaygroundViewModel>();
}
示例4: 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());
}
示例5: ApplicationStartup
//.........这里部分代码省略.........
Directory.CreateDirectory(Path.Combine(BootStrapper.RootPath, "App_Data"));
ModuleResource.ReadSystemsAndResources(BootStrapper.RootPath);
#region View Conventions
this.Conventions.ViewLocationConventions.Clear();
// Site's View Folder has most priority
// Mobile View Overrides
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
string u = context.Context.Request.Headers.UserAgent.ToLowerInvariant();
if (u.Contains("mobile/"))
{
return "Site/Views/Mobile/" + viewName;
}
return string.Empty; // not mobile browser
});
// Desktop View Location
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return "Site/Views/Desktop/" + viewName;
});
// Generic View Location
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return "Site/Views/" + viewName;
});
// NancyBlack's View Location
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return "Content/Views/" + viewName;
});
// then try Views in Systems (AdminSystem, ContentSystem etc...)
foreach (var system in ModuleResource.Systems)
{
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return string.Concat("Modules/",
viewName);
});
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return string.Concat("Modules/",
system,
"/Views/",
viewName);
});
}
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return viewName; // fully qualify names
});
this.Conventions.ViewLocationConventions.Add((viewName, model, context) =>
{
return viewName.Substring(1); // fully qualify names, remove forward slash at first
});
#endregion
var formsAuthConfiguration = new FormsAuthenticationConfiguration
{
RedirectUrl = "~/__membership/login",
UserMapper = container.Resolve<IUserMapper>(),
};
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
pipelines.BeforeRequest.AddItemToStartOfPipeline((ctx) =>
{
ctx.Items["SiteDatabase"] = NancyBlackDatabase.GetSiteDatabase(this.RootPathProvider.GetRootPath());
ctx.Items["CurrentSite"] = BootStrapper.GetSiteSettings();
ctx.Items["SiteSettings"] = BootStrapper.GetSiteSettings();
if (ctx.CurrentUser == null)
{
ctx.CurrentUser = NcbUser.Anonymous;
if (ctx.Request.Url.HostName == "localhost")
{
ctx.CurrentUser = NcbUser.LocalHostAdmin;
}
}
return null;
});
foreach (var item in container.ResolveAll<IPipelineHook>())
{
item.Hook(pipelines);
}
}