internal void Apply(T objectToApplyTo, IObjectAdapter <T> adapter) { switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: throw new NotImplementedException("Test is currently not implemented."); default: break; } }
public void Apply(TModel objectToApplyTo, IObjectAdapter <TModel> adapter) { switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: throw new NotSupportedException(Resources.TestOperationNotSupported); default: break; } }
public void Apply(object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException("objectToApplyTo"); } if (adapter == null) { throw new ArgumentNullException("adapter"); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; } }
public void Apply(T objectToApplyTo, IObjectAdapter <T> adapter) { switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: adapter.Test(this, objectToApplyTo); break; default: break; } }
public IEnumerable <PatchOperationResult> Apply(TModel objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException("objectToApplyTo"); } if (adapter == null) { throw new ArgumentNullException("adapter"); } switch (OperationType) { case OperationType.Add: return(adapter.Add(this, objectToApplyTo)); case OperationType.Remove: return(adapter.Remove(this, objectToApplyTo)); case OperationType.Replace: return(adapter.Replace(this, objectToApplyTo)); default: throw new InvalidOperationException(string.Format("Patch OperationType type '{0}' is invalid.", OperationType)); } }
public void Apply(object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException("objectToApplyTo"); } if (adapter == null) { throw new ArgumentNullException("adapter"); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; } }
public void Apply(object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: throw new NotSupportedException(Resources.TestOperationNotSupported); default: break; } }
public void Apply(TModel objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: if (adapter is IObjectAdapterWithTest adapterWithTest) { adapterWithTest.Test(this, objectToApplyTo); break; } else { throw new JsonPatchException(new JsonPatchError(objectToApplyTo, this, Resources.TestOperationNotSupported)); } case OperationType.Invalid: throw new JsonPatchException( Resources.FormatInvalidJsonPatchOperation(op), innerException: null); default: break; } }
public void Apply(object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: if (adapter is IObjectAdapterWithTest adapterWithTest) { adapterWithTest.Test(this, objectToApplyTo); break; } else { throw new NotSupportedException(Resources.TestOperationNotSupported); } default: break; } }
public void Apply(TModel objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: throw new NotImplementedException("Test is currently not implemented."); case OperationType.Invalid: throw new JsonPatchException( Resources.FormatInvalidJsonPatchOperation(op), innerException: null); default: break; } }
/// <summary> /// Applies the operation to the target object using the specified adapter. /// </summary> /// <param name="objectToApplyTo">The target object.</param> /// <param name="adapter">The <see cref="IObjectAdapter" />.</param> public void Apply(TModel objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Move: adapter.Move(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Test when adapter is IObjectAdapterWithTest adapterWithTest: adapterWithTest.Test(this, objectToApplyTo, typeof(TModel)); break; case OperationType.Test: throw new JsonPatchException(new JsonPatchError(objectToApplyTo, this, "The test operation is not supported.")); case OperationType.Invalid: throw new JsonPatchException($"Invalid JsonPatch operation '{Op}'."); } }
public void Apply(object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: adapter.Test(this, objectToApplyTo); break; default: break; } }
public void Apply(TModel objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new ArgumentNullException(nameof(objectToApplyTo)); } if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } switch (OperationType) { case OperationType.Add: adapter.Add(this, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(this, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(this, objectToApplyTo); break; case OperationType.Move: adapter.Move(this, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(this, objectToApplyTo); break; case OperationType.Test: throw new JsonPatchException(new JsonPatchError(objectToApplyTo, this, Resources.TestOperationNotSupported)); default: break; } }
internal static void Apply(this Operation operation, object objectToApplyTo, IObjectAdapter adapter) { if (objectToApplyTo == null) { throw new NullReferenceException("objectToApplyTo cannot be null"); } if (adapter == null) { throw new NullReferenceException("adapter cannot be null"); } switch (operation.OperationType) { case OperationType.Add: adapter.Add(operation, objectToApplyTo); break; case OperationType.Remove: adapter.Remove(operation, objectToApplyTo); break; case OperationType.Replace: adapter.Replace(operation, objectToApplyTo); break; case OperationType.Move: adapter.Move(operation, objectToApplyTo); break; case OperationType.Copy: adapter.Copy(operation, objectToApplyTo); break; case OperationType.Test: throw new NotImplementedException("Test is currently not implemented."); default: break; } }