/// <summary>
        /// Called during the chain of responsibility for a build operation. The
        /// PreBuildUp method is called when the chain is being executed in the
        /// forward direction.
        /// </summary>
        /// <param name="context">Context of the build operation.</param>
        // FxCop suppression: Validation is done by Guard class
        public override void PreBuildUp(IBuilderContext context)
        {
            Type type;

            BuildKey.TryGetType(context.BuildKey, out type);

            foreach (IMemberInfo <TMemberInfo> member in GetMembers(context))
            {
                if (MemberRequiresProcessing(member))
                {
                    IEnumerable <IParameter> parameters =
                        GenerateIParametersFromParameterInfos(member.GetParameters(), type, member.Name);

                    AddParametersToPolicy(context, member, parameters);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets an individual policy.
        /// </summary>
        /// <param name="policyInterface">The interface the policy is registered under.</param>
        /// <param name="buildKey">The key the policy applies.</param>
        /// <param name="localOnly">true if the policy searches local only; otherwise false to seach up the parent chain.</param>
        /// <returns>The policy in the list, if present; returns null otherwise.</returns>
        public IBuilderPolicy Get(Type policyInterface,
                                  object buildKey,
                                  bool localOnly)
        {
            Type buildType;

            if (!BuildKey.TryGetType(buildKey, out buildType) || !buildType.IsGenericType)
            {
                return
                    (GetNoDefault(policyInterface, buildKey, localOnly) ??
                     GetNoDefault(policyInterface, null, localOnly));
            }

            return
                (GetNoDefault(policyInterface, buildKey, localOnly) ??
                 GetNoDefault(policyInterface, BuildKey.ReplaceType(buildKey, buildType.GetGenericTypeDefinition()), localOnly) ??
                 GetNoDefault(policyInterface, null, localOnly));
        }