/// <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 DeployedServiceReplicaDetailInfo GetFromJsonProperties(JsonReader reader) { DeployedServiceReplicaDetailInfo obj; var propName = reader.ReadPropertyName(); if (!propName.Equals("ServiceKind", StringComparison.Ordinal)) { throw new JsonReaderException($"Incorrect discriminator property name {propName}, Expected discriminator property name is ServiceKind."); } var propValue = reader.ReadValueAsString(); if (propValue.Equals("Stateful", StringComparison.Ordinal)) { obj = DeployedStatefulServiceReplicaDetailInfoConverter.GetFromJsonProperties(reader); } else if (propValue.Equals("Stateless", StringComparison.Ordinal)) { obj = DeployedStatelessServiceInstanceDetailInfoConverter.GetFromJsonProperties(reader); } else { throw new InvalidOperationException("Unknown ServiceKind."); } return(obj); }
/// <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, DeployedServiceReplicaDetailInfo obj) { var kind = obj.ServiceKind; if (kind.Equals(ServiceKind.Stateful)) { DeployedStatefulServiceReplicaDetailInfoConverter.Serialize(writer, (DeployedStatefulServiceReplicaDetailInfo)obj); } else if (kind.Equals(ServiceKind.Stateless)) { DeployedStatelessServiceInstanceDetailInfoConverter.Serialize(writer, (DeployedStatelessServiceInstanceDetailInfo)obj); } else { throw new InvalidOperationException("Unknown ServiceKind."); } }