当前位置: 首页>>代码示例>>C#>>正文


C# System.StringComparison类代码示例

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


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

示例1: WildcardPathSegment

 public WildcardPathSegment(string beginsWith, List<string> contains, string endsWith, StringComparison comparisonType)
 {
     BeginsWith = beginsWith;
     Contains = contains;
     EndsWith = endsWith;
     _comparisonType = comparisonType;
 }
开发者ID:leloulight,项目名称:FileSystem,代码行数:7,代码来源:WildcardPathSegment.cs

示例2: SearchTermMatches

 public static Expression<Func<EstablishmentUrl, bool>> SearchTermMatches(string term, StringMatchStrategy matchStrategy, StringComparison? stringComparison = null)
 {
     var textMatches =
         TextMatches(term, matchStrategy, stringComparison).Expand()
     ;
     var officialUrlMatches =
         IsOfficialUrl()
         .And
         (
             textMatches
         )
     ;
     var nonOfficialNameMatches =
         IsNotOfficialUrl()
         //.And
         //(
         //    TranslationToLanguageMatchesCurrentUiCulture()
         //)
         .And
         (
             textMatches
         )
         .Expand()
     ;
     var urlMatches =
         officialUrlMatches
         .Or
         (
             nonOfficialNameMatches
         )
     ;
     return urlMatches;
 }
开发者ID:danludwig,项目名称:UCosmic,代码行数:33,代码来源:QueryEstablishmentUrls.cs

示例3: CalculateCloseness

        public static int? CalculateCloseness(this ILocation locationA, ILocation locationB, StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase)
        {
            var sequenceA = locationA.GetParts();
            var sequenceB = locationB.GetParts();

            return sequenceA.CalculateCloseness(sequenceB, comparisonType);
        }
开发者ID:Mavtak,项目名称:roomie,代码行数:7,代码来源:LocationExtensions.cs

示例4: MakeUnique

        public static void MakeUnique(ref List<string> items, StringComparison sc)
        {
            List<int> IndicesToRemove = new List<int>();

            int index = 0;
            foreach (string s in items)
            {
                if (index > 0)
                {
                    if (ExistsInSubset(items, index, s, sc))
                    {
                        IndicesToRemove.Add(index);
                    }
                }
                ++index;
            }

            if (IndicesToRemove.Count > 0)
            {
                for (index = IndicesToRemove.Count - 1; index >= 0; --index)
                {
                    items.RemoveAt(IndicesToRemove[index]);
                }
            }
        }
开发者ID:zippy1981,项目名称:GTools,代码行数:25,代码来源:StringList.cs

示例5: ContainsExt

        public static bool ContainsExt(this string text, string toFind, StringComparison comparison)
        {
            if (text == null) { throw new ArgumentNullException(nameof(text)); }
            if (toFind == null) { throw new ArgumentNullException(nameof(toFind)); }

            return text.IndexOf(toFind, comparison) > -1;
        }
开发者ID:Kingloo,项目名称:Storm,代码行数:7,代码来源:String.cs

示例6: Contains

        /// <summary>
        /// Determines whether a string contans another string.
        /// </summary>
        public static bool Contains(this string source, string value, StringComparison compareMode)
        {
            if (string.IsNullOrEmpty(source))
                return false;

            return source.IndexOf(value, compareMode) >= 0;
        }
开发者ID:pschaeflein,项目名称:Commerce-MOCK-API-DotNet,代码行数:10,代码来源:StringExtensionMethods.cs

示例7: ContainsAny

        /// <summary>
        ///     Checks if the string contains any of the values given.
        /// </summary>
        /// <exception cref="ArgumentNullException">The string can not be null.</exception>
        /// <exception cref="ArgumentNullException">The values can not be null.</exception>
        /// <param name="str">The string to check.</param>
        /// <param name="values">The values to search for.</param>
        /// <param name="comparisonType">The string comparison type.</param>
        /// <returns>Returns true if the string contains any of the values given, otherwise false.</returns>
        public static Boolean ContainsAny( this String str, StringComparison comparisonType, params String[] values )
        {
            str.ThrowIfNull( nameof( str ) );
            values.ThrowIfNull( nameof( values ) );

            return values.Any( x => str.IndexOf( x, comparisonType ) != -1 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:16,代码来源:String.ContainsAny.cs

示例8: Contains

        public static bool Contains(this string input, string value, StringComparison comparisonType)
        {
            if (input.DoesNotHaveValue())
                return false;

            return input.IndexOf(value, comparisonType) >= 0;
        }
开发者ID:bitdiff,项目名称:bdlib,代码行数:7,代码来源:StringExtensions.cs

示例9: StringLiteralSearchComparer

		public StringLiteralSearchComparer(string s, bool caseSensitive = false, bool matchWholeString = false) {
			if (s == null)
				throw new ArgumentNullException();
			this.str = s;
			this.stringComparison = caseSensitive ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase;
			this.matchWholeString = matchWholeString;
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:7,代码来源:FilterSearcher.cs

示例10: Contains

		/// <summary>
		/// Returns true if a string contains a substring, using the specified StringComparison.
		/// </summary>
		public static bool Contains (this string s, string value, StringComparison sc)
		{
			CompareOptions co;
			switch (sc) {
			case StringComparison.CurrentCulture:
				co = CompareOptions.None;
				break;

			case StringComparison.CurrentCultureIgnoreCase:
				co = CompareOptions.IgnoreCase;
				break;

			case StringComparison.InvariantCulture:
				co = CompareOptions.None;
				break;

			case StringComparison.InvariantCultureIgnoreCase:
				co = CompareOptions.IgnoreCase;
				break;

			case StringComparison.Ordinal:
				co = CompareOptions.Ordinal;
				break;

			case StringComparison.OrdinalIgnoreCase:
				co = CompareOptions.OrdinalIgnoreCase;
				break;

			default:
				throw new InvalidOperationException ("Unknown string comparison value.");
			}

			return s.Contains (value, sc.RelatedCulture (), co);
		}
开发者ID:corneliutusnea,项目名称:Akka.Visualizer,代码行数:37,代码来源:StringComparisonExtensions.cs

示例11: Validate

 /// <summary>
 /// Validates the specified <paramref name="value"/> and throws an <see cref="ArgumentException"/>
 /// exception if not valid.
 /// </summary>
 /// <param name="value">The value to validate.</param>
 /// <param name="parameterName">Name of the parameter to use if throwing exception.</param>
 public static void Validate(StringComparison value, string parameterName)
 {
     if (!IsDefined(value))
     {
         throw Error.InvalidEnumArgument(parameterName, (int)value, typeof(StringComparison));
     }
 }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:13,代码来源:StringComparisonHelper.cs

示例12: GetTrailsAndinjectValue

        public static IEnumerable<Queue<string>> GetTrailsAndinjectValue(PropertyWithComponent target, PropertyWithComponent source, Predicate<Type> f, Queue<string> root, StringComparison comparison)
        {
            if (string.Equals(target.Property.Name, source.Property.Name, comparison) && f(source.Property.PropertyType))
            {
                var queue = new Queue<string>();
                queue.Enqueue(source.Property.Name);
                source.Property.SetValue(target.Component, source.Property.GetValue(source.Component, null), null);
                yield return queue;
                yield break;
            }

            if (target.Property.Name.StartsWith(source.Property.Name, comparison))
            {
                root.Enqueue(source.Property.Name);
                foreach (var pro in source.Property.PropertyType.GetInfos())
                {
                    foreach (var trail in GetTrails(target.Property.Name.RemovePrefix(source.Property.Name, comparison), pro, f, root, comparison))
                    {
                        var queue = new Queue<string>();
                        queue.Enqueue(source.Property.Name);
                        foreach (var value in trail.Reverse())
                        {
                            queue.Enqueue(value);
                        }
                        yield return queue;
                    }
                }
            }
        }
开发者ID:jpomez,项目名称:ValueInjecter,代码行数:29,代码来源:TrailFinder.cs

示例13: GetTrails

        public static IEnumerable<Queue<string>> GetTrails(string upn, PropertyInfo prop, Predicate<Type> f, Queue<string> root, StringComparison comparison)
        {
            if (string.Equals(upn, prop.Name, comparison) && f(prop.PropertyType))
            {
                var queue = new Queue<string>();
                queue.Enqueue(prop.Name);
                yield return queue;
                yield break;
            }

            if (upn.StartsWith(prop.Name, comparison))
            {
                root.Enqueue(prop.Name);
                foreach (var pro in prop.PropertyType.GetInfos())
                {
                    foreach (var trail in GetTrails(upn.RemovePrefix(prop.Name, comparison), pro, f, root, comparison))
                    {
                        var queue = new Queue<string>();
                        queue.Enqueue(prop.Name);
                        foreach (var value in trail)
                        {
                            queue.Enqueue(value);
                        }
                        yield return queue;
                    }
                }
            }
        }
开发者ID:jpomez,项目名称:ValueInjecter,代码行数:28,代码来源:TrailFinder.cs

示例14: GetTrails

        public static IEnumerable<IList<string>> GetTrails(string upn, PropertyInfo prop, Func<string, PropertyInfo, bool> match, IList<string> root, StringComparison comparison, bool flat = true)
        {
            if (flat && !prop.CanRead || !flat && !prop.CanWrite)
            {
                yield return null;
                yield break;
            }

            if (match(upn, prop))
            {
                var l = new List<string> { prop.Name };
                yield return l;
                yield break;
            }

            if (upn.StartsWith(prop.Name, comparison))
            {
                root.Add(prop.Name);
                foreach (var pro in prop.PropertyType.GetProps())
                {
                    foreach (var trail in GetTrails(upn.RemovePrefix(prop.Name, comparison), pro, match, root, comparison, flat))
                    {
                        if (trail != null)
                        {
                            var r = new List<string> { prop.Name };
                            r.AddRange(trail);
                            yield return r;
                        }
                    }
                }
            }
        }
开发者ID:rossminnes,项目名称:ValueInjecter,代码行数:32,代码来源:TrailFinder.cs

示例15: AsciiEquivalentMatches

 private static Expression<Func<PlaceName, bool>> AsciiEquivalentMatches(string term, StringMatchStrategy matchStrategy, StringComparison? stringComparison = null)
 {
     Expression<Func<PlaceName, bool>> expression;
     switch (matchStrategy)
     {
         case StringMatchStrategy.Equals:
             if (stringComparison.HasValue)
                 expression = name => name.AsciiEquivalent.Equals(term, stringComparison.Value);
             else
                 expression = name => name.AsciiEquivalent.Equals(term);
             break;
         case StringMatchStrategy.StartsWith:
             if (stringComparison.HasValue)
                 expression = name => name.AsciiEquivalent.StartsWith(term, stringComparison.Value);
             else
                 expression = name => name.AsciiEquivalent.StartsWith(term);
             break;
         case StringMatchStrategy.Contains:
             if (stringComparison.HasValue)
                 expression = name => name.AsciiEquivalent.Contains(term, stringComparison.Value);
             else
                 expression = name => name.AsciiEquivalent.Contains(term);
             break;
         default:
             throw new NotSupportedException(string.Format("StringMatchStrategy '{0}' is not supported.", matchStrategy));
     }
     return AsciiEquivalentIsNotNull().And(expression).Expand();
 }
开发者ID:saibalghosh,项目名称:Layout3,代码行数:28,代码来源:QueryPlaceNames.cs


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