コード例 #1
0
 public EntityPropertyAttribute(PropertyEditorType editorType)
 {
     EditorType = editorType;
     if (Min == 0 && Max == 0)
     {
         Max = 100;
     }
 }
コード例 #2
0
 protected Property(string id, PropertyEditorType editor, string header, bool isVisibleInProductEditor, bool isVisibleInMyLights, List <PropertyMetadataItem> metadata)
 {
     _id     = id;
     _editor = editor;
     _header = header;
     _isVisibleInProductEditor = isVisibleInProductEditor;
     _isVisibleInMyLights      = isVisibleInMyLights;
     _metadata = metadata;
 }
コード例 #3
0
        public PropertyForwarder(string id, PropertyEditorType editor, IEnumerable <IProperty> linkedProperties)
        {
            _id     = id;
            _editor = editor;

            if (linkedProperties != null)
            {
                var linkedPropertiesCount = linkedProperties.Count();
                _linkedProperties = new List <T>(linkedPropertiesCount);

                foreach (var prop in linkedProperties)
                {
                    AddLinkedProperty(prop);
                }

                if (_linkedProperties.Count > 0)
                {
                    _linkedProperties[0].ValueChanged += PropertyForwarder_ValueChanged;
                }
            }
        }
コード例 #4
0
        private string JsVarDecl(PropertyInfo prop, object obj)
        {
            string s  = @"this.{0} = {1};";
            string _c = @"this.Controls = new EbControlCollection(JSON.parse('{0}'));";

            if (prop.IsDefined(typeof(DefaultPropValue)))
            {
                string DefaultVal = prop.GetCustomAttribute <DefaultPropValue>().Value;
                // For Object Selector
                if (prop.GetType().GetTypeInfo().IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().PropertyEditorType == PropertyEditorType.ObjectSelector)
                {
                    Attribute          EditorAttr = prop.GetCustomAttribute <PropertyEditor>();
                    PropertyEditorType EditorType = (EditorAttr as PropertyEditor).PropertyEditorType;

                    if (EditorType is PropertyEditorType.ObjectSelector)
                    {
                        DefaultVal = DefaultVal.SingleQuoted();
                    }
                }
                //for Others
                else if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime))
                {
                    DefaultVal = DefaultVal.SingleQuoted();
                }

                return(string.Format(s, prop.Name, DefaultVal));
            }

            if (prop.PropertyType == typeof(string))
            {
                if (prop.Name.EndsWith("Color"))
                {
                    return(string.Format(s, prop.Name, "'#FFFFFF'"));
                }
                else
                {
                    return(string.Format(s, prop.Name, (prop.Name == "Name" || prop.Name == "EbSid") ? "id" : "''"));
                }
            }
            else if (prop.Name == "Controls")
            {
                return(string.Format(_c, JsonConvert.SerializeObject((obj as EbControlContainer).Controls, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                })));
            }
            else if (prop.PropertyType == (typeof(int)) || prop.PropertyType == (typeof(float)))
            {
                return(string.Format(s, prop.Name, ((prop.Name == "Id") ? "id" : "0")));
            }
            else if (prop.PropertyType == typeof(bool))
            {
                return(string.Format(s, prop.Name, "false"));
            }
            else if (prop.PropertyType.GetTypeInfo().IsEnum)
            {
                return(string.Format(s, prop.Name, "0"));
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(List <>))
            {
                Type[] args = prop.PropertyType.GetGenericArguments();
                if (args.Length > 1)
                {
                    Type itemType = args[0];
                    return(string.Format(s, prop.Name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, ExpressBase.Objects]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName)));
                }
                else
                {
                    return(string.Format(s, prop.Name, "[]"));
                }
            }
            else if (prop.PropertyType.IsClass)
            {
                object Obj = Activator.CreateInstance(prop.PropertyType);
                return(string.Format(s, prop.Name, EbSerializers.Json_Serialize(Obj)));
            }
            else
            {
                return(string.Format(s, prop.Name, "null"));
            }
        }
コード例 #5
0
        private string JsVarDecl(PropertyInfo prop, object obj)
        {
            string s     = @"this.{0} = {1};";
            string _c    = @"this.Controls = new EbControlCollection(JSON.parse('{0}'));";
            string _name = prop.Name;

            if (prop.IsDefined(typeof(JsonPropertyAttribute)))
            {
                _name = prop.GetCustomAttribute <JsonPropertyAttribute>().PropertyName;
            }
            if (prop.IsDefined(typeof(DefaultPropValue)) && (prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string) || prop.PropertyType.IsEnum))
            {
                string DefaultVal = prop.GetCustomAttribute <DefaultPropValue>().Value;
                // For Object Selector
                if (prop.GetType().GetTypeInfo().IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().PropertyEditorType == (int)PropertyEditorType.ObjectSelector)
                {
                    Attribute          EditorAttr = prop.GetCustomAttribute <PropertyEditor>();
                    PropertyEditorType EditorType = (PropertyEditorType)(EditorAttr as PropertyEditor).PropertyEditorType;

                    if (EditorType is PropertyEditorType.ObjectSelector)
                    {
                        DefaultVal = DefaultVal.SingleQuoted();
                    }
                }
                //for Others
                else if (prop.PropertyType == typeof(string) || prop.PropertyType == typeof(DateTime))
                {
                    DefaultVal = DefaultVal.SingleQuoted();
                }

                return(string.Format(s, _name, DefaultVal));
            }

            if (prop.PropertyType == typeof(string))
            {
                if (!string.IsNullOrEmpty((string)prop.GetValue(obj)))
                {
                    return(string.Format(s, _name, string.Format("'{0}'", prop.GetValue(obj))));
                }
                if (prop.Name.EndsWith("Color"))
                {
                    return(string.Format(s, _name, "'#FFFFFF'"));
                }
                else
                {
                    return(string.Format(s, _name, (prop.Name == "Name" || prop.Name == "EbSid") ? "id" : "''"));
                }
            }
            else if (prop.Name == "Controls")
            {
                return(string.Format(_c, JsonConvert.SerializeObject((obj as EbControlContainer).Controls, new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                })));
            }
            else if (prop.PropertyType == (typeof(int)) || prop.PropertyType == (typeof(float)))
            {
                return(string.Format(s, _name, ((prop.Name == "Id") ? "id" : "0")));
            }
            else if (prop.PropertyType == typeof(bool))
            {
                return(string.Format(s, _name, prop.GetValue(obj).ToString().ToLower()));
            }
            else if (prop.PropertyType.GetTypeInfo().IsEnum)
            {
                if (prop.IsDefined(typeof(PropertyEditor)) && prop.GetCustomAttribute <PropertyEditor>().BooleanOption)
                {
                    Type[] args     = prop.PropertyType.GetGenericArguments();
                    Type   itemType = args[0];
                    return(string.Format(s, _name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, @nameSpace]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName).Replace("@nameSpace", itemType.AssemblyQualifiedName.Split(",")[1])));
                }
                return(string.Format(s, _name, ((int)prop.GetValue(obj)).ToString()));
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition().Name == "IDictionary`2")
            {
                return(string.Format(s, _name, "{\"$type\": \"System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib\",\"$values\": {}}"));//need to recheck format
            }
            else if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(List <>))
            {
                Type[] args = prop.PropertyType.GetGenericArguments();
                if (args.Length > 0)
                {
                    Type itemType = args[0];
                    return(string.Format(s, _name, "{\"$type\":\"System.Collections.Generic.List`1[[@typeName, @nameSpace]], System.Private.CoreLib\",\"$values\":[]}".Replace("@typeName", itemType.FullName).Replace("@nameSpace", itemType.AssemblyQualifiedName.Split(",")[1])));
                }
                else
                {
                    return(string.Format(s, _name, "[]"));
                }
            }
            else if (prop.PropertyType.IsClass && !prop.PropertyType.IsPrimitive)
            {
                if (prop.PropertyType == typeof(EbFont))
                {
                    return(string.Format(s, _name, "null"));
                }
                else
                {
                    try
                    {
                        object Obj = Activator.CreateInstance(prop.PropertyType);
                        SetAllDefaultPropVals(prop, Obj);
                        return(string.Format(s, _name, EbSerializers.Json_Serialize(Obj)));
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.Message);
                        return("");
                    }
                }
            }
            else
            {
                return(string.Format(s, _name, "null"));
            }
        }
コード例 #6
0
 public PropertyEditor(PropertyEditorType type1, int limit) : this(type1)
 {
     this.Limit = limit;
 }
コード例 #7
0
 public PropertyEditor(PropertyEditorType type, string source, string Dprop, bool ShouldRefreshOnInit) : this(type, source)
 {
     this.DependantProp = Dprop;
     this.BooleanOption = ShouldRefreshOnInit;
 }
コード例 #8
0
 public PropertyEditor(PropertyEditorType type1, PropertyEditorType type2)
 {
     this.PropertyEditorType = (int)type1 + (int)type2;
 }
コード例 #9
0
 public PropertyEditor(PropertyEditorType type, string source, int limit) : this(type, source)
 {
     this.Limit = limit;
 }
コード例 #10
0
 public PropertyEditor(PropertyEditorType type, string source, string Dprop) : this(type, source)
 {
     this.DependantProp = Dprop;
 }
コード例 #11
0
 public PropertyEditor(PropertyEditorType type, string source, bool ShouldRefreshOnInit) : this(type)
 {
     this.PropertyEditorSource = source;
     this.BooleanOption        = ShouldRefreshOnInit;
 }
コード例 #12
0
 public PropertyEditor(PropertyEditorType type, bool boolOpt) : this(type)
 {
     this.BooleanOption = boolOpt;
 }
コード例 #13
0
 public PropertyEditor(PropertyEditorType type1, PropertyEditorType type2, PropertyEditorType type3)
 {
     this.PropertyEditorType = (int)type1 + (int)type2 + (int)type3;
 }
コード例 #14
0
ファイル: Attributes.cs プロジェクト: ahammedunni/EbTestCi
 public PropertyEditor(PropertyEditorType type)
 {
     this.PropertyEditorType = type;
 }
コード例 #15
0
 public PropertyEditor(PropertyEditorType type, string source, string Dprop, string Dprop2) : this(type, source, Dprop)
 {
     this.DependantProp2 = Dprop2;
 }
コード例 #16
0
ファイル: Attributes.cs プロジェクト: ahammedunni/EbTestCi
 public PropertyEditor(PropertyEditorType type, string source)
 {
     this.PropertyEditorType   = type;
     this.PropertyEditorSource = source;
 }
コード例 #17
0
 public PropertyEditor(PropertyEditorType type1)
 {
     this.PropertyEditorType = (int)type1;
 }