public bool Apply(IJSONDocument document) { var attribute = _targetField as Attribute; if (attribute != null) { return(Attributor.TryDelete(document, attribute)); } return(false); }
public bool Apply(IJSONDocument document) { var attribute = _targetField as Attribute; if (attribute != null) { switch (Type) { case UpdateType.Single: return(Attributor.TryDelete(document, attribute)); case UpdateType.Array: Array array; if (Attributor.TryGetArray(document, out array, attribute)) { var values = new ClusteredArrayList(array.Length + _evaluator.Length); values.AddRange(array); bool isChangeApplicable = false; foreach (var evaluable in _evaluator) { IJsonValue newValue; if (evaluable.Evaluate(out newValue, document)) { while (values.Contains(newValue.Value)) { values.Remove(newValue.Value); isChangeApplicable = true; } } } return(isChangeApplicable && Attributor.TrySetArray(document, values.ToArray(), attribute)); } return(false); } return(false); } return(false); }