本文整理汇总了C#中IResolutionRoot.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IResolutionRoot.Get方法的具体用法?C# IResolutionRoot.Get怎么用?C# IResolutionRoot.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResolutionRoot
的用法示例。
在下文中一共展示了IResolutionRoot.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: NinjectServiceScope
public NinjectServiceScope(
IResolutionRoot resolver,
IEnumerable<IParameter> inheritedParameters)
{
_scope = new ScopeParameter();
inheritedParameters = inheritedParameters.AddOrReplaceScopeParameter(_scope);
_serviceProvider = new NinjectServiceProvider(resolver, inheritedParameters.ToArray());
var httpContext = resolver.Get<IHttpContextAccessor>().HttpContext;
if (httpContext != null)
{
httpContext.Items.Add(typeof(ScopeParameter).FullName, _scope);
}
}
示例3: GetLanguage
public static Func<string> GetLanguage(IResolutionRoot kernel)
{
return () => kernel.Get<IIdentityService>().Language
?? TwoLetterISOLanguageName.Russian;
}
示例4: ComplexClass
public ComplexClass(ServiceUser serviceUser, IResolutionRoot resRoot)
{
InjectedServiceUser = serviceUser;
ResolvedServiceUser = resRoot.Get<ServiceUser>();
}