예제 #1
0
        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;
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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));
            }
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
        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;
            }
        }
예제 #8
0
        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;
            }
        }
예제 #9
0
        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;
            }
        }
예제 #10
0
        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;
            }
        }
예제 #11
0
        /// <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}'.");
            }
        }
예제 #12
0
        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;
            }
        }
예제 #13
0
        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;
            }
        }
예제 #14
0
        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;
            }
        }