Last active
August 29, 2015 14:06
-
-
Save robertmclaws/2dbadad305131e1483d4 to your computer and use it in GitHub Desktop.
Our current WebJobs method signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ProcessQueueMessage([QueueTrigger("events")] byte[] messageEnvelope) | |
{ | |
var message = messageEnvelope.Deserialize<string>()); | |
Trace.WriteLine(message). | |
} | |
public static T Deserialize<T>(this byte[] data) where T : class | |
{ | |
if (data == null) | |
{ | |
return null; | |
} | |
//if (typeof(T) == typeof(string)) | |
//{ | |
return Decompress(data) as T; | |
//} | |
//return DeserializeFromJson<T>(data); | |
} | |
private static string Decompress(byte[] data) | |
{ | |
using (var outputMemoryStream = new MemoryStream()) | |
{ | |
using (var inputMemoryStream = new MemoryStream(data)) | |
{ | |
using (var decompressionStream = new DeflateStream(inputMemoryStream, CompressionMode.Decompress)) | |
{ | |
decompressionStream.CopyTo(outputMemoryStream); | |
} | |
} | |
return outputMemoryStream.ToArray().GetString(); | |
} | |
} |
rustd
commented
Sep 18, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment