Exemple #1
0
        /// <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, ServiceDescription obj)
        {
            var kind = obj.ServiceKind;

            if (kind.Equals(ServiceKind.Stateful))
            {
                StatefulServiceDescriptionConverter.Serialize(writer, (StatefulServiceDescription)obj);
            }
            else if (kind.Equals(ServiceKind.Stateless))
            {
                StatelessServiceDescriptionConverter.Serialize(writer, (StatelessServiceDescription)obj);
            }
            else
            {
                throw new InvalidOperationException("Unknown ServiceKind.");
            }
        }