private string PropertyValue(object propertyValue, Type propertyType)
        {
            var type = FWReflectionHelper.GetUnderlyingType(propertyType);

            if (propertyValue == null)
            {
                var defaultValue = FWReflectionHelper.GetDefault(propertyType);
                return(defaultValue == null ? "''" : defaultValue.ToString());
            }

            if (type == FWKnownTypes.String)
            {
                return($"'{propertyValue.ToString().Replace("'", "\\'")}'");
            }
            else if (type == FWKnownTypes.Bool)
            {
                return((bool)propertyValue ? "true" : "false");
            }
            else if (type == FWKnownTypes.Decimal)
            {
                return(((decimal)propertyValue).ToString(new CultureInfo("en")));
            }
            else if (type == FWKnownTypes.DateTime)
            {
                return($"moment.utc('{((DateTime)propertyValue).ToString("yyyy-MM-ddTHH:mm:ss")}')");
            }

            return(propertyValue.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new control.
 /// </summary>
 /// <param name="requestContext">The request helper.</param>
 /// <param name="model">The current model.</param>
 /// <param name="metadata">The model metadata.</param>
 public FWInputControlFactory(FWRequestContext requestContext, object model, ModelMetadata metadata)
 {
     _requestContext = requestContext;
     _modelType      = FWReflectionHelper.GetUnderlyingType(metadata.ModelType);
     _model          = model;
     _metadata       = metadata;
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new Display control.
        /// </summary>
        /// <param name="requestContext">The request helper.</param>
        /// <param name="model">The current model.</param>
        /// <param name="metadata">The model metadata.</param>
        public FWDisplayControl(FWRequestContext requestContext, object model, ModelMetadata metadata)
            : base(metadata)
        {
            Name = metadata.PropertyName;

            _requestContext = requestContext;
            _modelType      = FWReflectionHelper.GetUnderlyingType(metadata.ModelType);
            _model          = model;
            _metadata       = metadata;
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FWInputControl" />.
        /// </summary>
        /// <param name="requestContext">The request helper.</param>
        /// <param name="model">The current model.</param>
        /// <param name="metadata">The model metadata.</param>
        protected FWInputControl(FWRequestContext requestContext, object model, ModelMetadata metadata)
            : base(metadata)
        {
            RequestContext = requestContext;
            Name           = metadata.PropertyName;

            Model         = model;
            DisplayName   = metadata.DisplayName;
            ModelType     = FWReflectionHelper.GetUnderlyingType(metadata.ModelType);
            ContainerType = metadata.ContainerType;
            IsRequired    = metadata.IsRequired();
            IsReadOnly    = metadata.IsReadOnly;
        }