public ListObjectModel(ObjectModel parent, string name, Type type, object value, ModelOptions options, ObjectTag tag) : base(parent, name, type, value, options, tag) { ItemType = GetItempType(type); TemplateObject = For(this, "[-1]", ItemType, ItemType.GetDefaultValue(), ObjectTag.Template); Values = new List <ObjectModel>(); var collection = (IEnumerable)Value; if (collection != null) { var index = 0; foreach (var collectionValue in collection) { Values.Add(For(this, string.Format("[{0}]", index), collectionValue.GetType(), collectionValue)); index++; } } }
public DictionaryObjectModel(ObjectModel parent, string name, Type type, object value, ModelOptions options, ObjectTag tag) : base(parent, name, type, value, options, tag) { ItemType = GetItempType(type); TemplateObject = For(this, "[-1]", ItemType, ItemType.GetDefaultValue(), ObjectTag.Template); Values = new List <ObjectModel>(); var dictionary = (IDictionary)Value; if (dictionary != null) { var index = 0; foreach (var pair in dictionary) { Values.Add(For(this, string.Format("[{0}]", index), ItemType, Map(pair, ItemType))); index++; } } }