Modified on Wednesday, 21 August 2013 19:10 by Administrator — Categorized as: Uncategorized


ServiceStack with Razor Support: Create an empty ASP.NET Web or Console Application and (.NET 4.0+)

PM> Install-Package ServiceStack.Razor

Convert a JSON string to a class

public class ResponseVoiceBaseUploadFile
        public string requestStatus { get; set; }
        public string statusMessage { get; set; }
        public string fileStatus { get; set; }
        public VoiceBaseFileMetadataResponse response { get; set; }

        public ResponseVoiceBaseUploadFile()
            //response = new VoiceBaseFileMetadataResponse();

JsonServiceClient client = new JsonServiceClient("");
string json = @"{""requestStatus"":""SUCCESS"",""statusMessage"":""The request was processed successfully"",""mediaId"":""5213bade6efaf"",""fileUrl"":""http:\/\/\/autonotes\/private_detail\/324653\/hash=bJaZZmlolW1paGnGw5WWbp3Il54=""}";
MemoryStream ss = new MemoryStream(UTF8Encoding.Default.GetBytes(json));
ResponseVoiceBaseUploadFile result = client.DeserializeFromStream<ResponseVoiceBaseUploadFile>(ss);

Convert a class to a list of query string parameters

RequestVoiceBaseUploadFile a = new RequestVoiceBaseUploadFile() { };
string s = QueryStringSerializer.SerializeToString<object>(a);

Extension method to dump all properties of a class (any class)

The object is called note() and has been created

Use nugget to add reference to ServiceStack.Text

then add reference

using ServiceStack.Text;