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


C# IPolicyList类代码示例

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


IPolicyList类属于命名空间,在下文中一共展示了IPolicyList类的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: ContainerRegistration

 internal ContainerRegistration(Type registeredType, string name, IPolicyList policies)
 {
     this.buildKey = new NamedTypeBuildKey(registeredType, name);
     MappedToType = GetMappedType(policies);
     LifetimeManagerType = GetLifetimeManagerType(policies);
     LifetimeManager = GetLifetimeManager(policies);
 }
开发者ID:CFMITL,项目名称:unity,代码行数:7,代码来源:ContainerRegistration.cs

示例3: SelectMethods

 /// <summary>
 ///   Return the sequence of methods to call while building the target 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 methods to call.</returns>
 public IEnumerable<SelectedMethod> SelectMethods(IBuilderContext context, IPolicyList resolverPolicyDestination)
 {
     foreach (Pair<MethodInfo, IEnumerable<InjectionParameterValue>> method in methods)
     {
         Type typeToBuild = context.BuildKey.Type;
         SelectedMethod selectedMethod;
         var typeReflector = new ReflectionHelper(method.First.DeclaringType);
         var methodReflector = new MethodReflectionHelper(method.First);
         if (!methodReflector.MethodHasOpenGenericParameters && !typeReflector.IsOpenGeneric)
         {
             selectedMethod = new SelectedMethod(method.First);
         }
         else
         {
             Type[] closedMethodParameterTypes =
                 methodReflector.GetClosedParameterTypes(typeToBuild.GetGenericArguments());
             selectedMethod = new SelectedMethod(
                 typeToBuild.GetMethod(method.First.Name, closedMethodParameterTypes));
         }
         SpecifiedMemberSelectorHelper.AddParameterResolvers(
             typeToBuild,
             resolverPolicyDestination,
             method.Second,
             selectedMethod);
         yield return selectedMethod;
     }
 }
开发者ID:Raconeisteron,项目名称:bakopanos,代码行数:34,代码来源:SpecifiedMethodsSelectorPolicy.cs

示例4: SelectProperties

        public IEnumerable<SelectedProperty> SelectProperties(IBuilderContext context, IPolicyList resolverPolicyDestination)
        {
            var t = context.BuildKey.Type;
             var propertyNames = new HashSet<string>();
             foreach (SelectedProperty prop in specifiedPropertiesPolicy.SelectProperties(context,resolverPolicyDestination))
             {
            if (!propertyNames.Contains(prop.Property.Name))
            {
               propertyNames.Add(prop.Property.Name);
               yield return prop;
            }
             }
             foreach (SelectedProperty prop in defaultProlicy.SelectProperties(context,resolverPolicyDestination))
             {
            if (!propertyNames.Contains(prop.Property.Name))
            {
               yield return prop;
            }
             }

             foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.Instance))
             {
            if (prop.GetIndexParameters().Length == 0 &&
               prop.CanWrite && !ShoudBeIgnored(prop) &&
               !propertyNames.Contains(prop.Name) &&
               !prop.PropertyType.IsValueType &&
               CanBeResolved(prop))
            {
               yield return CreateSelectedProperty(context, prop);
            }
             }
        }
开发者ID:kostaswonga,项目名称:NServiceBus,代码行数:32,代码来源:FullAutowirePropertySelectorPolicy.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">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

示例6: RemoveResolvers

 /// <summary>
 /// Remove the currently tracked resolvers from the given policy list.
 /// </summary>
 /// <param name="policies">Policy list to remove the resolvers from.</param>
 public void RemoveResolvers(IPolicyList policies)
 {
     foreach(object key in keys)
     {
         policies.Clear<IDependencyResolverPolicy>(key);
     }
     keys.Clear();
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:12,代码来源:DependencyResolverTrackerPolicy.cs

示例7: 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

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

示例9: 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

示例10: 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 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)
        {
            MethodInfo methodInfo = this.FindMethod(implementationType);
            this.ValidateMethodCanBeInjected(methodInfo, implementationType);

            SpecifiedMethodsSelectorPolicy selector =
                GetSelectorPolicy(policies, implementationType, name);
            selector.AddMethodAndParameters(methodInfo, this.methodParameters);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:17,代码来源:InjectionMethod.cs

示例11: GetMappedType

 private Type GetMappedType(IPolicyList policies)
 {
     var mappingPolicy = policies.Get<IBuildKeyMappingPolicy>(buildKey);
     if (mappingPolicy != null)
     {
         return mappingPolicy.Map(buildKey, null).Type;
     }
     return buildKey.Type;
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:9,代码来源:ContainerRegistration.cs

示例12: BuilderContext

 /// <summary>
 /// Create a new <see cref="BuilderContext"/> using the explicitly provided
 /// values.
 /// </summary>
 /// <param name="chain">The <see cref="IStrategyChain"/> to use for this context.</param>
 /// <param name="lifetime">The <see cref="ILifetimeContainer"/> to use for this context.</param>
 /// <param name="persistentPolicies">The set of persistent policies to use for this context.</param>
 /// <param name="transientPolicies">The set of transient policies to use for this context. It is
 /// the caller's responsibility to ensure that the transient and persistent policies are properly
 /// combined.</param>
 /// <param name="buildKey">Build key for this context.</param>
 /// <param name="existing">Existing object to build up.</param>
 public BuilderContext(IStrategyChain chain, ILifetimeContainer lifetime, IPolicyList persistentPolicies, IPolicyList transientPolicies, NamedTypeBuildKey buildKey, object existing)
 {
     this.chain = chain;
     this.lifetime = lifetime;
     this.persistentPolicies = persistentPolicies;
     this.policies = transientPolicies;
     this.originalBuildKey = buildKey;
     this.BuildKey = buildKey;
     this.Existing = existing;
 }
开发者ID:theoju,项目名称:CleanCode,代码行数:22,代码来源:BuilderContext.cs

示例13: GetSelectorPolicy

 private static SpecifiedMethodsSelectorPolicy GetSelectorPolicy(IPolicyList policies, Type typeToCreate, string name)
 {
     var key = new NamedTypeBuildKey(typeToCreate, name);
     var selector = policies.GetNoDefault<IMethodSelectorPolicy>(key, false);
     if (selector == null || !(selector is SpecifiedMethodsSelectorPolicy))
     {
         selector = new SpecifiedMethodsSelectorPolicy();
         policies.Set<IMethodSelectorPolicy>(selector, key);
     }
     return (SpecifiedMethodsSelectorPolicy)selector;
 }
开发者ID:CFMITL,项目名称:unity,代码行数:11,代码来源:InjectionMethod.cs

示例14: BuilderContext

 /// <summary>
 /// Create a new <see cref="BuilderContext"/> using the explicitly provided
 /// values.
 /// </summary>
 /// <param name="chain">The <see cref="IStrategyChain"/> to use for this context.</param>
 /// <param name="locator">The <see cref="IReadWriteLocator"/> to use for this context.</param>
 /// <param name="lifetime">The <see cref="ILifetimeContainer"/> to use for this context.</param>
 /// <param name="persistentPolicies">The set of persistent policies to use for this context.</param>
 /// <param name="transientPolicies">The set of transient policies to use for this context. It is
 /// the caller's responsibility to ensure that the transient and persistent policies are properly
 /// combined.</param>
 /// <param name="buildKey">Build key for this context.</param>
 /// <param name="existing">Existing object to build up.</param>
 public BuilderContext(IStrategyChain chain, IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList persistentPolicies, IPolicyList transientPolicies, object buildKey, object existing)
 {
     this.chain = chain;
     this.lifetime = lifetime;
     this.locator = locator;
     this.persistentPolicies = persistentPolicies;
     this.policies = transientPolicies;
     this.originalBuildKey = buildKey;
     this.buildKey = buildKey;
     this.existing = existing;
 }
开发者ID:shhyder,项目名称:application,代码行数:24,代码来源:BuilderContext.cs

示例15: 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


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