public ConstructorDependencyModel(ParameterInfo parameter)
			: base(parameter.Name, parameter.ParameterType, false, parameter.HasDefaultValue(), parameter.DefaultValue)
		{
		}
Ejemplo n.º 2
0
 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");
     }
 }
Ejemplo n.º 3
0
        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());
            }
        }