/// <summary> /// Serializes the specified object. /// </summary> /// <typeparam name="Type">The type of the <paramref name="objectToSerialize"/>.</typeparam> /// <param name="objectToSerialize">The object to be serialized.</param> public static string Serialize <Type>(Type objectToSerialize) { DataContractJsonSerializer _Srlzr = new DataContractJsonSerializer(typeof(Type)); using (System.IO.MemoryStream _writer = new System.IO.MemoryStream()) { _Srlzr.WriteObject(_writer, objectToSerialize); return(_writer.ReadString()); } }
private string SerializeEvent <T>(T e) { var serializer = new DataContractSerializer(e.GetType()); using (var memStream = new System.IO.MemoryStream()) { serializer.WriteObject(memStream, e); memStream.Position = 0; return(memStream.ReadString()); } }