private static void ExtractInfoFromCommand(BSonDoc command, ref string type, ref string action) { if (command.HasProperty("_action")) action = (command["_action"] ?? string.Empty).ToString(); if (command.HasProperty("_type")) type = (command["_type"] ?? string.Empty).ToString(); }
private static Type GetDocumentType(BSonDoc command) { string result = null; if (command.HasProperty("_type_")) result = command["_type_"].ToString(); else if (command.HasProperty("_value")) { var value = command["_value"] as BSonDoc; if (value != null && value.HasProperty("_type_")) result = value["_type_"].ToString(); } if (!string.IsNullOrEmpty(result)) return Type.GetType(result, false); return null; }
private static void UpdateSingleDocument(BSonDoc document, IObjectStore store) { var obj = store.GetById((byte[])document[DocumentMetadata.IdPropertyName]); BSonDoc val = GetValue(document); foreach (var p in GetRealProperties(val)) // remove properties starting with if (document.HasProperty(p)) obj[p] = val[p]; store.Set(obj); }
private static void InternalDelete(BSonDoc document, string collection, IStore store) { IObjectStore st = store.GetCollection(collection); if (document.HasProperty(Configuration.DensoIDKeyName)) { var ent = st.GetById((byte[])document[Configuration.DensoIDKeyName]); if (ent != null) st.Remove(ent); } }
public override void OnHandle(IStore store, string collection, BSonDoc command, BSonDoc document) { if (document == null || string.IsNullOrEmpty(collection)) return; IObjectStore st = store.GetCollection(collection); if (document.HasProperty(DocumentMetadata.IdPropertyName)) { UpdateSingleDocument(document, st); return; } if (document.HasProperty(CommandKeyword.Filter)) { UpdateCollection(document, st); return; } st.Set(document); }
public override void OnHandle(IStore store, string collection, BSonDoc command, BSonDoc document) { IObjectStore st = store.GetCollection(collection); if (command.HasProperty(CommandKeyword.Id)) { var ent = st.GetById((byte[])command[CommandKeyword.Id]); if (ent != null) st.Remove(ent); } if (document != null && document.HasProperty(DocumentMetadata.IdPropertyName)) { var ent = st.GetById((byte[])document[DocumentMetadata.IdPropertyName]); if (ent != null) st.Remove(ent); } }
private static void InternalExecute(IStore store, BSonDoc command, InternalMethod method) { if (command.HasProperty("_value")) { var value = command["_value"] as BSonDoc; var collection = (command["_collection"] ?? string.Empty).ToString(); method(value, collection, store); } }
private static BSonDoc GetValue(BSonDoc document) { if (document.HasProperty("_value")) return document["_value"] as BSonDoc; return document; }
private static void UpdateSingleDocument(BSonDoc document, IObjectStore store) { var obj = store.GetById((byte[])document[Configuration.DensoIDKeyName]); BSonDoc val = GetValue(document); foreach (var p in val.GetRealProperties()) // remove properties starting with if (document.HasProperty(p)) obj[p] = val[p]; store.Set(obj); }
private static void InternalUpdate(BSonDoc document, string collection, IStore store) { IObjectStore st = store.GetCollection(collection); if (document.HasProperty(Configuration.DensoIDKeyName)) { UpdateSingleDocument(document, st); return; } if (document.HasProperty("_filter")) { UpdateCollection(document, st); return; } InsertElement(document, st); return; }
private byte[] GetEntityUI(BSonDoc entity) { if (entity.HasProperty(DocumentMetadata.IdPropertyName) && entity[DocumentMetadata.IdPropertyName] != null) return (byte[])entity[DocumentMetadata.IdPropertyName]; entity[DocumentMetadata.IdPropertyName] = newIdFunction(); return (byte[])entity[DocumentMetadata.IdPropertyName]; }
private static ICommandHandler[] ChechHandlers(BSonDoc command) { string actionname = string.Empty; if (command.HasProperty(CommandKeyword.Action)) actionname = (command[CommandKeyword.Action] ?? string.Empty).ToString(); if (_commandHandlers.ContainsKey(actionname)) return _commandHandlers[actionname].ToArray(); return null; }
private byte[] GetEntityUI(BSonDoc entity) { if (entity.HasProperty(Configuration.DensoIDKeyName) && entity[Configuration.DensoIDKeyName] != null) return (byte[])entity[Configuration.DensoIDKeyName]; entity[Configuration.DensoIDKeyName] = newIdFunction(); return (byte[])entity[Configuration.DensoIDKeyName]; }
protected static BSonDoc GetValue(BSonDoc document) { if (document.HasProperty(CommandKeyword.Value)) return document[CommandKeyword.Value] as BSonDoc; return document; }