void ApplyOperation(string key, IParseOperation op)
 {
     if (op is ParseDeleteOperation)
     {
         estimatedData.Remove(key);
     }
     else
     {
         if (estimatedData.TryGetValue(key, out object oldValue))
         {
             estimatedData[key] = op.Apply(oldValue, key);
         }
         else
         {
             estimatedData[key] = op.Apply(null, key);
         }
     }
     if (operationDict.TryGetValue(key, out IParseOperation previousOp))
     {
         operationDict[key] = op.MergeWithPrevious(previousOp);
     }
     else
     {
         operationDict[key] = op;
     }
 }
 public IParseOperation MergeWithPrevious(IParseOperation previousOp) {
     if (previousOp is ParseSetOperation || previousOp is ParseDeleteOperation) {
         return previousOp;
     }
     if (previousOp is ParseRemoveRelationOperation removeRelationOp) {
         valueList.AddRange(removeRelationOp.valueList);
         return this;
     }
     throw new ArgumentException("Operation is invalid after previous operation.");
 }
 public IParseOperation MergeWithPrevious(IParseOperation previousOp)
 {
     if (previousOp is ParseSetOperation || previousOp is ParseDeleteOperation)
     {
         return(previousOp);
     }
     if (previousOp is ParseNumberOperation incrementOp)
     {
         object otherAmount = incrementOp.value;
         return(new ParseNumberOperation(Add(otherAmount, value)));
     }
     return(this);
 }
예제 #4
0
 public IParseOperation MergeWithPrevious(IParseOperation previousOp)
 {
     if (previousOp is ParseSetOperation || previousOp is ParseDeleteOperation)
     {
         return(previousOp);
     }
     if (previousOp is ParseAddUniqueOperation addUniqueOp)
     {
         values.UnionWith(addUniqueOp.values);
         return(this);
     }
     throw new ArgumentException("Operation is invalid after previous operation.");
 }
예제 #5
0
 public IParseOperation MergeWithPrevious(IParseOperation previousOp)
 {
     if (previousOp is ParseSetOperation || previousOp is ParseDeleteOperation)
     {
         return(previousOp);
     }
     if (previousOp is ParseRemoveOperation removeOp)
     {
         List <object> list = new List <object>(removeOp.valueList);
         list.AddRange(valueList);
         valueList = list;
         return(this);
     }
     throw new ArgumentException("Operation is invalid after previous operation.");
 }
예제 #6
0
 IParseOperation IParseOperation.MergeWithPrevious(IParseOperation previousOp)
 {
     if (previousOp is ParseSetOperation || previousOp is ParseDeleteOperation)
     {
         return(previousOp);
     }
     if (previousOp is ParseAddOperation addOp)
     {
         List <object> list = new List <object>(addOp.valueList);
         list.AddRange(valueList);
         valueList = list;
         return(this);
     }
     if (previousOp is ParseAddUniqueOperation addUniqueOp)
     {
         List <object> list = addUniqueOp.values.ToList();
         list.AddRange(valueList);
         valueList = list;
         return(this);
     }
     throw new ArgumentException("Operation is invalid after previous operation.");
 }
예제 #7
0
 static object EncodeOperation(IParseOperation operation)
 {
     return(operation.Encode());
 }
 public IParseOperation MergeWithPrevious(IParseOperation previousOp)
 {
     return(this);
 }