/// <summary> /// Simple conversion of the type to string /// </summary> /// <param name="type">The type to convert</param> /// <param name="clientReference">The reference to the client</param> /// <param name="reference">a reference to an instance of the type</param> /// <returns></returns> public static string ToString(this IModelType type, string clientReference, string reference) { if (type == null || type.IsKindOfString()) { return(reference); } PrimaryType primaryType = type as PrimaryType; string serializationSettings = string.Format(CultureInfo.InvariantCulture, "{0}.SerializationSettings", clientReference); if (primaryType != null) { if (primaryType.KnownPrimaryType == KnownPrimaryType.Date) { serializationSettings = "new Microsoft.Rest.Serialization.DateJsonConverter()"; } else if (primaryType.KnownPrimaryType == KnownPrimaryType.DateTimeRfc1123) { serializationSettings = "new Microsoft.Rest.Serialization.DateTimeRfc1123JsonConverter()"; } else if (primaryType.KnownPrimaryType == KnownPrimaryType.Base64Url) { serializationSettings = "new Microsoft.Rest.Serialization.Base64UrlJsonConverter()"; } else if (primaryType.KnownPrimaryType == KnownPrimaryType.UnixTime) { serializationSettings = "new Microsoft.Rest.Serialization.UnixTimeJsonConverter()"; } } return(string.Format(CultureInfo.InvariantCulture, "Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject({0}, {1}).Trim('\"')", reference, serializationSettings)); }