本文整理汇总了C#中IResolutionRoot类的典型用法代码示例。如果您正苦于以下问题:C# IResolutionRoot类的具体用法?C# IResolutionRoot怎么用?C# IResolutionRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IResolutionRoot类属于命名空间,在下文中一共展示了IResolutionRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public object Resolve(IResolutionRoot resolutionRoot, IResolutionParameters resolutionParameters)
{
Type type = resolutionParameters.TypeToResolve;
TypeInfo typeInfo = type.GetTypeInfo();
if (typeInfo.IsGenericType)
{
var genericType = type.GetGenericTypeDefinition();
if (genericType == typeof(IEnumerable<>) ||
genericType == typeof(ICollection<>) ||
genericType == typeof(IList<>) ||
genericType == typeof(List<>))
{
return this.GetAllAsList(resolutionRoot, typeInfo.GenericTypeArguments[0], resolutionParameters);
}
}
if (typeInfo.IsArray)
{
var argumentType = type.GetElementType();
return this.GetAllAsArray(resolutionRoot, argumentType, resolutionParameters);
}
return resolutionRoot.Get(
type,
resolutionParameters.Constraint,
resolutionParameters.Parameters.ToArray());
}
示例2: NinjectDependencyScope
public NinjectDependencyScope(IResolutionRoot resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
this.resolver = resolver;
}
示例3: ChildKernel
/// <summary>
/// Initializes a new instance of the <see cref="ChildKernel"/> class.
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="modules">The modules.</param>
public ChildKernel(IResolutionRoot parent, params INinjectModule[] modules)
: base(modules)
{
this.parent = parent;
this.Components.RemoveAll<IActivationCache>();
this.Components.Add<IActivationCache, ChildActivationCache>();
}
示例4: NinjectServiceScope
public NinjectServiceScope(
IResolutionRoot resolver,
IEnumerable<IParameter> inheritedParameters)
{
_scope = new ScopeParameter();
inheritedParameters = inheritedParameters.AddOrReplaceScopeParameter(_scope);
_serviceProvider = new NinjectServiceProvider(resolver, inheritedParameters.ToArray());
}
示例5: CreateAuthKernel
private static ChildKernel CreateAuthKernel(IResolutionRoot parent)
{
var kernel = new ChildKernel(parent, new ServerModule(), new AuthServerModule());
kernel.Rebind<IPacketCodeTable>().To<AuthPacketCodeTableV75>().InSingletonScope();
kernel.Rebind<IAuthenticator>().To<StubAuthenticator>().InSingletonScope();
kernel.Rebind<IAccountProvider>().To<StubAccountProvider>().InSingletonScope();
return kernel;
}
示例6: WcfBootstrapper
/// <summary>
/// Initializes it all.
/// </summary>
public WcfBootstrapper(IEnumerable<OsWcfConfiguration> configurations, IResolutionRoot resolutionRoot, ILogger logger)
: base(resolutionRoot, logger)
{
this.configurations = configurations.ToList();
this.hosts = new List<ServiceHost>(this.configurations.Count);
this.isDisposed = false;
}
示例7: GetAllAsArray
public object GetAllAsArray(IResolutionRoot resolutionRoot, Type type, IResolutionParameters resolutionParameters)
{
var list = this.GetAllAsList(resolutionRoot, type, resolutionParameters);
return typeof(Enumerable)
.GetTypeInfo()
.GetDeclaredMethod("ToArray")
.MakeGenericMethod(type)
.Invoke(null, new[] { list });
}
示例8: ChildKernel
/// <summary>
/// Initializes a new instance of the <see cref="ChildKernel"/> class.
/// </summary>
/// <param name="parent">The parent.</param>
/// <param name="modules">The modules.</param>
public ChildKernel(IResolutionRoot parent, params INinjectModule[] modules)
: base(modules)
{
this.parent = parent;
this.Components.RemoveAll<IActivationCache>();
this.Components.Add<IActivationCache, ChildActivationCache>();
this.Components.RemoveAll<IConstructorScorer>();
this.Components.Add<IConstructorScorer, StandardConstructorScorerForChildKernel>();
}
示例9: Dispose
public void Dispose()
{
//IDisposable disposable = resolver as IDisposable;
//if (disposable != null)
// disposable.Dispose();
resolver = null;
}
示例10: Dispose
public void Dispose()
{
var disposable = _resolver as IDisposable;
if (disposable != null)
disposable.Dispose();
_resolver = null;
}
示例11: NinjectDependencyResolver
public NinjectDependencyResolver()
{
IKernel kernel = new StandardKernel();
resolutionRoot = kernel;
DoBindings(kernel);
}
示例12: Dispose
public void Dispose()
{
IDisposable disposable = resolver as IDisposable;
if (disposable != null)
disposable.Dispose();
resolver = null;
}
示例13: Dispose
public void Dispose()
{
var disposable = _resolutionRoot as IDisposable;
if(disposable!=null)
disposable.Dispose();
_resolutionRoot = null;
}
示例14: Dispose
public void Dispose()
{
var disposable = resolver as IDisposable;
disposable?.Dispose();
resolver = null;
}
示例15: Dispose
public void Dispose()
{
var root = this.resolutionRoot as IDisposable;
if (root != null)
root.Dispose();
resolutionRoot = null;
}