示例#1
0
            public int Compare(SettingValue <TTier, TDataCenter> x, SettingValue <TTier, TDataCenter> y)
            {
                if (EqualityComparer <TTier> .Default.Equals(x.Tier, y.Tier) &&
                    EqualityComparer <TDataCenter> .Default.Equals(x.DataCenter, y.DataCenter))
                {
                    return(0);
                }

                if (EqualityComparer <TTier> .Default.Equals(x.Tier, _currentTier) &&
                    EqualityComparer <TTier> .Default.Equals(y.Tier, _currentTier))
                {
                    return(-1);
                }

                if (EqualityComparer <TTier> .Default.Equals(y.Tier, _currentTier) &&
                    EqualityComparer <TTier> .Default.Equals(x.Tier, _currentTier))
                {
                    return(1);
                }

                if (EqualityComparer <TDataCenter> .Default.Equals(x.DataCenter, _currentDataCenter) &&
                    EqualityComparer <TDataCenter> .Default.Equals(y.DataCenter, _currentDataCenter))
                {
                    return(-1);
                }

                if (EqualityComparer <TDataCenter> .Default.Equals(y.DataCenter, _currentDataCenter) &&
                    EqualityComparer <TDataCenter> .Default.Equals(x.DataCenter, _currentDataCenter))
                {
                    return(1);
                }

                if (x.IsMoreSpecificThan(y))
                {
                    return(-1);
                }
                if (y.IsMoreSpecificThan(x))
                {
                    return(1);
                }

                return(0);
            }