Exemplo n.º 1
0
        internal static object ResolveValue <T>(IUEPropertyBaseConfig <T> property, T originalEntity)
        {
            var value = property.Expression.Compile().DynamicInvoke(originalEntity);

            if (property.Type == UEPropertyType.CheckBox)
            {
                bool?nullableBool = value as bool?;
                return(nullableBool.HasValue && nullableBool.Value ? "1" : "0");
            }

            if (property.Type == UEPropertyType.DropDown)
            {
                var optionValue = ResolveDropDownValue(property, originalEntity);
                if (string.IsNullOrWhiteSpace(optionValue))
                {
                    return(new string[0]);
                }

                return(optionValue);
            }

            //TODO: CHECK THIS
            string valueAsString = value as string;

            return(!string.IsNullOrWhiteSpace(valueAsString) && valueAsString.Equals("NULL") ? string.Empty : valueAsString);
        }
Exemplo n.º 2
0
        internal static string ResolveEditor <T>(IUEPropertyBaseConfig <T> property)
        {
            var item = _propertyTypeEditoViewCollection.SingleOrDefault(x => x.Type == property.Type);

            if (item == null)
            {
                throw new Exception("Cannot find editor type.");
            }

            return(item.Editor);
        }
Exemplo n.º 3
0
        internal static string ResolveDescription <T>(IUEPropertyBaseConfig <T> property, T originalEntity)
        {
            if (!string.IsNullOrWhiteSpace(property.Description))
            {
                return(property.Description);
            }

            if (property.DescriptionExpression != null)
            {
                return(property.DescriptionExpression.Compile().Invoke(originalEntity));
            }

            return(null);
        }
Exemplo n.º 4
0
        internal static Dictionary <string, object> ResolveConfig <T>(IUEPropertyBaseConfig <T> property)
        {
            if (property.Type == UEPropertyType.DropDown)
            {
                return(new Dictionary <string, object>
                {
                    { "items", property.DropdownOptions.Select(x => x.Value).ToArray() },
                    { "multiple", false }
                });
            }

            if (property.Type == UEPropertyType.TextBox)
            {
                return(new Dictionary <string, object>
                {
                    { "maxChars", property.MaxChars.HasValue ? property.MaxChars.Value : 500 }
                });
            }

            if (property.Type == UEPropertyType.TextArea)
            {
                if (property.MaxChars.HasValue)
                {
                    return(new Dictionary <string, object>
                    {
                        { "maxChars", property.MaxChars.Value },
                        { "rows", null }
                    });
                }
                else
                {
                    return(new Dictionary <string, object>
                    {
                        { "maxChars", false },
                        { "rows", null }
                    });
                }
            }

            if (property.Type == UEPropertyType.CheckBox)
            {
                return(new Dictionary <string, object>
                {
                    { "default", null },
                    { "labelOn", null }
                });
            }

            return(new Dictionary <string, object>());
        }
Exemplo n.º 5
0
        internal static string ResolveDropDownValue <T>(IUEPropertyBaseConfig <T> property, T originalEntity)
        {
            if (property.Type == UEPropertyType.DropDown)
            {
                var value       = property.Expression.Compile().DynamicInvoke(originalEntity);
                var optionValue = property.DropdownOptions.SingleOrDefault(x => x.Key == value.ToString());

                if (string.IsNullOrWhiteSpace(optionValue.Value))
                {
                    return(null);
                }

                return(optionValue.Value);
            }

            return(null);
        }