public ConstructorDependencyModel(ParameterInfo parameter) : base(parameter.Name, parameter.ParameterType, false, parameter.HasDefaultValue(), parameter.DefaultValue) { }
private static Expression CreateDefaultValueExpression(ParameterInfo parameter) { if (parameter.HasDefaultValue()) { return AstUtils.Constant(parameter.DefaultValue, parameter.ParameterType); } else { throw new NotSupportedException("missing parameter value not supported"); } }
public static void CopyParameterAttributes(ParameterInfo from, ParameterBuilder to) { if (from.IsDefined(typeof(ParamArrayAttribute), false)) { to.SetCustomAttribute(new CustomAttributeBuilder( typeof(ParamArrayAttribute).GetConstructor(ReflectionUtils.EmptyTypes), ArrayUtils.EmptyObjects) ); } else if (from.IsDefined(typeof(ParamDictionaryAttribute), false)) { to.SetCustomAttribute(new CustomAttributeBuilder( typeof(ParamDictionaryAttribute).GetConstructor(ReflectionUtils.EmptyTypes), ArrayUtils.EmptyObjects) ); } if (from.HasDefaultValue()) { to.SetConstant(from.GetDefaultValue()); } }