コード例 #1
0
 private void ProcessSingleton(BuildRuleElement buildRule, Type buildType)
 {
     if (buildRule.Mode == ModeElement.Singleton)
     {
         builder.Policies.Set <ISingletonPolicy>(new SingletonPolicy(true), buildType, null);
     }
 }
コード例 #2
0
        private void ProcessConstructor(BuildRuleElement buildRule, Type buildType)
        {
            if (buildRule.Constructor == null)
            {
                return;
            }

            ConstructorPolicy policy = new ConstructorPolicy();

            foreach (object param in buildRule.Constructor.Items)
            {
                policy.AddParameter(GetParameterFromConfigParam(param));
            }

            builder.Policies.Set <ICreationPolicy>(policy, buildType, null);
        }
コード例 #3
0
        private void ProcessProperties(BuildRuleElement buildRule, Type buildType)
        {
            if (buildRule.Property == null)
            {
                return;
            }

            PropertySetterPolicy policy = new PropertySetterPolicy();

            foreach (PropertyElement prop in buildRule.Property)
            {
                policy.Properties.Add(prop.Name,
                                      new PropertySetterInfo(prop.Name, GetParameterFromConfigParam(prop.Item)));
            }

            builder.Policies.Set <IPropertySetterPolicy>(policy, buildType, null);
        }
コード例 #4
0
        private void ProcessMethods(BuildRuleElement buildRule, Type buildType)
        {
            if (buildRule.Method == null)
            {
                return;
            }

            MethodPolicy policy = GetMethodPolicy(buildType, null);

            foreach (MethodElement method in buildRule.Method)
            {
                List <IParameter> parameters = new List <IParameter>();

                foreach (object param in method.Items)
                {
                    parameters.Add(GetParameterFromConfigParam(param));
                }

                policy.Methods.Add(method.Name, new MethodCallInfo(method.Name, parameters));
            }
        }