You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.47
Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
parent
88ff76fe28
commit
e46a49ecf1
@ -133,31 +133,46 @@ namespace System {
|
||||
, IWellKnownStringEqualityComparer
|
||||
#endif
|
||||
{
|
||||
|
||||
private CompareInfo _compareInfo;
|
||||
private bool _ignoreCase;
|
||||
[OptionalField]
|
||||
private CompareOptions _options;
|
||||
|
||||
internal CultureAwareComparer(CultureInfo culture, bool ignoreCase) {
|
||||
_compareInfo = culture.CompareInfo;
|
||||
_ignoreCase = ignoreCase;
|
||||
_options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None;
|
||||
}
|
||||
|
||||
internal CultureAwareComparer(CompareInfo compareInfo, bool ignoreCase) {
|
||||
_compareInfo = compareInfo;
|
||||
_ignoreCase = ignoreCase;
|
||||
_options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None;
|
||||
}
|
||||
|
||||
internal CultureAwareComparer(CompareInfo compareInfo, CompareOptions options) {
|
||||
_compareInfo = compareInfo;
|
||||
_options = options;
|
||||
|
||||
// set the _ignoreCase flag to preserve compat in case this type is serialized on a
|
||||
// newer version of the framework and deserialized on an older version of the framework
|
||||
_ignoreCase = ((options & CompareOptions.IgnoreCase) == CompareOptions.IgnoreCase ||
|
||||
(options & CompareOptions.OrdinalIgnoreCase ) == CompareOptions.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public override int Compare(string x, string y) {
|
||||
if (Object.ReferenceEquals(x, y)) return 0;
|
||||
if (x == null) return -1;
|
||||
if (y == null) return 1;
|
||||
return _compareInfo.Compare(x, y, _ignoreCase? CompareOptions.IgnoreCase : CompareOptions.None);
|
||||
return _compareInfo.Compare(x, y, _options);
|
||||
}
|
||||
|
||||
public override bool Equals(string x, string y) {
|
||||
if (Object.ReferenceEquals(x ,y)) return true;
|
||||
if (x == null || y == null) return false;
|
||||
|
||||
return (_compareInfo.Compare(x, y, _ignoreCase? CompareOptions.IgnoreCase : CompareOptions.None) == 0);
|
||||
return (_compareInfo.Compare(x, y, _options) == 0);
|
||||
}
|
||||
|
||||
public override int GetHashCode(string obj) {
|
||||
@ -166,13 +181,7 @@ namespace System {
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
CompareOptions options = CompareOptions.None;
|
||||
|
||||
if( _ignoreCase) {
|
||||
options |= CompareOptions.IgnoreCase;
|
||||
}
|
||||
|
||||
return _compareInfo.GetHashCodeOfString(obj, options);
|
||||
return _compareInfo.GetHashCodeOfString(obj, _options);
|
||||
}
|
||||
|
||||
// Equals method for the comparer itself.
|
||||
@ -181,7 +190,8 @@ namespace System {
|
||||
if( comparer == null) {
|
||||
return false;
|
||||
}
|
||||
return (this._ignoreCase == comparer._ignoreCase) && (this._compareInfo.Equals(comparer._compareInfo));
|
||||
return (this._ignoreCase == comparer._ignoreCase) && (this._compareInfo.Equals(comparer._compareInfo)
|
||||
&& this._options == comparer._options);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
Reference in New Issue
Block a user