本文整理汇总了C#中IPolicyList.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IPolicyList.Get方法的具体用法?C# IPolicyList.Get怎么用?C# IPolicyList.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPolicyList
的用法示例。
在下文中一共展示了IPolicyList.Get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveResolvers
/// <summary>
/// Remove the resolvers for the given build key.
/// </summary>
/// <param name="policies">Policy list containing the build key.</param>
/// <param name="buildKey">Build key.</param>
public static void RemoveResolvers(IPolicyList policies, object buildKey)
{
IDependencyResolverTrackerPolicy tracker = policies.Get<IDependencyResolverTrackerPolicy>(buildKey);
if (tracker != null)
{
tracker.RemoveResolvers(policies);
}
}
示例2: GetMappedType
private Type GetMappedType(IPolicyList policies)
{
var mappingPolicy = policies.Get<IBuildKeyMappingPolicy>(buildKey);
if (mappingPolicy != null)
{
return mappingPolicy.Map(buildKey, null).Type;
}
return buildKey.Type;
}
示例3: GetTracker
// Helper methods for adding and removing the tracker policy.
/// <summary>
/// Get an instance that implements <see cref="IDependencyResolverTrackerPolicy"/>,
/// either the current one in the policy set or creating a new one if it doesn't
/// exist.
/// </summary>
/// <param name="policies">Policy list to look up from.</param>
/// <param name="buildKey">Build key to track.</param>
/// <returns>The resolver tracker.</returns>
public static IDependencyResolverTrackerPolicy GetTracker(IPolicyList policies, object buildKey)
{
IDependencyResolverTrackerPolicy tracker =
policies.Get<IDependencyResolverTrackerPolicy>(buildKey);
if (tracker == null)
{
tracker = new DependencyResolverTrackerPolicy();
policies.Set<IDependencyResolverTrackerPolicy>(tracker, buildKey);
}
return tracker;
}
示例4: AddPolicies
public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
{
var key = new NamedTypeBuildKey(implementationType, name);
var policy = policies.Get<InterceptorPolicy>(key);
if (policy == null)
{
policy = new InterceptorPolicy();
policies.Set(policy, key);
}
policy.AddInterceptor(this.interceptorContainer);
}
示例5: GetLifetimeManagerType
private Type GetLifetimeManagerType(IPolicyList policies)
{
var key = new NamedTypeBuildKey(MappedToType, Name);
var lifetime = policies.Get<ILifetimePolicy>(key);
if(lifetime != null)
{
return lifetime.GetType();
}
if(MappedToType.IsGenericType)
{
var genericKey = new NamedTypeBuildKey(MappedToType.GetGenericTypeDefinition(), Name);
var lifetimeFactory = policies.Get<ILifetimeFactoryPolicy>(genericKey);
if(lifetimeFactory != null)
{
return lifetimeFactory.LifetimeType;
}
}
return typeof (TransientLifetimeManager);
}
示例6: GetLifetimeManager
private LifetimeManager GetLifetimeManager(IPolicyList policies)
{
var key = new NamedTypeBuildKey(MappedToType, Name);
return (LifetimeManager)policies.Get<ILifetimePolicy>(key);
}
示例7: GetSelectorPolicy
private static SpecifiedPropertiesSelectorPolicy GetSelectorPolicy(IPolicyList policies, Type typeToInject, string name)
{
NamedTypeBuildKey key = new NamedTypeBuildKey(typeToInject, name);
IPropertySelectorPolicy selector =
policies.GetNoDefault<IPropertySelectorPolicy>(key, false);
if (selector == null)
{
FullAutowirePropertySelectorPolicy defaultSelector =
policies.Get<IPropertySelectorPolicy>(key, false) as FullAutowirePropertySelectorPolicy;
if (defaultSelector != null)
{
selector = defaultSelector.Clone();
policies.Set(selector, key);
}
else
{
throw new InvalidOperationException("Cannot use AutiviewEnabledInjectionProperty without FullAutowireContainerExtension. Please register FullAutowireContainerExtension extension in the container.");
}
}
return ((FullAutowirePropertySelectorPolicy)selector).SpecifiedPropertiesPolicy;
}
示例8: ResolveValue
private object ResolveValue(IPolicyList policies, string key)
{
IDependencyResolverPolicy resolver = policies.Get<IDependencyResolverPolicy>(key);
return resolver.Resolve(null);
}