Welcome Guest, you are in: Login

wiki.crowe.co.nz

RSS RSS

Navigation





Search the wiki
»

PoweredBy

ServiceStack

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

ServiceStack

http://www.servicestack.net/

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("http://www.voicebase.com");
string json = @"{""requestStatus"":""SUCCESS"",""statusMessage"":""The request was processed successfully"",""mediaId"":""5213bade6efaf"",""fileUrl"":""http:\/\/www.voicebase.com\/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)

http://www.servicestack.net/mythz_blog/?p=202

The object is called note() and has been created

Use nugget to add reference to ServiceStack.Text

then add reference

using ServiceStack.Text;

Console.WriteLine(note.Dump());



ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.