示例#1
0
文件: ATMap.cs 项目: hoffmannj/ATM
        private bool ValidateConstructor(ConstructorInfo constructor, List <IATMap> chain)
        {
            var parameters = constructor.GetParameters();

            if (HasBadParameter(parameters))
            {
                return(false);
            }
            var parameterGenerators = ValidateParameters(parameters, chain);

            if (parameterGenerators == null)
            {
                return(false);
            }
            NewExpression innerExpr;

            if (parameterGenerators.Length == 0)
            {
                innerExpr = Expression.New(constructor);
            }
            else
            {
                innerExpr = Expression.New(constructor, parameterGenerators.Select(p => p.GetCallExpression()).ToArray());
            }
            generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(Expression.Lambda <Func <T> >(innerExpr));
            validated = true;
            return(true);
        }
示例#2
0
文件: ATMap.cs 项目: hoffmannj/ATM
 private void AssertSingleton()
 {
     if (!isSingleton || singletonInstance != null)
     {
         return;
     }
     singletonInstance = generator.GetCallResult();
     generator         = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => singletonInstance);
 }
示例#3
0
文件: ATMap.cs 项目: hoffmannj/ATM
 IATMOptions IATMap.To(object instance)
 {
     generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => (T)instance);
     validated = true;
     return(this);
 }
示例#4
0
文件: ATMap.cs 项目: hoffmannj/ATM
 IATMOptions IATMap.To(Func <object> func)
 {
     generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => (T)func());
     validated = true;
     return(this);
 }