Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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);
       }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
              }
        }
Esempio n. 7
0
        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);
              }
        }
Esempio n. 8
0
 private static BSonDoc GetValue(BSonDoc document)
 {
     if (document.HasProperty("_value"))
     return document["_value"] as BSonDoc;
       return document;
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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;
        }
Esempio n. 11
0
        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];
        }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
        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];
        }
Esempio n. 14
0
 protected static BSonDoc GetValue(BSonDoc document)
 {
     if (document.HasProperty(CommandKeyword.Value))
     return document[CommandKeyword.Value] as BSonDoc;
       return document;
 }