本文整理汇总了C#中System.Globalization.CompareInfo类的典型用法代码示例。如果您正苦于以下问题:C# CompareInfo类的具体用法?C# CompareInfo怎么用?C# CompareInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompareInfo类属于System.Globalization命名空间,在下文中一共展示了CompareInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CultureComparer
//--- Constructors ---
/// <summary>
/// Create comparer based on culture.
/// </summary>
/// <param name="culture">Culture to get <see cref="CompareInfo"/> from.</param>
public CultureComparer(CultureInfo culture)
{
if(culture == null) {
throw new ArgumentNullException("culture");
}
_cultureCompare = culture.CompareInfo;
}
示例2: Comparer
Comparer (CultureInfo culture)
{
if (culture == null)
throw new ArgumentNullException ("culture");
m_compareInfo = culture.CompareInfo;
}
示例3: Comparer
public Comparer(CultureInfo culture) {
if (culture==null) {
throw new ArgumentNullException("culture");
}
Contract.EndContractBlock();
m_compareInfo = culture.CompareInfo;
}
示例4: CharacterTest
public CharacterTest()
{
_MarvelPublicKey = "67d146c4c462f0b55bf12bb7d60948af";
_MarvelPrivateKey = "54fd1a8ac788767cc91938bcb96755186074970b";
_Marvel = new Marvel(_MarvelPublicKey, _MarvelPrivateKey);
_Comparer = CompareInfo.GetCompareInfo("en-US");
}
示例5: DeclareCollation
/// <summary>
/// Create a collation based on a given <c>CompareInfo</c> and <c>CompareOptions</c>
/// </summary>
/// <param name="uri">The collation URI to be used within the XPath expression to refer to this collation</param>
/// <param name="comparer">The <c>CompareInfo</c>, which determines the language-specific
/// collation rules to be used</param>
/// <param name="options">Options to be used in performing comparisons, for example
/// whether they are to be case-blind and/or accent-blind</param>
/// <param name="isDefault">If true, this collation will be used as the default collation</param>
public void DeclareCollation(Uri uri, CompareInfo compareInfo, CompareOptions options, Boolean isDefault) {
DotNetComparator comparator = new DotNetComparator(compareInfo, options);
env.declareCollation(uri.ToString(), comparator);
if(isDefault) {
env.declareDefaultCollation(uri.ToString());
}
}
示例6: LinearIndexOf
private int LinearIndexOf(string fieldName, CompareOptions compareOptions)
{
CompareInfo compareInfo = this._compareInfo;
if (compareInfo == null)
{
if (-1 != this._defaultLocaleID)
{
compareInfo = CompareInfo.GetCompareInfo(this._defaultLocaleID);
}
if (compareInfo == null)
{
compareInfo = CultureInfo.InvariantCulture.CompareInfo;
}
this._compareInfo = compareInfo;
}
int length = this._fieldNames.Length;
for (int i = 0; i < length; i++)
{
if (compareInfo.Compare(fieldName, this._fieldNames[i], compareOptions) == 0)
{
this._fieldNameLookup[fieldName] = i;
return i;
}
}
return -1;
}
示例7: PatternMatcher
/// <summary>
/// Construct a new PatternMatcher using the specified culture.
/// </summary>
/// <param name="pattern">The pattern to make the pattern matcher for.</param>
/// <param name="culture">The culture to use for string searching and comparison.</param>
/// <param name="verbatimIdentifierPrefixIsWordCharacter">Whether to consider "@" as a word character</param>
/// <param name="allowFuzzyMatching">Whether or not close matches should count as matches.</param>
public PatternMatcher(
string pattern,
CultureInfo culture,
bool verbatimIdentifierPrefixIsWordCharacter,
bool allowFuzzyMatching)
{
pattern = pattern.Trim();
_compareInfo = culture.CompareInfo;
_allowFuzzyMatching = allowFuzzyMatching;
_fullPatternSegment = new Segment(pattern, verbatimIdentifierPrefixIsWordCharacter, allowFuzzyMatching);
if (pattern.IndexOf('.') < 0)
{
// PERF: Avoid string.Split allocations when the pattern doesn't contain a dot.
_dotSeparatedSegments = pattern.Length > 0
? new Segment[1] { _fullPatternSegment }
: Array.Empty<Segment>();
}
else
{
_dotSeparatedSegments = pattern.Split(s_dotCharacterArray, StringSplitOptions.RemoveEmptyEntries)
.Select(text => new Segment(text.Trim(), verbatimIdentifierPrefixIsWordCharacter, allowFuzzyMatching))
.ToArray();
}
_invalidPattern = _dotSeparatedSegments.Length == 0 || _dotSeparatedSegments.Any(s => s.IsInvalid);
}
示例8: CaseInsensitiveComparer
public CaseInsensitiveComparer(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException("culture");
}
this.m_compareInfo = culture.CompareInfo;
}
示例9: CaseInsensitiveHashCodeProvider
public CaseInsensitiveHashCodeProvider(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
_compareInfo = culture.CompareInfo;
}
示例10: CaseInsensitiveComparer
public CaseInsensitiveComparer(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException(nameof(culture));
}
Contract.EndContractBlock();
_compareInfo = culture.CompareInfo;
}
示例11: AssertCompare
void AssertCompare (string message, int result, string s1, string s2,
CompareOptions opt, CompareInfo ci)
{
int ret = ci.Compare (s1, s2, opt);
if (result == 0)
AssertEquals (message, 0, ret);
else if (result < 0)
Assert.IsTrue (message + String.Format ("(neg: {0})", ret), ret < 0);
else
Assert.IsTrue (message + String.Format ("(pos: {0})", ret), ret > 0);
}
示例12: Comparer
private Comparer(SerializationInfo info, StreamingContext context)
{
this.m_compareInfo = null;
SerializationInfoEnumerator enumerator = info.GetEnumerator();
while (enumerator.MoveNext())
{
string str;
if (((str = enumerator.Name) != null) && (str == "CompareInfo"))
{
this.m_compareInfo = (CompareInfo) info.GetValue("CompareInfo", typeof(CompareInfo));
}
}
}
示例13: __DTString
internal __DTString(string str, DateTimeFormatInfo dtfi)
{
this.Index = -1;
this.Value = str;
this.len = this.Value.Length;
this.m_current = '\0';
if (dtfi != null)
{
this.m_info = dtfi.CompareInfo;
this.m_checkDigitToken = ((dtfi.FormatFlags & DateTimeFormatFlags.UseDigitPrefixInTokens) != DateTimeFormatFlags.None);
return;
}
this.m_info = Thread.CurrentThread.CurrentCulture.CompareInfo;
this.m_checkDigitToken = false;
}
示例14: MatchCaseInsensitive
/// <summary>
/// Attempts to match the specified string with the current point in the string in a case-insensitive
/// manner, according to the given comparison info.
/// </summary>
internal bool MatchCaseInsensitive(string match, CompareInfo compareInfo)
{
unchecked
{
if (match.Length > Value.Length - Index)
{
return false;
}
// FIXME: This will fail if the length in the input string is different to the length in the
// match string for culture-specific reasons. It's not clear how to handle that...
if (compareInfo.Compare(Value, Index, match.Length, match, 0, match.Length, CompareOptions.IgnoreCase) == 0)
{
Move(Index + match.Length);
return true;
}
return false;
}
}
示例15: Compare
internal int Compare(string s1, string s2, CompareInfo comparer) {
object obj1 = s1;
object obj2 = s2;
if (obj1 == obj2)
return 0;
if (obj1 == null)
return -1;
if (obj2 == null)
return 1;
int leng1 = s1.Length;
int leng2 = s2.Length;
for (; leng1 > 0; leng1--) {
if (s1[leng1-1] != 0x20 && s1[leng1-1] != 0x3000) // 0x3000 is Ideographic Whitespace
break;
}
for (; leng2 > 0; leng2--) {
if (s2[leng2-1] != 0x20 && s2[leng2-1] != 0x3000)
break;
}
return (comparer ?? this.CompareInfo).Compare(s1, 0, leng1, s2, 0, leng2, _compareFlags);
}