Skip to content

Instantly share code, notes, and snippets.

@claudiosanchez
Created May 21, 2013 05:40
Show Gist options
  • Select an option

  • Save claudiosanchez/5617693 to your computer and use it in GitHub Desktop.

Select an option

Save claudiosanchez/5617693 to your computer and use it in GitHub Desktop.
Generic Method for Getting Azure Objects
public static T GetAzureObject<T>(string subscriptionId, string storageName, string uriFormat, params object[] parameters) where T:class, T:new()
{
var service = default(T);
var requestUri = new Uri (string.Format(uriFormat, parameters));
var httpResponse = PerformHttpCall (subscriptionId, storageName);
var serializer = new XmlSerializer (T);
using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(httpResponse)))
{
service = (T)serializer.Deserialize(memStream);
}
return service;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment