コード例 #1
0
ファイル: UpdateHandler.cs プロジェクト: ppossanzini/DensoDB
        private static void UpdateSingleDocument(BSonDoc document, IObjectStore store)
        {
            var obj = store.GetById((string)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);
        }
コード例 #2
0
ファイル: UpdateHandler.cs プロジェクト: ppossanzini/DensoDB
        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);
        }
コード例 #3
0
ファイル: DeleteHandler.cs プロジェクト: ppossanzini/DensoDB
        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((string)command[CommandKeyword.Id]);
            if (ent != null) st.Remove(ent);
              }

              if (document != null && document.HasProperty(DocumentMetadata.IdPropertyName))
              {
            var ent = st.GetById((string)document[DocumentMetadata.IdPropertyName]);
            if (ent != null) st.Remove(ent);
              }
        }
コード例 #4
0
ファイル: EventHandler.cs プロジェクト: ppossanzini/DensoDB
        private static ICommandHandler[] ChechHandlers(BSonDoc command)
        {
            string actionname = string.Empty;
              if (command.HasProperty(CommandKeyword.Action))
            actionname = (command[CommandKeyword.Action] ?? string.Empty).ToString();

              LogWriter.LogInformation(string.Format("Executing action {0}", string.Empty), LogEntryType.Information);

              if (_commandHandlers.ContainsKey(actionname))
            return _commandHandlers[actionname].ToArray();

              return null;
        }
コード例 #5
0
ファイル: ObjectStore.cs プロジェクト: ppossanzini/DensoDB
    private string GetEntityUI(BSonDoc entity)
    {
      if (entity.HasProperty(DocumentMetadata.IdPropertyName) && entity[DocumentMetadata.IdPropertyName] != null)
        return (string)entity[DocumentMetadata.IdPropertyName];

      entity[DocumentMetadata.IdPropertyName] = newIdFunction();
      return (string)entity[DocumentMetadata.IdPropertyName];
    }
コード例 #6
0
 protected static BSonDoc GetValue(BSonDoc document)
 {
     if (document.HasProperty(CommandKeyword.Value))
     return document[CommandKeyword.Value] as BSonDoc;
       return document;
 }