forked from anthonyreilly/NetCoreForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensionMethods.cs
53 lines (49 loc) · 1.55 KB
/
ExtensionMethods.cs
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
using System;
using System.Collections.Generic;
namespace NetCoreForce.Client
{
public static class ExtensionMethods
{
/// <summary>
/// Convert DateTimeOffset to a Salesforce-compatible string
/// </summary>
public static string ToSfDateString(this DateTimeOffset value)
{
return value.ToString("yyyy-MM-ddTHH:mm:sszzz");
}
/// <summary>
/// Uppercase the first letter in the string.
/// </summary>
public static string UppercaseFirstLetter(this string value)
{
if (value.Length > 0)
{
char[] array = value.ToCharArray();
array[0] = char.ToUpper(array[0]);
return new string(array);
}
return value;
}
/// <summary>
/// Lowercase the first letter in the string.
/// </summary>
public static string LowercaseFirstLetter(this string value)
{
if (value.Length > 0)
{
char[] array = value.ToCharArray();
array[0] = char.ToLower(array[0]);
return new string(array);
}
return value;
}
/// <summary>
/// Add all key pairs from another dictionary
/// </summary>
public static void AddRange<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Dictionary<TKey, TValue> range)
{
foreach (TKey key in range.Keys)
{ dictionary.Add(key, range[key]); }
}
}
}