本文整理汇总了C#中IContainer.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IContainer.Get方法的具体用法?C# IContainer.Get怎么用?C# IContainer.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContainer
的用法示例。
在下文中一共展示了IContainer.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: App
static App()
{
_container = ContainerContext.Current;
_container.Register<IMessenger>(new Messenger());
ViewModelService.TypeFinder = (name) => {
var typeDiscoverer = _container.Get<ITypeDiscoverer>();
var types = typeDiscoverer.FindAnyByName(name);
if (types.Length > 1) throw new ArgumentException("Ambiguous viewModel name");
return types[0];
};
ViewModelService.InstanceCreator = (t) => _container.Get(t);
}
示例2: Configure
public void Configure(IContainer container)
{
var basicApiProvider = container.Get<IBasicApiProvider>();
var registry = container.Get<IRegistry>();
registry.Config = basicApiProvider.GetDefaultUaConfig();
registry.LoggingConfig = basicApiProvider.GetDefaultLoggingConfig();
registry.MediaConfig = container.Get<IMediaApiProvider>().GetDefaultConfig();
container.RegisterAsSingleton(registry.LoggingConfig);
container.RegisterAsSingleton(registry.Config);
container.RegisterAsSingleton(registry.MediaConfig);
container.RegisterAsSingleton<ISipUserAgent, ISipUserAgentInternal, DefaultSipUserAgent>();
}
示例3: Configure
public void Configure(IContainer container)
{
Helper.GuardNotNull(container);
container.RegisterAsSingleton<IObjectFactory, DefaultObjectFactory>();
container.RegisterAsSingleton<ILocalRegistry, DefaultLocalRegistry>();
container.RegisterAsSingleton(container.Get<ILocalRegistry>() as IConfigurationContext);
container.RegisterAsSingleton<IImManager, DefaultImManager>();
container.RegisterAsSingleton(container.Get<IImManager>().As<IImManagerInternal>());
container.Register<IMessageBuilder, DefaultMessageBuilder>();
container.Register<IBuddyBuilder, DefaultBuddyBuilder>();
container.Register<IBuddyInternal, Buddy>();
container.RegisterAsSingleton<ISipUserAgent, DefaultSipUserAgent>();
container.RegisterAsSingleton(container.Get<ISipUserAgent>() as ISipUserAgentInternal);
}
示例4: GeneratedProxies
public GeneratedProxies(
CommandProxies commandProxies,
CommandSecurityProxies commandSecurityProxies,
QueryProxies queryProxies,
ReadModelProxies readModelProxies,
ServiceProxies serviceProxies,
NamespaceConfigurationProxies namespaceConfigurationProxies,
ITypeDiscoverer typeDiscoverer,
IContainer container)
{
var builder = new StringBuilder();
builder.Append(commandProxies.Generate());
builder.Append(commandSecurityProxies.Generate());
builder.Append(readModelProxies.Generate());
builder.Append(queryProxies.Generate());
builder.Append(serviceProxies.Generate());
builder.Append(namespaceConfigurationProxies.Generate());
var generatorTypes = typeDiscoverer.FindMultiple<IProxyGenerator>().Where(t => !t.Namespace.StartsWith("Bifrost"));
foreach (var generatorType in generatorTypes)
{
var generator = container.Get(generatorType) as IProxyGenerator;
builder.Append(generator.Generate());
}
All = builder.ToString();
}
示例5: Initialize
public void Initialize(IContainer container)
{
var typeDiscoverer = container.Get<ITypeDiscoverer>();
FluentConfiguration.Mappings(m => DiscoverClassMapsAndAddAssemblies(typeDiscoverer, m));
Configuration = FluentConfiguration.BuildConfiguration();
SessionFactory = Configuration.BuildSessionFactory();
}
示例6: Main
public static void Main (string[] args)
{
var kernel = new StandardKernel();
Container = new Container(kernel);
Configure.With(Container)
.UsingJsonStorage("JsonDB")
.Initialize();
var commandCoordinator = ServiceLocator.Current.GetInstance<ICommandCoordinator>();
var command = new CreatePerson(Guid.NewGuid(), "First", "Person");
var result = commandCoordinator.Handle(command);
if (!result.Success)
{
Console.WriteLine("Handling of command failed");
Console.WriteLine("Exception : {0}\nStack Trace : {1}", result.Exception.Message, result.Exception.StackTrace);
}
var queries = Container.Get<IPersonView>();
var persons = queries.GetAll();
foreach (var person in persons)
{
Console.WriteLine("Person ({0}) - {1} {2}", person.Id, person.FirstName, person.LastName);
}
}
示例7: Configure
public void Configure(IContainer container)
{
Helper.GuardNotNull(container);
container.RegisterAsSingleton<IAccountManager, DefaultAccountManager>();
container.RegisterAsSingleton(container.Get<IAccountManager>() as IAccountManagerInternal);
container.Register<IAccountBuilder, DefaultAccountBuilder>();
container.Register<IAccountInternal, Account>();
}
示例8: DiscoverAssembliesWithHbmMappings
static IList<Assembly> DiscoverAssembliesWithHbmMappings(IContainer container)
{
return container
.Get<IAssemblies>()
.GetAll()
.Where(a => a.GetManifestResourceNames().Any(s => s.EndsWith(".hbm.xml")))
.ToList();
}
示例9: Configure
public void Configure(IContainer container)
{
Helper.GuardNotNull(container);
container.RegisterAsSingleton<ICallManager, DefaultCallManager>();
container.RegisterAsSingleton(container.Get<ICallManager>() as ICallManagerInternal);
container.Register<ICallBuilder, DefaultCallBuilder>();
container.Register<ICallInternal, Call>();
}
示例10: Configure
public void Configure(IContainer container)
{
Helper.GuardNotNull(container);
container.RegisterAsSingleton<IConferenceBridge, DefaultConferenceBridge>();
container.RegisterAsSingleton<IMediaManager, DefaultMediaManager>();
container.RegisterAsSingleton(container.Get<IMediaManager>() as IMediaManagerInternal);
container.Register<CodecInfo, CodecInfo>();
container.Register<IWavPlayer, WavPlayer>();
}
示例11: UIPort
public UIPort(IContainer container, ScrollViewer scrollViewer, StackPanel mainStack)
{
_container = container;
_normalMode = _container.Get<IHasNormalMode>();
_mainStack = mainStack;
_stackPanelWrapper = new StackPanelWrapper(mainStack, scrollViewer, false);
}
示例12: DiscoverAssembliesWithFluentMappings
static IList<Assembly> DiscoverAssembliesWithFluentMappings(IContainer container)
{
return container
.Get<IImplementorFinder>()
.GetImplementorsFor(typeof(IMappingProvider))
.Select(t => t.Assembly)
.Distinct()
.ToList();
}
示例13: Initialize
#pragma warning disable 1591 // Xml Comments
public void Initialize(IContainer container)
{
var typeDiscoverer = container.Get<ITypeDiscoverer>();
var resolverType = typeof(DefaultPrincipalResolver);
var resolverTypes = typeDiscoverer.FindMultiple<ICanResolvePrincipal>().Where(t => t.Assembly != typeof(SecurityConfiguration).Assembly);
if (resolverTypes.Count() > 1) throw new MultiplePrincipalResolversFound();
if (resolverTypes.Count() == 1) resolverType = resolverTypes.First();
container.Bind<ICanResolvePrincipal>(resolverType);
}
示例14: Initialize
public void Initialize(IContainer container)
{
container.Bind(typeof(ICommandFor<>), (Type t) =>
{
var commandForProxies = container.Get<ICommandForProxies>();
return commandForProxies.CallGenericMethod<object, ICommandForProxies>(cc => cc.GetFor<Bifrost.Commands.Command>, t.GenericTypeArguments[0]);
});
var dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
Bifrost.Execution.DispatcherManager.Current = new Bifrost.Execution.Dispatcher(dispatcher);
container.Bind<System.Windows.Threading.Dispatcher>(dispatcher);
Configure.Instance.Container.Bind<IDispatcher>(Bifrost.Execution.DispatcherManager.Current);
var proxyGenerator = new ProxyGenerator();
Configure.Instance.Container.Bind<IProxyBuilder>(proxyGenerator.ProxyBuilder);
Configure.Instance.Container.Bind(typeof(ICanHandleInvocationsFor<,>), typeof(InvocationHandler<,>));
}
示例15: NoteCollection
public NoteCollection(IContainer container)
{
_container = container;
#if DEBUG
var file = new FileInfo(@"..\..\notes.xml");
#else
var file = new FileInfo("notes.xml");
#endif
_document = file.Exists
? XDocument.Load(file.FullName)
: new XDocument(new XElement("notes"));
_children = _document
.Elements("notes")
.Single()
.Elements("note")
.Select(noteElement => (object) _container.Get<NoteItem>(noteElement))
.ToArray();
}