• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CompareOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CompareOptions的典型用法代码示例。如果您正苦于以下问题:C# CompareOptions类的具体用法?C# CompareOptions怎么用?C# CompareOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompareOptions类属于命名空间,在下文中一共展示了CompareOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Compare

 public virtual int Compare(string string1, string string2, CompareOptions options)
 {
     if (options == CompareOptions.OrdinalIgnoreCase)
     {
         return string.Compare(string1, string2, StringComparison.OrdinalIgnoreCase);
     }
     if ((options & CompareOptions.Ordinal) != CompareOptions.None)
     {
         if (options != CompareOptions.Ordinal)
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_CompareOptionOrdinal"), "options");
         }
         return string.CompareOrdinal(string1, string2);
     }
     if ((options & ~(CompareOptions.StringSort | CompareOptions.IgnoreWidth | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase)) != CompareOptions.None)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");
     }
     if (string1 == null)
     {
         if (string2 == null)
         {
             return 0;
         }
         return -1;
     }
     if (string2 == null)
     {
         return 1;
     }
     return InternalCompareString(this.m_dataHandle, this.m_sortName, string1, 0, string1.Length, string2, 0, string2.Length, GetNativeCompareFlags(options));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:CompareInfo.cs


示例2: SortKey

        internal byte[] m_KeyData;        // sortkey data

        //
        // The following constructor is designed to be called from CompareInfo to get the 
        // the sort key of specific string for synthetic culture
        //
        internal SortKey(String localeName, String str, CompareOptions options, byte[] keyData)
        {
            this.m_KeyData = keyData;
            this.localeName = localeName;
            this.options    = options;
            this.m_String   = str;
        }
开发者ID:JonHanna,项目名称:coreclr,代码行数:13,代码来源:SortKey.cs


示例3: internal_index

		private int internal_index (string source, int sindex,
		int count, string value,
		CompareOptions options,
		bool first)
		{
			throw new System.NotImplementedException();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:CompareInfo.Mosa.cs


示例4: GetHashCodeOfStringCore

        private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options)
        {
            Debug.Assert(source != null);
            Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0);

            if (source.Length == 0)
            {
                return 0;
            }

            int tmpHash = 0;

            fixed (char* pSource = source)
            {
                if (Interop.mincore.LCMapStringEx(_sortHandle != IntPtr.Zero ? null : _sortName,
                                                  LCMAP_HASH | (uint)GetNativeCompareFlags(options),
                                                  pSource, source.Length,
                                                  &tmpHash, sizeof(int),
                                                  null, null, _sortHandle) == 0)
                {
                    Environment.FailFast("LCMapStringEx failed!");
                }
            }

            return tmpHash;
        }
开发者ID:stephentoub,项目名称:corert,代码行数:26,代码来源:CompareInfo.Windows.cs


示例5: SortKey

        internal byte[] _keyData;        // sortkey data

        //
        // The following constructor is designed to be called from CompareInfo to get the 
        // the sort key of specific string for synthetic culture
        //
        internal SortKey(String localeName, String str, CompareOptions options, byte[] keyData)
        {
            _keyData = keyData;
            _localeName = localeName;
            _options    = options;
            _string   = str;
        }
开发者ID:JonHanna,项目名称:coreclr,代码行数:13,代码来源:SortKey.cs


示例6: 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());
            }
        }
开发者ID:nuxleus,项目名称:saxonica,代码行数:17,代码来源:XQuery.cs


示例7: 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:FieldNameLookup.cs


示例8: internal_compare

		private int internal_compare (string str1, int offset1,
		int length1, string str2,
		int offset2, int length2,
		CompareOptions options)
		{
			throw new System.NotImplementedException();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:CompareInfo.Mosa.cs


示例9: Equals

        public void Equals(string cultureName1, CompareOptions options1, string cultureName2, CompareOptions options2, bool expected)
        {
            StringComparer comparer1 = new CultureInfo(cultureName1).CompareInfo.GetStringComparer(options1);
            StringComparer comparer2 = new CultureInfo(cultureName2).CompareInfo.GetStringComparer(options2);

            Assert.Equal(expected, comparer1.Equals(comparer2));
            Assert.Equal(expected, comparer1.GetHashCode().Equals(comparer2.GetHashCode()));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:GetStringComparerTests.cs


示例10: IsSuffix

 public void IsSuffix(CompareInfo compareInfo, string source, string value, CompareOptions options, bool expected)
 {
     if (options == CompareOptions.None)
     {
         Assert.Equal(expected, compareInfo.IsSuffix(source, value));
     }
     Assert.Equal(expected, compareInfo.IsSuffix(source, value, options));
 }
开发者ID:SGuyGe,项目名称:corefx,代码行数:8,代码来源:CompareInfoTests.IsSuffix.cs


示例11: CultureContains

        public static bool CultureContains(this string haystack, string needle, CompareOptions comparison = CompareOptions.IgnoreCase)
        {
            if (Thread.CurrentThread.CurrentCulture.Name != "en-US") {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            }

            return Thread.CurrentThread.CurrentCulture.CompareInfo.IndexOf(haystack, needle, comparison) >= 0;
        }
开发者ID:IdleLands,项目名称:IdleLandsRedux,代码行数:8,代码来源:StringExtensions.cs


示例12: GetSortKey

 /// <summary>
 /// Gets the sort key for the specified string.
 /// </summary>
 /// <param name="compareInfo"></param>
 /// <param name="source"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static SortKey GetSortKey(this CompareInfo compareInfo, string source, CompareOptions options = CompareOptions.None)
 {
     #if PORTABLE
     throw new PlatformNotSupportedException();
     #else
     return compareInfo.GetSortKey(source, options);
     #endif
 }
开发者ID:ddunkin,项目名称:PortableContrib,代码行数:15,代码来源:CompareInfoPortableExtensions.cs


示例13: EndsWith

 private unsafe bool EndsWith(string source, string suffix, CompareOptions options)
 {
     fixed (char *pSource = source) fixed (char *pValue = suffix)
     {
         return FindStringOrdinal(pSource, source.Length, pValue, suffix.Length, FindStringOptions.EndsWith,
                                  (options & CompareOptions.IgnoreCase) != 0) >= 0;
     }
 }
开发者ID:huamichaelchen,项目名称:corert,代码行数:8,代码来源:CompareInfo.Dummy.cs


示例14: Compare

		/// <summary>
		/// Compares two strings.
		/// </summary>
		/// <param name="strA">The first string.</param>
		/// <param name="startA">The offset within the first string.</param>
		/// <param name="lengthA">The length within the first string.</param>
		/// <param name="strB">The second string.</param>
		/// <param name="startB">The offset within the second string.</param>
		/// <param name="lengthB">The length within the second string.</param>
		/// <param name="culture">The culture used for the comparison.</param>
		/// <param name="options">The comparison options.</param>
		/// <returns>Zero when string A is equal to string B;
		/// a positive value when string A is greater than string B;
		/// a negative value when string A is less than string B.</returns>
		public static int Compare(string strA, int startA, int lengthA, string strB, int startB, int lengthB, CultureInfo culture, CompareOptions options)
		{
			// TODO: Null?
			// TODO: Contract?
			int minLength = Math.Min(lengthA, lengthB);
			int result = String.Compare(strA, startA, strB, startB, minLength, culture, options);
			if (result == 0)
				result = lengthA.CompareTo(lengthB);
			return result;
		}
开发者ID:Virtlink,项目名称:noofax,代码行数:24,代码来源:StringExt.cs


示例15: CompareString

        private unsafe int CompareString(string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options)
        {
            fixed (char *pStr1 = string1) fixed (char *pStr2 = string2)
            {
                char *pString1 = &pStr1[offset1];
                char *pString2 = &pStr2[offset2];

                return CompareString(pString1, length1, pString2, length2, options);
            }
        }
开发者ID:huamichaelchen,项目名称:corert,代码行数:10,代码来源:CompareInfo.Dummy.cs


示例16: Compare

    public static void Compare(string localeName, string left, string right, int expected, CompareOptions options)
    {
        CompareInfo ci = CompareInfo.GetCompareInfo(localeName);        
        
        Assert.Equal(expected, Math.Sign(ci.Compare(left, right, options)));

        if (options == CompareOptions.None)
        {
            Assert.Equal(expected, Math.Sign(ci.Compare(left, right)));
        }
    }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:11,代码来源:CompareInfo.cs


示例17: 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);
	}
开发者ID:carrie901,项目名称:mono,代码行数:11,代码来源:CompareInfoTest.jvm.cs


示例18: GetHashCodeOfStringCore

        private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options)
        {
            bool ignoreCase = (options & (CompareOptions.IgnoreCase | CompareOptions.OrdinalIgnoreCase)) != 0;

            if (ignoreCase)
            {
                return source.ToUpper().GetHashCode();
            }

            return source.GetHashCode();
        }
开发者ID:huamichaelchen,项目名称:corert,代码行数:11,代码来源:CompareInfo.Dummy.cs


示例19: SortKey

		internal SortKey (int lcid, string source, byte [] buffer, CompareOptions opt,
			int lv1Length, int lv2Length, int lv3Length,
			int kanaSmallLength, int markTypeLength,
			int katakanaLength, int kanaWidthLength,
			int identLength)
		{
			this.lcid = lcid;
			this.source = source;
			this.key = buffer;
			this.options = opt;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:11,代码来源:SortKey.cs


示例20: Compare

 public virtual unsafe int Compare(string string1, string string2, CompareOptions options)
 {
     if (options == CompareOptions.OrdinalIgnoreCase)
     {
         return string.Compare(string1, string2, StringComparison.OrdinalIgnoreCase);
     }
     if ((options & CompareOptions.Ordinal) != CompareOptions.None)
     {
         if (options != CompareOptions.Ordinal)
         {
             throw new ArgumentException(Environment.GetResourceString("Argument_CompareOptionOrdinal"), "options");
         }
         if (string1 == null)
         {
             if (string2 == null)
             {
                 return 0;
             }
             return -1;
         }
         if (string2 == null)
         {
             return 1;
         }
         return string.nativeCompareOrdinal(string1, string2, false);
     }
     if ((options & ~(CompareOptions.StringSort | CompareOptions.IgnoreWidth | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase)) != CompareOptions.None)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");
     }
     if (string1 == null)
     {
         if (string2 == null)
         {
             return 0;
         }
         return -1;
     }
     if (string2 == null)
     {
         return 1;
     }
     if (!this.IsSynthetic)
     {
         return Compare(this.m_pSortingTable, this.m_sortingLCID, string1, string2, options);
     }
     if (options == CompareOptions.Ordinal)
     {
         return Compare(CultureInfo.InvariantCulture.CompareInfo.m_pSortingTable, this.m_sortingLCID, string1, string2, options);
     }
     return nativeCompareString(this.m_sortingLCID, string1, 0, string1.Length, string2, 0, string2.Length, GetNativeCompareFlags(options));
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:52,代码来源:CompareInfo.cs



注:本文中的CompareOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompareTool类代码示例发布时间:2022-05-24
下一篇:
C# CompareFunction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap