public ObjectDefInstance GetInstance() { var instance = new ObjectDefInstance() { Name = this.Name }; foreach (var p in this.Properties) { // instance.Properties.Add(p.Name, new ObjectDefInstanceProperty(instance) { Name = p.Name, Value = p.Value }); instance.Properties.Add(p.Name, p.Value); } return(instance); }
public static ObjectDefInstance Create(string name, object values, KV <string, object> key = null) { var instance = new ObjectDefInstance() { Name = name, Key = key }; Type type = values.GetType(); foreach (var prop in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)) { instance.Properties.Add(prop.Name, prop.GetValue(values)); } return(instance); }
public static ObjectDefInstance CreateInstance <T>(T t, KV <string, object> key = null) { Type type = typeof(T); string name = type.Name; string listName = name.Pluralize(); ObjectDefInstance instance = new ObjectDefInstance() { Name = type.Name, Key = key }; foreach (var p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (p.PropertyType.IsSimpleType()) { instance.Properties.Add(p.Name, p.GetValue(t)); } } return(instance); }