forked from CommunityToolkit/WindowsCommunityToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAuthParameter.cs
More file actions
65 lines (58 loc) · 1.86 KB
/
Copy pathOAuthParameter.cs
File metadata and controls
65 lines (58 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Globalization;
namespace Microsoft.Toolkit.Services.OAuth
{
/// <summary>
/// OAuth parameter.
/// </summary>
internal class OAuthParameter
{
/// <summary>
/// Gets or sets key property.
/// </summary>
public string Key { get; set; }
/// <summary>
/// Gets or sets value property.
/// </summary>
public string Value { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="OAuthParameter"/> class.
/// Constructor accepting key and value.
/// </summary>
/// <param name="key">Key.</param>
/// <param name="value">Value.</param>
public OAuthParameter(string key, string value)
{
Key = key;
Value = value;
}
/// <summary>
/// ToString override.
/// </summary>
/// <returns>String representation</returns>
public override string ToString()
{
return ToString(false);
}
/// <summary>
/// Format key / value into string.
/// </summary>
/// <param name="withQuotes">Whether to create quotes in string.</param>
/// <returns>Formatted string of key / value.</returns>
public string ToString(bool withQuotes)
{
string format;
if (withQuotes)
{
format = "{0}=\"{1}\"";
}
else
{
format = "{0}={1}";
}
return string.Format(CultureInfo.InvariantCulture, format, OAuthEncoder.UrlEncode(Key), OAuthEncoder.UrlEncode(Value));
}
}
}