Skip to content

Commit 390fba0

Browse files
committed
Tabified OAuth files.
1 parent 8c07281 commit 390fba0

18 files changed

+1260
-1286
lines changed

RestSharp.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.WindowsPhone", "RestSharp.WindowsPhone\RestSharp.WindowsPhone.csproj", "{F4D48DF6-316E-4963-B5C1-59CA39B431B7}"
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{E709A928-A45C-4622-A35C-CCD8EE44CA80}"
15-
ProjectSection(SolutionItems) = preProject
16-
restsharp.nuspec = restsharp.nuspec
17-
EndProjectSection
1815
EndProject
1916
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Net4", "RestSharp.Net4\RestSharp.Net4.csproj", "{5D979D3C-99D6-49B0-AC4F-ACFF32F9C4BE}"
2017
EndProject
Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
43
using System.Collections.Specialized;
4+
using System.Text;
55

66
#if SILVERLIGHT
77
using Hammock.Silverlight.Compat;
@@ -11,106 +11,106 @@
1111

1212
namespace RestSharp.Authenticators.OAuth.Extensions
1313
{
14-
internal static class CollectionExtensions
15-
{
16-
public static IEnumerable<T> AsEnumerable<T>(this T item)
17-
{
18-
return new[] {item};
19-
}
20-
21-
public static IEnumerable<T> And<T>(this T item, T other)
22-
{
23-
return new[] {item, other};
24-
}
25-
26-
public static IEnumerable<T> And<T>(this IEnumerable<T> items, T item)
27-
{
28-
foreach (var i in items)
29-
{
30-
yield return i;
31-
}
32-
33-
yield return item;
34-
}
35-
36-
public static K TryWithKey<T, K>(this IDictionary<T, K> dictionary, T key)
37-
{
38-
return dictionary.ContainsKey(key) ? dictionary[key] : default(K);
39-
}
40-
41-
public static IEnumerable<T> ToEnumerable<T>(this object[] items) where T : class
42-
{
43-
foreach (var item in items)
44-
{
45-
var record = item as T;
46-
yield return record;
47-
}
48-
}
49-
50-
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
51-
{
52-
foreach (var item in items)
53-
{
54-
action(item);
55-
}
56-
}
14+
internal static class CollectionExtensions
15+
{
16+
public static IEnumerable<T> AsEnumerable<T>(this T item)
17+
{
18+
return new[] {item};
19+
}
20+
21+
public static IEnumerable<T> And<T>(this T item, T other)
22+
{
23+
return new[] {item, other};
24+
}
25+
26+
public static IEnumerable<T> And<T>(this IEnumerable<T> items, T item)
27+
{
28+
foreach (var i in items)
29+
{
30+
yield return i;
31+
}
32+
33+
yield return item;
34+
}
35+
36+
public static K TryWithKey<T, K>(this IDictionary<T, K> dictionary, T key)
37+
{
38+
return dictionary.ContainsKey(key) ? dictionary[key] : default(K);
39+
}
40+
41+
public static IEnumerable<T> ToEnumerable<T>(this object[] items) where T : class
42+
{
43+
foreach (var item in items)
44+
{
45+
var record = item as T;
46+
yield return record;
47+
}
48+
}
49+
50+
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
51+
{
52+
foreach (var item in items)
53+
{
54+
action(item);
55+
}
56+
}
5757

5858
#if !WINDOWS_PHONE
5959

60-
public static void AddRange(this IDictionary<string, string> collection, NameValueCollection range)
61-
{
62-
foreach(string key in range.AllKeys)
63-
{
64-
collection.Add(key, range[key]);
65-
}
66-
}
67-
68-
public static string ToQueryString(this NameValueCollection collection)
69-
{
70-
var sb = new StringBuilder();
71-
if (collection.Count > 0)
72-
{
73-
sb.Append("?");
74-
}
75-
76-
var count = 0;
77-
foreach(var key in collection.AllKeys)
78-
{
79-
sb.AppendFormat("{0}={1}", key, collection[key].UrlEncode());
80-
count++;
81-
82-
if (count >= collection.Count)
83-
{
84-
continue;
85-
}
86-
sb.Append("&");
87-
}
88-
return sb.ToString();
89-
}
60+
public static void AddRange(this IDictionary<string, string> collection, NameValueCollection range)
61+
{
62+
foreach (var key in range.AllKeys)
63+
{
64+
collection.Add(key, range[key]);
65+
}
66+
}
67+
68+
public static string ToQueryString(this NameValueCollection collection)
69+
{
70+
var sb = new StringBuilder();
71+
if (collection.Count > 0)
72+
{
73+
sb.Append("?");
74+
}
75+
76+
var count = 0;
77+
foreach (var key in collection.AllKeys)
78+
{
79+
sb.AppendFormat("{0}={1}", key, collection[key].UrlEncode());
80+
count++;
81+
82+
if (count >= collection.Count)
83+
{
84+
continue;
85+
}
86+
sb.Append("&");
87+
}
88+
return sb.ToString();
89+
}
9090

9191
#endif
9292

93-
public static string Concatenate(this WebParameterCollection collection, string separator, string spacer)
94-
{
95-
var sb = new StringBuilder();
96-
97-
var total = collection.Count;
98-
var count = 0;
99-
100-
foreach (var item in collection)
101-
{
102-
sb.Append(item.Name);
103-
sb.Append(separator);
104-
sb.Append(item.Value);
105-
106-
count++;
107-
if (count < total)
108-
{
109-
sb.Append(spacer);
110-
}
111-
}
112-
113-
return sb.ToString();
114-
}
115-
}
93+
public static string Concatenate(this WebParameterCollection collection, string separator, string spacer)
94+
{
95+
var sb = new StringBuilder();
96+
97+
var total = collection.Count;
98+
var count = 0;
99+
100+
foreach (var item in collection)
101+
{
102+
sb.Append(item.Name);
103+
sb.Append(separator);
104+
sb.Append(item.Value);
105+
106+
count++;
107+
if (count < total)
108+
{
109+
sb.Append(spacer);
110+
}
111+
}
112+
113+
return sb.ToString();
114+
}
115+
}
116116
}

RestSharp/Authenticators/OAuth/Extensions/OAuthExtensions.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44

55
namespace RestSharp.Authenticators.OAuth.Extensions
66
{
7-
internal static class OAuthExtensions
8-
{
9-
public static string ToRequestValue(this OAuthSignatureMethod signatureMethod)
10-
{
11-
var value = signatureMethod.ToString().ToUpper();
12-
var shaIndex = value.IndexOf("SHA1");
13-
return shaIndex > -1 ? value.Insert(shaIndex, "-") : value;
14-
}
15-
16-
public static OAuthSignatureMethod FromRequestValue(this string signatureMethod)
17-
{
18-
switch(signatureMethod)
19-
{
20-
case "HMAC-SHA1":
21-
return OAuthSignatureMethod.HmacSha1;
22-
case "RSA-SHA1":
23-
return OAuthSignatureMethod.RsaSha1;
24-
default:
25-
return OAuthSignatureMethod.PlainText;
26-
}
27-
}
7+
internal static class OAuthExtensions
8+
{
9+
public static string ToRequestValue(this OAuthSignatureMethod signatureMethod)
10+
{
11+
var value = signatureMethod.ToString().ToUpper();
12+
var shaIndex = value.IndexOf("SHA1");
13+
return shaIndex > -1 ? value.Insert(shaIndex, "-") : value;
14+
}
2815

29-
public static string HashWith(this string input, HashAlgorithm algorithm)
30-
{
31-
var data = Encoding.UTF8.GetBytes(input);
32-
var hash = algorithm.ComputeHash(data);
33-
return Convert.ToBase64String(hash);
34-
}
35-
}
16+
public static OAuthSignatureMethod FromRequestValue(this string signatureMethod)
17+
{
18+
switch (signatureMethod)
19+
{
20+
case "HMAC-SHA1":
21+
return OAuthSignatureMethod.HmacSha1;
22+
case "RSA-SHA1":
23+
return OAuthSignatureMethod.RsaSha1;
24+
default:
25+
return OAuthSignatureMethod.PlainText;
26+
}
27+
}
28+
29+
public static string HashWith(this string input, HashAlgorithm algorithm)
30+
{
31+
var data = Encoding.UTF8.GetBytes(input);
32+
var hash = algorithm.ComputeHash(data);
33+
return Convert.ToBase64String(hash);
34+
}
35+
}
3636
}

0 commit comments

Comments
 (0)