private object ConvertInstance(IStored instance) { IDictionary <string, object> doc = new Dictionary <string, object>(); foreach (string name in instance.Names) { doc[name] = ConvertValue(instance.GetData(name)); } return(doc); }
void PopulateMember(Context context, IStored stored, IInstance instance, String name) { AttributeDeclaration decl = context.getRegisteredDeclaration <AttributeDeclaration>(name); if (!decl.Storable) { return; } if (stored.HasData(name)) { Object data = stored.GetData(name); IValue value = decl.getIType().ConvertCSharpValueToIValue(context, data); instance.SetMemberValue(context, name, value); } }
CategoryType ReadItemType(IStored stored) { Object value = stored.GetData("category"); if (value is List <String> ) { List <String> categories = (List <String>)value; String category = categories[categories.Count - 1]; CategoryType type = new CategoryType(category); type.Mutable = this.Mutable; return(type); } else { throw new InvalidDataError("Could not infer category!"); } }
public override IValue interpret(Context context) { IStore store = DataStore.Instance; IQuery query = buildFetchOneQuery(context, store); IStored stored = store.FetchOne(query); if (stored == null) { return(NullValue.Instance); } else { List <String> categories = (List <String>)stored.GetData("category"); String actualTypeName = categories.FindLast((v) => true); CategoryType type = new CategoryType(actualTypeName); if (this.type != null) { type.Mutable = this.type.Mutable; } return(type.newInstance(context, stored)); } }