当前位置: 首页>>代码示例>>C#>>正文


C# IPolicyList.Set方法代码示例

本文整理汇总了C#中IPolicyList.Set方法的典型用法代码示例。如果您正苦于以下问题:C# IPolicyList.Set方法的具体用法?C# IPolicyList.Set怎么用?C# IPolicyList.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPolicyList的用法示例。


在下文中一共展示了IPolicyList.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPolicies

 /// <summary>
 /// Add policies to the <paramref name="policies"/> to configure the
 /// container to call this constructor with the appropriate parameter values.
 /// </summary>
 /// <param name="typeToCreate">Type to register.</param>
 /// <param name="name">Name used to resolve the type object.</param>
 /// <param name="policies">Policy list to add policies to.</param>
 public override void AddPolicies(Type typeToCreate, string name, IPolicyList policies)
 {
     ConstructorInfo ctor = FindConstructor(typeToCreate);
     policies.Set<IConstructorSelectorPolicy>(
         new SpecifiedConstructorSelectorPolicy(ctor, parameterValues.ToArray()),
         new NamedTypeBuildKey(typeToCreate, name));
 }
开发者ID:shhyder,项目名称:application,代码行数:14,代码来源:InjectionConstructor.cs

示例2: AddPolicies

 /// <summary>
 /// Add policies to the <paramref name="policies"/> to configure the
 /// container to call this constructor with the appropriate parameter values.
 /// </summary>
 /// <param name="serviceType">Interface registered, ignored in this implementation.</param>
 /// <param name="implementationType">Type to register.</param>
 /// <param name="name">Name used to resolve the type object.</param>
 /// <param name="policies">Policy list to add policies to.</param>
 public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
 {
     ConstructorInfo ctor = this.FindConstructor(implementationType);
     policies.Set<IConstructorSelectorPolicy>(
         new SpecifiedConstructorSelectorPolicy(ctor, this.parameterValues.ToArray()),
         new NamedTypeBuildKey(implementationType, name));
 }
开发者ID:kangkot,项目名称:unity,代码行数:15,代码来源:InjectionConstructor.cs

示例3: AddPolicies

 /// <summary>
 /// Add policies to the <paramref name="policies"/> to configure the container to use the represented 
 /// <see cref="IInterceptor"/> for the supplied parameters.
 /// </summary>
 /// <param name="serviceType">Interface being registered.</param>
 /// <param name="implementationType">Type to register.</param>
 /// <param name="name">Name used to resolve the type object.</param>
 /// <param name="policies">Policy list to add policies to.</param>
 public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
 {
     var key = new NamedTypeBuildKey(implementationType, name);
     if(IsInstanceInterceptor)
     {
         var policy = CreateInstanceInterceptionPolicy();
         policies.Set<IInstanceInterceptionPolicy>(policy, key);
         policies.Clear<ITypeInterceptionPolicy>(key);
     }
     else
     {
         var policy = CreateTypeInterceptionPolicy();
         policies.Set<ITypeInterceptionPolicy>(policy, key);
         policies.Clear<IInstanceInterceptionPolicy>(key);
     }
 }
开发者ID:shhyder,项目名称:MapApplication,代码行数:24,代码来源:Interceptor.cs

示例4: AddPolicies

        /// <summary>
        /// Add policies to the <paramref name="policies"/> to configure the container with 
        /// an appropriate <see cref="IInstanceInterceptionPolicy"/>
        /// </summary>
        /// <param name="serviceType">Type of the interface being registered. This parameter is
        /// ignored by this class.</param>
        /// <param name="implementationType">Type to register.</param>
        /// <param name="name">Name used to resolve the type object.</param>
        /// <param name="policies">Policy list to add policies to.</param>
        public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
        {
            var key = new NamedTypeBuildKey(implementationType);
            policies.Set<IInstanceInterceptionPolicy>(new FixedInstanceInterceptionPolicy(Interceptor), key);

            var piabInjectionMember = new InterceptionBehavior<PolicyInjectionBehavior>();
            piabInjectionMember.AddPolicies(serviceType, implementationType, name, policies);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:17,代码来源:InstanceInterceptionPolicySettingInjectionMember.cs

示例5: AddPolicies

        /// <summary>
        /// Add policies to the <paramref name="policies"/> to configure the
        /// container to call this constructor with the appropriate parameter values.
        /// </summary>
        /// <param name="serviceType">Type of interface being registered. If no interface,
        /// this will be null. This parameter is ignored in this implementation.</param>
        /// <param name="implementationType">Type of concrete type being registered.</param>
        /// <param name="name">Name used to resolve the type object.</param>
        /// <param name="policies">Policy list to add policies to.</param>
        public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
        {
            Guard.ArgumentNotNull(implementationType, "implementationType");
            Guard.ArgumentNotNull(policies, "policies");

            var policy = new FactoryDelegateBuildPlanPolicy(this.factoryFunc);
            policies.Set<IBuildPlanPolicy>(policy,
                new NamedTypeBuildKey(implementationType, name));
        }
开发者ID:CFMITL,项目名称:unity,代码行数:18,代码来源:InjectionFactory.cs

示例6: GetBehaviorsPolicy

 /// <summary>
 /// Get the list of behaviors for the current type so that it can be added to.
 /// </summary>
 /// <param name="policies">Policy list.</param>
 /// <param name="implementationType">Implementation type to set behaviors for.</param>
 /// <param name="name">Name type is registered under.</param>
 /// <returns>An instance of <see cref="InterceptionBehaviorsPolicy"/>.</returns>
 protected override InterceptionBehaviorsPolicy GetBehaviorsPolicy(IPolicyList policies, Type implementationType,
     string name)
 {
     var policy = policies.GetNoDefault<IInterceptionBehaviorsPolicy>(implementationType, false);
     if ((policy == null) || !(policy is InterceptionBehaviorsPolicy))
     {
         policy = new InterceptionBehaviorsPolicy();
         policies.Set(policy, implementationType);
     }
     return (InterceptionBehaviorsPolicy) policy;
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:18,代码来源:DefaultInterceptionBehavior.cs

示例7: AddPolicies

 public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
 {
     if (serviceType == null)
         throw new ArgumentNullException(nameof(serviceType), "The service type cannot be null");
     if (implementationType == null)
         throw new ArgumentNullException(nameof(implementationType), "The implementation type cannot be null");
     policies.Set(
         typeof(ILazyProxyPolicy),
         new LazyProxyPolicy(serviceType, implementationType),
         new NamedTypeBuildKey(serviceType, name));
 }
开发者ID:thomaslevesque,项目名称:LazyProxy,代码行数:11,代码来源:InjectionLazyProxy.cs

示例8: 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;
 }
开发者ID:kangkot,项目名称:unity,代码行数:20,代码来源:DependencyResolverTrackerPolicy.cs

示例9: AddParameterResolvers

 /// <summary>
 /// Add dependency resolvers to the policy set.
 /// </summary>
 /// <param name="policies">PolicyList to add the resolvers to.</param>
 /// <param name="parameterValues">Objects supplying the dependency resolvers.</param>
 /// <param name="result">Result object to store the keys in.</param>
 public static void AddParameterResolvers(IPolicyList policies, 
     IEnumerable<InjectionParameterValue> parameterValues, 
     SelectedMemberWithParameters result)
 {
     foreach(InjectionParameterValue parameterValue in parameterValues)
     {
         string key = Guid.NewGuid().ToString();
         policies.Set<IDependencyResolverPolicy>(parameterValue.GetResolverPolicy(), key);
         result.AddParameterKey(key);
     }
 }
开发者ID:shhyder,项目名称:application,代码行数:17,代码来源:SpecifiedMemberSelectorHelper.cs

示例10: 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);
 }
开发者ID:BrunoJuchli,项目名称:Unity.StaticProxyExtension,代码行数:12,代码来源:Intercept.cs

示例11: GetOrCreate

 internal static InterceptionBehaviorsPolicy GetOrCreate(
     IPolicyList policies,
     Type typeToCreate,
     string name)
 {
     NamedTypeBuildKey key = new NamedTypeBuildKey(typeToCreate, name);
     IInterceptionBehaviorsPolicy policy =
         policies.GetNoDefault<IInterceptionBehaviorsPolicy>(key, false);
     if ((policy == null) || !(policy is InterceptionBehaviorsPolicy))
     {
         policy = new InterceptionBehaviorsPolicy();
         policies.Set<IInterceptionBehaviorsPolicy>(policy, key);
     }
     return (InterceptionBehaviorsPolicy)policy;
 }
开发者ID:kangkot,项目名称:unity,代码行数:15,代码来源:InterceptionBehaviorsPolicy.cs

示例12: GetOrCreate

 internal static AdditionalInterfacesPolicy GetOrCreate(
     IPolicyList policies,
     Type typeToCreate,
     string name)
 {
     NamedTypeBuildKey key = new NamedTypeBuildKey(typeToCreate, name);
     IAdditionalInterfacesPolicy policy =
         policies.GetNoDefault<IAdditionalInterfacesPolicy>(key, false);
     if ((policy == null) || !(policy is AdditionalInterfacesPolicy))
     {
         policy = new AdditionalInterfacesPolicy();
         policies.Set<IAdditionalInterfacesPolicy>(policy, key);
     }
     return (AdditionalInterfacesPolicy)policy;
 }
开发者ID:shhyder,项目名称:MapApplication,代码行数:15,代码来源:AdditionalInterfacesPolicy.cs

示例13: AddPolicies

        /// <summary>
        /// Add policies to the <paramref name="policies"/> to configure the
        ///             container to call this constructor with the appropriate parameter values.
        /// </summary>
        /// <param name="serviceType">Type of interface being registered. If no interface,
        ///             this will be null.</param><param name="implementationType">Type of concrete type being registered.</param><param name="name">Name used to resolve the type object.</param><param name="policies">Policy list to add policies to.</param>
        public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
        {
            if (implementationType == null) throw new ArgumentNullException("implementationType");

            if(!implementationType.IsGenericType ||
                implementationType.GetGenericTypeDefinition() != typeof(Validator<>))
            {
                throw new InvalidOperationException(Resources.IllegalUseOfInjectionValidationSource);
            }

            var key = new NamedTypeBuildKey(implementationType, name);
            var policy = new ValidationSpecificationSourcePolicy(Source);

            policies.Set<ValidationSpecificationSourcePolicy>(policy, key);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:21,代码来源:InjectionValidationSource.cs

示例14: AddParameterResolvers

        /// <summary>
        /// Add dependency resolvers to the parameter set.
        /// </summary>
        /// <param name="typeToBuild">Type that's currently being built (used to resolve open generics).</param>
        /// <param name="policies">PolicyList to add the resolvers to.</param>
        /// <param name="parameterValues">Objects supplying the dependency resolvers.</param>
        /// <param name="result">Result object to store the keys in.</param>
        public static void AddParameterResolvers(Type typeToBuild,
            IPolicyList policies,
            IEnumerable<InjectionParameterValue> parameterValues,
            SelectedMemberWithParameters result)
        {
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(policies, "policies");
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(parameterValues, "parameterValues");
            Microsoft.Practices.Unity.Utility.Guard.ArgumentNotNull(result, "result");

            foreach(InjectionParameterValue parameterValue in parameterValues)
            {
                string key = Guid.NewGuid().ToString();
                policies.Set<IDependencyResolverPolicy>(parameterValue.GetResolverPolicy(typeToBuild), key);
                result.AddParameterKey(key);
            }
        }
开发者ID:theoju,项目名称:CleanCode,代码行数:23,代码来源:SpecifiedMemberSelectorHelper.cs

示例15: SelectProperties

        /// <summary>
        /// Returns sequence of properties on the given type that
        /// should be set as part of building that object.
        /// </summary>
        /// <param name="context">Current build context.</param>
        /// <param name="resolverPolicyDestination">The <see cref='IPolicyList'/> to add any
        /// generated resolver objects into.</param>
        /// <returns>Sequence of <see cref="PropertyInfo"/> objects
        /// that contain the properties to set.</returns>
        public IEnumerable<SelectedProperty> SelectProperties(IBuilderContext context, IPolicyList resolverPolicyDestination)
        {
            Type typeToBuild = context.BuildKey.Type;
            var currentTypeReflector = new ReflectionHelper(context.BuildKey.Type);
            foreach(Pair<PropertyInfo, InjectionParameterValue> pair in propertiesAndValues)
            {
                PropertyInfo currentProperty = pair.First;

                // Is this the property info on the open generic? If so, get the one
                // for the current closed generic.
                if (new ReflectionHelper(pair.First.DeclaringType).IsOpenGeneric)
                {
                    currentProperty = currentTypeReflector.Type.GetProperty(currentProperty.Name);
                }
                
                string key = Guid.NewGuid().ToString();
                resolverPolicyDestination.Set<IDependencyResolverPolicy>(pair.Second.GetResolverPolicy(typeToBuild), key);
                yield return new SelectedProperty(currentProperty, key);
            }
        }
开发者ID:shhyder,项目名称:MapApplication,代码行数:29,代码来源:SpecifiedPropertiesSelectorPolicy.cs


注:本文中的IPolicyList.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。