-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExtensionMethods.cs
More file actions
40 lines (32 loc) · 1.05 KB
/
ExtensionMethods.cs
File metadata and controls
40 lines (32 loc) · 1.05 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
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.Drawing;
namespace ColorCode.Common
{
public static class ExtensionMethods
{
public static void SortStable<T>(this IList<T> list,
Comparison<T> comparison)
{
Guard.ArgNotNull(list, "list");
int count = list.Count;
for (int j = 1; j < count; j++)
{
T key = list[j];
int i = j - 1;
for (; i >= 0 && comparison(list[i], key) > 0; i--)
{
list[i + 1] = list[i];
}
list[i + 1] = key;
}
}
public static string ToHtmlColor(this Color color)
{
if (color == Color.Empty)
throw new ArgumentException("You may not create a hex string from an empty color.");
return ColorTranslator.ToHtml(color);
}
}
}