[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / Model / PropertyEntryNameComparer.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Model 
5 {
6     using System;
7     using System.Collections;
8     using System.Collections.Generic;
9
10     using System.Activities.Presentation.PropertyEditing;
11
12     // <summary>
13     // Compares PropertyEntry instances solely on their DisplayName
14     // </summary>
15     internal class PropertyEntryNameComparer : IComparer, IComparer<PropertyEntry> 
16     {
17
18         public static readonly PropertyEntryNameComparer Instance = new PropertyEntryNameComparer();
19
20         private static int CompareCore(object x, object y) 
21         {
22             ModelPropertyEntry j = x as ModelPropertyEntry;
23             ModelPropertyEntry k = y as ModelPropertyEntry;
24
25             if (j == null && k == null) 
26             {
27                 return 0;
28             }
29             if (j == null) 
30             {
31                 return -1;
32             }
33             if (k == null) 
34             {
35                 return 1;
36             }
37
38             return string.Compare(j.DisplayName, k.DisplayName, StringComparison.CurrentCulture);
39         }
40
41         // IComparer<PropertyEntry> Members
42
43         public int Compare(PropertyEntry x, PropertyEntry y) 
44         {
45             return CompareCore(x, y);
46         }
47
48
49         // IComparer Members
50
51         public int Compare(object x, object y) 
52         {
53             return CompareCore(x, y);
54         }
55
56     }
57 }