Visual Studio Feeds English |
- Annual SQL Connectivity Survey
- Fetching Picasa Images through RSS in WP7
- I'm on the SharePoint Pod Show talking about Web Parts
- Silverlight 5 Incompatibility: Play by the Rules
- Practical Window Phone 7 ListBox Usage
- Two Legged OAuth Signature Generator
- Return a NameValueCollection From A HTTP Header
- Windows Azure and Cloud Computing Posts for 8/15/2011+
- Setting default value for @Html.EditorFor in asp.net mvc
- Windows Client Developer Roundup 078 for 8/15/2011
| Annual SQL Connectivity Survey Posted: 15 Aug 2011 02:23 PM PDT |
| Fetching Picasa Images through RSS in WP7 Posted: 15 Aug 2011 02:08 PM PDT |
| I'm on the SharePoint Pod Show talking about Web Parts Posted: 15 Aug 2011 12:20 PM PDT |
| Silverlight 5 Incompatibility: Play by the Rules Posted: 15 Aug 2011 11:04 AM PDT |
| Practical Window Phone 7 ListBox Usage Posted: 15 Aug 2011 10:48 AM PDT |
| Two Legged OAuth Signature Generator Posted: 15 Aug 2011 09:30 AM PDT public class TwoLeggedOAuthSignatureGenerator { private const string OAuthConsumerKey = "oauth_consumer_key"; private const string OAuthNonce = "oauth_nonce"; private const string OAuthSignatureMethod = "oauth_signature_method"; private const string OAuthTimestamp = "oauth_timestamp"; private const string OAuthVersion = "oauth_version"; public string GenerateSignature(string httpMethod, Uri uri, string consumerKey, string consumerSecret, string nonce, string timestamp, string version = null) { var parameters = ConvertQueryStringToListOfKvp(uri.Query); AddParameter(parameters, OAuthConsumerKey, consumerKey); AddParameter(parameters, OAuthNonce, nonce); AddParameter(parameters, OAuthSignatureMethod, "HMAC-SHA1"); AddParameter(parameters, OAuthTimestamp, timestamp); if (version != null) AddParameter(parameters, OAuthVersion, version); parameters.Sort((x, y) => x.Key == y.Key ? string.Compare(x.Value, y.Value) : string.Compare(x.Key, y.Key)); var normalizedUrl = string.Format("{0}://{1}{2}{3}", uri.Scheme, uri.Host, (uri.Scheme == "http" && uri.Port == 80) || (uri.Scheme == "https" && uri.Port == 443) ? null : ":" + uri.Port, uri.AbsolutePath); var normalizedRequestParameters = string.Join(null, parameters.Select(x => "&" + x.Key + "=" + x.Value)).TrimStart('&'); var signatureData = string.Format("{0}&{1}&{2}", httpMethod.ToUpper(), UrlEncode(normalizedUrl), UrlEncode(normalizedRequestParameters)); return ComputeHash(consumerSecret, signatureData); } private static List ConvertQueryStringToListOfKvp(string queryString) { return Regex.Matches(queryString, @"(\w+)=.*?(?:&|$)").Cast().Select(x => x.Value.TrimEnd('&').Split('=')).Select(x => new KeyValuePair(x[0], x[1])).ToList(); } private static void AddParameter(ICollection parameters, string key, string value) { parameters.Add(new KeyValuePair(key, value)); } private static string ComputeHash(string secret, string data) { var hash = new HMACSHA1 { Key = Encoding.ASCII.GetBytes(UrlEncode(secret) + "&") }.ComputeHash(Encoding.ASCII.GetBytes(data)); return Convert.ToBase64String(hash); } private static string UrlEncode(string value) { const string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"; return value.Select(x => x.ToString()).Aggregate((x, y) => x + (unreservedChars.Contains(y.ToString()) ? y : HttpUtility.UrlEncode(y).ToUpper())); } } ...(Read whole news on source site) (http://geekswithblogs.net/Nettuce/archive/2011/08/15/two-legged-oauth-signature-generator.aspx) |
| Return a NameValueCollection From A HTTP Header Posted: 15 Aug 2011 09:30 AM PDT public static NameValueCollection HeaderNameValueCollection(this string header) { var nameValueCollection = new NameValueCollection(); Regex.Matches(header, @"(\w+)="".*?""").Cast().Select(x => x.Value.TrimEnd('"').Split(new[] { "=\"" }, StringSplitOptions.None)).ForEach(x => nameValueCollection.Add(x[0], x.Length == 2 ? x[1] : string.Empty)); return nameValueCollection; } ...(Read whole news on source site) (http://geekswithblogs.net/Nettuce/archive/2011/08/15/return-a-namevaluecollection-from-a-http-header.aspx) |
| Windows Azure and Cloud Computing Posts for 8/15/2011+ Posted: 15 Aug 2011 09:13 AM PDT |
| Setting default value for @Html.EditorFor in asp.net mvc Posted: 15 Aug 2011 08:42 AM PDT |
| Windows Client Developer Roundup 078 for 8/15/2011 Posted: 15 Aug 2011 08:13 AM PDT |
| You are subscribed to email updates from VSF RSS English To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |
Комментариев нет:
Отправить комментарий