RVControlBase CreateControl(object ob, string fieldName, RVVisibility rvVisibility) { RVControlBase b = null; if (IsNull(ob) == true) { b = new RVText(fieldName, null, depth + 1, rvVisibility); } else { Type t = ob.GetType(); if (RVHelper.IsCanToStringDirently(t) == true) { b = new RVText(fieldName, ob, depth + 1, rvVisibility); } else { RVVisibility rvv = rvVisibility.GetCopy(); if (RVHelper.IsCollection(t) == false) { rvv.RVType = RVVisibility.NameType.Class; } // Debug.Log("--------------" + this.NameLabel); b = new RVCollection(this.parentNameLabel + this.NameLabel, GetSpecialNameLabel(ob, fieldName), ob, depth + 1, rvv); } } return(b); }
List <RVControlBase> AnalyzeClass(object data, Type thisType) { List <RVControlBase> result = new List <RVControlBase>(); while (thisType.IsSubclassOf(typeof(object))) { FieldInfo[] fields = thisType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (FieldInfo field in fields) { if (IsForbidThis(data, field.Name) == true) { continue; } object value = field.GetValue(data); RVVisibility rvv = new RVVisibility(); rvv.RVType = RVVisibility.NameType.Field; rvv.ValueType = field.FieldType; rvv.IsPrivate = field.IsPrivate; rvv.IsPublic = field.IsPublic; RVControlBase cb = CreateControl(value, field.Name, rvv); if (result.Contains(cb) == false) { result.Add(cb); } } PropertyInfo[] properties = thisType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (PropertyInfo property in properties) { object value = null; try { if (IsForbidThis(data, property.Name) == true) { continue; } value = property.GetValue(data, null); } catch { value = null; } RVVisibility rvv = new RVVisibility(); rvv.RVType = RVVisibility.NameType.Property; rvv.PropertyCanRead = property.CanRead; rvv.PropertyCanWrite = property.CanWrite; rvv.ValueType = property.PropertyType; RVControlBase cb = CreateControl(value, property.Name, rvv); if (result.Contains(cb) == false) { result.Add(cb); } } thisType = thisType.BaseType; } // //result.Sort((a, b) => //{ // return string.Compare(a.NameLabel, b.NameLabel, false, System.Globalization.CultureInfo.InvariantCulture); //}); return(result); }