/// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, PropertyBatchOperation obj)
        {
            var kind = obj.Kind;

            if (kind.Equals(PropertyBatchOperationKind.CheckExists))
            {
                CheckExistsPropertyBatchOperationConverter.Serialize(writer, (CheckExistsPropertyBatchOperation)obj);
            }
            else if (kind.Equals(PropertyBatchOperationKind.CheckSequence))
            {
                CheckSequencePropertyBatchOperationConverter.Serialize(writer, (CheckSequencePropertyBatchOperation)obj);
            }
            else if (kind.Equals(PropertyBatchOperationKind.CheckValue))
            {
                CheckValuePropertyBatchOperationConverter.Serialize(writer, (CheckValuePropertyBatchOperation)obj);
            }
            else if (kind.Equals(PropertyBatchOperationKind.Delete))
            {
                DeletePropertyBatchOperationConverter.Serialize(writer, (DeletePropertyBatchOperation)obj);
            }
            else if (kind.Equals(PropertyBatchOperationKind.Get))
            {
                GetPropertyBatchOperationConverter.Serialize(writer, (GetPropertyBatchOperation)obj);
            }
            else if (kind.Equals(PropertyBatchOperationKind.Put))
            {
                PutPropertyBatchOperationConverter.Serialize(writer, (PutPropertyBatchOperation)obj);
            }
            else
            {
                throw new InvalidOperationException("Unknown Kind.");
            }
        }
Ejemplo n.º 2
0
        public static string GetStringDescription(PropertyBatchOperation operation)
        {
            switch (operation.Kind)
            {
            case PropertyBatchOperationKind.CheckExists:
                return(GetStringDescription((CheckExistsPropertyOperation)operation));

            case PropertyBatchOperationKind.CheckSequence:
                return(GetStringDescription((CheckSequencePropertyOperation)operation));

            case PropertyBatchOperationKind.CheckValue:
                return(GetStringDescription((CheckValuePropertyOperation)operation));

            case PropertyBatchOperationKind.Delete:
                return(GetStringDescription((DeletePropertyOperation)operation));

            case PropertyBatchOperationKind.Get:
                return(GetStringDescription((GetPropertyOperation)operation));

            case PropertyBatchOperationKind.Put:
                return(GetStringDescription((PutPropertyOperation)operation));

            case PropertyBatchOperationKind.PutCustom:
                return(GetStringDescription((PutCustomPropertyOperation)operation));

            default:
                return(string.Format(
                           CultureInfo.InvariantCulture,
                           "Property={0}; OpType={1}",
                           operation.PropertyName,
                           operation.Kind));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the object from Json properties.
        /// </summary>
        /// <param name="reader">The <see cref="T: Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <returns>The object Value.</returns>
        internal static PropertyBatchOperation GetFromJsonProperties(JsonReader reader)
        {
            PropertyBatchOperation obj = null;
            var propName = reader.ReadPropertyName();

            if (!propName.Equals("Kind", StringComparison.Ordinal))
            {
                throw new JsonReaderException($"Incorrect discriminator property name {propName}, Expected discriminator property name is Kind.");
            }

            var propValue = reader.ReadValueAsString();

            if (propValue.Equals("CheckExists", StringComparison.Ordinal))
            {
                obj = CheckExistsPropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("CheckSequence", StringComparison.Ordinal))
            {
                obj = CheckSequencePropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("CheckValue", StringComparison.Ordinal))
            {
                obj = CheckValuePropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("Delete", StringComparison.Ordinal))
            {
                obj = DeletePropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("Get", StringComparison.Ordinal))
            {
                obj = GetPropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else if (propValue.Equals("Put", StringComparison.Ordinal))
            {
                obj = PutPropertyBatchOperationConverter.GetFromJsonProperties(reader);
            }
            else
            {
                throw new InvalidOperationException("Unknown Kind.");
            }

            return(obj);
        }