Ejemplo n.º 1
0
        public static string GetArgumentType(this BaseParameter param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }

            return("typeof(" + param.GetParameterTypeString() + ")");
        }
Ejemplo n.º 2
0
        public static string GetParameterDefinition(this BaseParameter param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }

            return(String.Format("{0} {1}", param.GetParameterTypeString(), param.Name));
        }
Ejemplo n.º 3
0
        public static void ToString(BaseParameter obj, MethodReturnEventArgs<string> e)
        {
            e.Result = string.Format("{0}{1} {2}",
                obj.IsReturnParameter
                    ? "[Return] "
                    : String.Empty,
                obj.GetParameterTypeString(),
                obj.Name);

            ToStringHelper.FixupFloatingObjectsToString(obj, e);
        }
Ejemplo n.º 4
0
        public static void ToString(BaseParameter obj, MethodReturnEventArgs <string> e)
        {
            e.Result = string.Format("{0}{1} {2}",
                                     obj.IsReturnParameter
                    ? "[Return] "
                    : String.Empty,
                                     obj.GetParameterTypeString(),
                                     obj.Name);

            ToStringHelper.FixupFloatingObjectsToString(obj, e);
        }
Ejemplo n.º 5
0
        // TODO: should use database backed decision tables
        public TModelFactory CreateViewModel <TModelFactory>(BaseParameter param) where TModelFactory : class
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            Type t;

            if (param is BoolParameter && !param.IsList)
            {
                t = typeof(NullableBoolPropertyViewModel);
            }
            else if (param is DateTimeParameter && !param.IsList)
            {
                t = typeof(NullableDateTimePropertyViewModel);
            }
            else if (param is DoubleParameter && !param.IsList)
            {
                t = typeof(NullableStructValueViewModel <double>);
            }
            else if (param is IntParameter && !param.IsList)
            {
                t = typeof(NullableStructValueViewModel <int>);
            }
            else if (param is DecimalParameter && !param.IsList)
            {
                t = typeof(NullableDecimalPropertyViewModel);
            }
            else if (param is StringParameter && !param.IsList)
            {
                t = typeof(ClassValueViewModel <string>);
            }
            else if (param is ObjectReferenceParameter && !param.IsList)
            {
                t = typeof(ObjectReferenceViewModel);
            }
            else if (param is EnumParameter && !param.IsList)
            {
                t = typeof(EnumerationValueViewModel);
            }
            else if (param is CompoundObjectParameter && !param.IsList)
            {
                var compObj = ((CompoundObjectParameter)param).CompoundObject;
                if (compObj.DefaultPropertyViewModelDescriptor != null)
                {
                    t = compObj.DefaultPropertyViewModelDescriptor.ViewModelRef.AsType(true);
                }
                else
                {
                    t = typeof(CompoundObjectPropertyViewModel);
                }
            }
            else
            {
                throw new NotImplementedException(String.Format("==>> No model for parameter '{0}' with type '{1}'", param, param.GetParameterTypeString()));
            }

            return(CreateViewModel <TModelFactory>(ResolveFactory(t)));
        }
Ejemplo n.º 6
0
        public static IValueModel GetValueModel(this BaseParameter parameter, bool allowNullInput)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            var lb = parameter.GetLabel();

            if (parameter is BoolParameter && !parameter.IsList)
            {
                return(new BoolValueModel(lb, parameter.Description, allowNullInput, false));
            }
            else if (parameter is DateTimeParameter && !parameter.IsList)
            {
                var dtp = (DateTimeParameter)parameter;
                return(new DateTimeValueModel(lb, parameter.Description, allowNullInput, false, dtp.DateTimeStyle ?? DateTimeStyles.DateTime));
            }
            else if (parameter is DoubleParameter && !parameter.IsList)
            {
                return(new NullableStructValueModel <double>(lb, parameter.Description, allowNullInput, false));
            }
            else if (parameter is IntParameter && !parameter.IsList)
            {
                return(new NullableStructValueModel <int>(lb, parameter.Description, allowNullInput, false));
            }
            else if (parameter is DecimalParameter && !parameter.IsList)
            {
                return(new DecimalValueModel(lb, parameter.Description, allowNullInput, false));
            }
            else if (parameter is StringParameter && !parameter.IsList)
            {
                return(new ClassValueModel <string>(lb, parameter.Description, allowNullInput, false));
            }
            else if (parameter is ObjectReferenceParameter && !parameter.IsList)
            {
                return(new ObjectReferenceValueModel(lb, parameter.Description, allowNullInput, false, ((ObjectReferenceParameter)parameter).ObjectClass));
            }
            else if (parameter is EnumParameter && !parameter.IsList)
            {
                return(new EnumerationValueModel(lb, parameter.Description, allowNullInput, false, ((EnumParameter)parameter).Enumeration));
            }
            else if (parameter is CompoundObjectParameter && !parameter.IsList)
            {
                return(new CompoundObjectValueModel(lb, parameter.Description, allowNullInput, false, ((CompoundObjectParameter)parameter).CompoundObject));
            }
            else
            {
                Logging.Log.WarnFormat("No model for parameter '{0}' of type '{1}'", parameter, parameter.GetParameterTypeString());
                return(null);
            }
        }