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); }
private void AssertSingleton() { if (!isSingleton || singletonInstance != null) { return; } singletonInstance = generator.GetCallResult(); generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => singletonInstance); }
IATMOptions IATMap.To(object instance) { generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => (T)instance); validated = true; return(this); }
IATMOptions IATMap.To(Func <object> func) { generator = GeneratorFuncFactory.CreateFromFuncGeneric <T>(() => (T)func()); validated = true; return(this); }