Пример #1
0
        public static string Replace(this string s, string oldValue, string newValue, StringComparison comparisonType)
        {
            if (s == null)
            {
                return null;
            }

            if (string.IsNullOrEmpty(oldValue))
            {
                return s;
            }

            var result = new StringBuilder(Math.Min(4096, s.Length));
            var pos = 0;

            while (true)
            {
                var i = s.IndexOf(oldValue, pos, comparisonType);
                if (i < 0)
                {
                    break;
                }

                result.Append(s, pos, i - pos);
                result.Append(newValue);

                pos = i + oldValue.Length;
            }
            result.Append(s, pos, s.Length - pos);

            return result.ToString();
        }
        public static String Replace(this String s, String oldValue, String newValue, StringComparison comparisonType)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s");
            }
            if (oldValue == null)
            {
                throw new ArgumentNullException("oldValue");
            }
            if (oldValue.Equals(String.Empty))
            {
                throw new ArgumentException("String cannot be of zero length.", "oldValue");
            }

            StringBuilder sb = new StringBuilder();

            int previousIndex = 0;
            int index = s.IndexOf(oldValue, comparisonType);
            while (index != -1)
            {
                sb.Append(s.Substring(previousIndex, index - previousIndex));
                sb.Append(newValue);
                index += oldValue.Length;

                previousIndex = index;
                index = s.IndexOf(oldValue, index, comparisonType);
            }
            sb.Append(s.Substring(previousIndex));

            return sb.ToString();
        }
Пример #3
0
        /// <summary>Determines whether the specified value contains the specified substring.</summary>
        /// <param name="value">The value to check.</param>
        /// <param name="substring">The substring to find.</param>
        /// <param name="comparisonType">The type of comparison to perform.</param>
        /// <returns>If the specified value contains the specified substring, <c>true</c>; otherwise, <c>false</c>.</returns>
        public static bool Contains(this string value, string substring, StringComparison comparisonType)
        {
            if (value == null) throw new ArgumentNullException("value");
            if (substring == null) throw new ArgumentNullException("substring");

            return value.IndexOf(substring, comparisonType) >= 0;
        }
Пример #4
0
 public WildcardPathSegment(string beginsWith, List<string> contains, string endsWith, StringComparison comparisonType)
 {
     BeginsWith = beginsWith;
     Contains = contains;
     EndsWith = endsWith;
     _comparisonType = comparisonType;
 }
        public static bool Contains(this string input, string value, StringComparison comparisonType)
        {
            if (string.IsNullOrEmpty(input) == false)
                return input.IndexOf(value, comparisonType) != -1;

            return false;
        }
        /// <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;
        }
Пример #7
0
        static Message()
        {
            var sensitivity = System.Web.Configuration.WebConfigurationManager.AppSettings["CaseInsensitivePathSegment"];

            if (sensitivity != null && (sensitivity.Equals("no", StringComparison.OrdinalIgnoreCase) || sensitivity.Equals("false", StringComparison.OrdinalIgnoreCase)))
                comparison = StringComparison.Ordinal;
        }
Пример #8
0
        /// <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 );
        }
Пример #9
0
        public static string Replace(string original, string oldValue, string newValue, StringComparison comparisionType)
        {
            string result = original;

            if (!string.IsNullOrEmpty(newValue))
            {
                int index = -1;
                int lastIndex = 0;

                StringBuilder buffer = new StringBuilder(original.Length);

                while ((index = original.IndexOf(oldValue, index + 1, comparisionType)) >= 0)
                {
                    buffer.Append(original, lastIndex, index - lastIndex);
                    buffer.Append(newValue);

                    lastIndex = index + oldValue.Length;
                }
                buffer.Append(original, lastIndex, original.Length - lastIndex);

                result = buffer.ToString();
            }

            return result;
        }
Пример #10
0
        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;
                        }
                    }
                }
            }
        }
Пример #11
0
 private static Expression<Func<EstablishmentUrl, bool>> TextMatches(string term, StringMatchStrategy matchStrategy, StringComparison? stringComparison = null)
 {
     Expression<Func<EstablishmentUrl, bool>> expression;
     switch (matchStrategy)
     {
         case StringMatchStrategy.Equals:
             if (stringComparison.HasValue)
                 expression = url => url.Value.Equals(term, stringComparison.Value);
             else
                 expression = url => url.Value.Equals(term);
             break;
         case StringMatchStrategy.StartsWith:
             if (stringComparison.HasValue)
                 expression = url => url.Value.StartsWith(term, stringComparison.Value);
             else
                 expression = url => url.Value.StartsWith(term);
             break;
         case StringMatchStrategy.Contains:
             if (stringComparison.HasValue)
                 expression = url => url.Value.Contains(term, stringComparison.Value);
             else
                 expression = url => url.Value.Contains(term);
             break;
         default:
             throw new NotSupportedException(string.Format("StringMatchStrategy '{0}' is not supported.", matchStrategy));
     }
     return expression;
 }
Пример #12
0
        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;
        }
Пример #13
0
 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;
 }
        public static bool Contains(this string source, string toCheck, StringComparison comparison)
        {
            if (IsEmpty(source))
                return true;

            return source.IndexOf(toCheck, comparison) >= 0;
        } 
Пример #15
0
        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);
        }
Пример #16
0
        public static Param<string> IsEqualTo(this Param<string> param, string expected, StringComparison? comparison = null)
        {
           if (!StringEquals(param.Value, expected, comparison))
                throw ExceptionFactory.CreateForParamValidation(param, ExceptionMessages.EnsureExtensions_Is_Failed.Inject(param.Value, expected));

            return param;
        }
Пример #17
0
        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]);
                }
            }
        }
Пример #18
0
 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();
 }
Пример #19
0
        /// <summary>
        /// Verifies the constrained <see cref="string"/> is equal to the specified value using the specified
        /// <see cref="StringComparison"/>.
        /// </summary>
        /// <param name="self">The constrained value.</param>
        /// <param name="expected">The expected value.</param>
        /// <param name="comparisonType">The <see cref="StringComparison"/> to use to compare the values.</param>
        /// <param name="message">The message to display in case of failure.</param>
        /// <param name="parameters">The parameters used to format the <paramref name="message"/>.</param>
        /// <exception cref="Exception">The constraint failed. The exact type of exception thrown will
        /// depend on the unit test framework, if any, in use.</exception>
        public static void BeEqualTo(this IConstraint<string> self, string expected, StringComparison comparisonType, string message = null, params object[] parameters)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            if (string.Compare(expected, self.Value, comparisonType) != 0)
            {
                self.FailIfNotNegated(
                    self.FormatErrorMessage(
                        "BeEqualTo",
                        Messages.NotEqual(expected, self.Value),
                        message,
                        parameters));
            }
            else
            {
                self.FailIfNegated(
                    self.FormatErrorMessage(
                        "BeEqualTo",
                        Messages.Equal(expected, self.Value),
                        message,
                        parameters));
            }
        }
		public IgnoreCase(IgnoreCase? value)
		{
			if (value.HasValue)
				Value = value.Value;
			else
				Value = No.Value;
		}
        public static bool Contains(this string text, string value, StringComparison comparison)
        {
            if (text.IsNull())
                return false;

            return text.IndexOf(value, comparison) >= 0;
        }
Пример #22
0
        static StackObject *Equals_21(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.StringComparison @comparisonType = (System.StringComparison) typeof(System.StringComparison).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 20);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @b = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String @a = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = System.String.Equals(@a, @b, @comparisonType);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
        public static string TrimStringStartOrSelf(string str, string stringToTrim, StringComparison comparison)
        {
            if (stringToTrim == null || str == null)
                return str;

            return str.StartsWith(stringToTrim, comparison) ? str.Substring(stringToTrim.Length) : str;
        }
Пример #24
0
        /// <summary>
        /// Returns a captured wildcard segment from string. Pattern uses '*' for match capture by default and may contain a single capture
        /// </summary>
        public static string CapturePatternMatch(this string str,     //     Pages/Dima/Welcome
            string pattern,
            char wc ='*',
            StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase)
        {
            var i = pattern.IndexOf(wc);
               if (i<0) return string.Empty;

               var pleft = pattern.Substring(0, i);
               var pright = (i+1<pattern.Length)? pattern.Substring(i+1) : string.Empty;

               if (pleft.Length>0)
               {
             if (!str.StartsWith(pleft, comparisonType)) return string.Empty;
             str = str.Substring(pleft.Length);
               }

               if (pright.Length>0)
               {
             if (!str.EndsWith(pright, comparisonType)) return string.Empty;
             str = str.Substring(0, str.Length - pright.Length);
               }

               return str;
        }
        public NameEndsWithFilter(string value, StringComparison comparison = StringComparison.Ordinal)
        {
            value.ThrowIfNull("value");

            _value = value;
            _comparison = comparison;
        }
Пример #26
0
        public static bool Contains(this string input, string value, StringComparison comparisonType)
        {
            if (input.DoesNotHaveValue())
                return false;

            return input.IndexOf(value, comparisonType) >= 0;
        }
Пример #27
0
		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;
		}
 /// <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));
     }
 }
		/// <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);
		}
Пример #30
0
        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;
                    }
                }
            }
        }
Пример #31
0
        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;
                    }
                }
            }
        }
Пример #32
0
    private bool FilterTags(TreeModel model, TreeIter iter)
    {
        int    index = model.GetPath(iter).Indices[0];
        string tag   = (string)_tags[index];
        string query = entry2.Text;

        System.StringComparison comp = System.StringComparison.OrdinalIgnoreCase;
        return(tag.IndexOf(query, comp) > -1);
    }
Пример #33
0
 public FormatterBuilder MapRequestHeader(
     string headerName,
     string headerValue,
     System.StringComparison valueComparison,
     bool isValueSubstring,
     string mediaType)
 {
     _mappings.Add(new RequestHeaderMapping(headerName, headerValue, valueComparison, isValueSubstring, mediaType));
     return(this);
 }
Пример #34
0
        internal StringComparerAndComparison(StringComparer comparer, StringComparison comparison)
        {
            if (comparer == null)
            {
                throw new ArgumentNullException(nameof(comparer));
            }

            Comparer   = comparer;
            Comparison = comparison;
        }
Пример #35
0
        public static XElement GetRootSector()
        {
            _xDoc = _xDoc ?? XDocument.Load(Configs.DataFile);
            var appContext = MainActivity.AppContext;

            const System.StringComparison sc = StringComparison.OrdinalIgnoreCase;
            XElement region = _xDoc.Root.Elements("Region")
                              .FirstOrDefault(el => el.Element("Name").Value.Equals(appContext.Region, sc));

            return(EnsureSector(MainActivity.AppContext.Sector, region));
        }
Пример #36
0
 public static bool isImageFile(string filepath)
 {
     System.IO.FileInfo finfo = new System.IO.FileInfo(filepath);
     if (!finfo.Exists)
     {
         return(false);
     }
     System.StringComparison comp = System.StringComparison.OrdinalIgnoreCase;
     if (finfo.Extension.IndexOf("jpg", comp) > -1)
     {
         return(true);
     }
     if (finfo.Extension.IndexOf("png", comp) > -1)
     {
         return(true);
     }
     return(false);
 }
Пример #37
0
        public static CSVRow FindRow(CSVData i_Source, string i_ColumnName, string i_ValueMatch, bool caseSensitive, bool containsMatch, int recordStartIndex = 0)
        {
            var result = new CSVRow(i_Source, null, -1);

            if (recordStartIndex < 0)
            {
                recordStartIndex = 0;
            }
            System.StringComparison comparisonType = caseSensitive ? System.StringComparison.Ordinal : System.StringComparison.OrdinalIgnoreCase;
            var columnNames = i_Source.ColumnNames;
            int columnCount = columnNames.Length;

            for (int i = 0; i < columnCount; ++i)
            {
                bool columnMatch = string.Compare(columnNames[i], i_ColumnName, comparisonType) == 0;
                if (columnMatch)
                {
                    int recordCount = i_Source.ContentRowCount;
                    for (int j = recordStartIndex; j < recordCount; ++j)
                    {
                        string[] recordValues = i_Source.GetContentRow(j);
                        string   value        = recordValues[i];
                        bool     foundRecord  = false;
                        if (containsMatch)
                        {
                            foundRecord = value.IndexOf(i_ValueMatch, comparisonType) >= 0;
                        }
                        else
                        {
                            foundRecord = string.Compare(value, i_ValueMatch, comparisonType) == 0;
                        }
                        if (foundRecord)
                        {
                            result.Values = recordValues;
                            result.Index  = j;
                            break;
                        }
                    }
                    break;
                }
            }

            return(result);
        }
Пример #38
0
 static int Compare(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         System.Uri              arg0 = (System.Uri)ToLua.CheckObject <System.Uri>(L, 1);
         System.Uri              arg1 = (System.Uri)ToLua.CheckObject <System.Uri>(L, 2);
         System.UriComponents    arg2 = (System.UriComponents)ToLua.CheckObject(L, 3, typeof(System.UriComponents));
         System.UriFormat        arg3 = (System.UriFormat)ToLua.CheckObject(L, 4, typeof(System.UriFormat));
         System.StringComparison arg4 = (System.StringComparison)ToLua.CheckObject(L, 5, typeof(System.StringComparison));
         int o = System.Uri.Compare(arg0, arg1, arg2, arg3, arg4);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #39
0
        /* **********************************************************************************
         * Summary:     Record position of scrollbar. Unbind and rebind procList to the
         *              Listbox. Set old scrollbar position back so user doesn't get bumped
         *              back to the top of the list while they are scrolling.
         * Return:      void. Listbox control updates.
         ***********************************************************************************/
        private void ShowData()
        {
            // update the listbox UI when background worker reports progress
            procListView.Clear();
            System.StringComparison stringComparison = System.StringComparison.CurrentCulture;
            for (int i = 0; i < procList.Count; i++)
            {
                procListView.Add(new ProcView(procList[i]));
            }

            switch (sortState)
            {
            case SortedBy.NONE:
                break;

            case SortedBy.NAME:
                procListView.Sort((x, y) => string.Compare(x.Name, y.Name, stringComparison));
                break;

            case SortedBy.CPU:
                procListView.Sort((x, y) => y.CpuUsage.CompareTo(x.CpuUsage));
                break;

            case SortedBy.RAM:
                procListView.Sort((x, y) => y.RamUsage.CompareTo(x.RamUsage));
                break;
            }

            // record old position of scrollbar
            var offset = this.listBox1.TopIndex;

            this.listBox1.DataSource = null;
            TaskManagerLib.FilterByText(ref procListView, this.textBoxFilter.Text);
            this.listBox1.DataSource = procListView;

            // set scrollbar back to original offset so user can scroll while its updating
            // without the scrollbar going back up to the top
            this.listBox1.TopIndex = offset;
        }
Пример #40
0
        private void HighlightKeyWords(SearchParams config, List <SearchFile.KeywordMatch> matches, bool onlyVisible = false)
        {
            int firstIndex = 0;
            int lastIndex  = viewMatches.Text.Length;

            // highlight only visible area - performance
            if (onlyVisible)
            {
                Point pos = new Point(0, 0);
                firstIndex = viewMatches.GetCharIndexFromPosition(pos);

                pos.X = viewMatches.ClientRectangle.Width;
                pos.Y = viewMatches.ClientRectangle.Height;

                lastIndex = viewMatches.GetCharIndexFromPosition(pos);
            }

            int matchindex = 0;

            System.StringComparison compare = config.UseCaseSensitiveMatch ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;
            string viewContent = viewMatches.Text;

            int keywordIndex = viewContent.IndexOf(matches[matchindex].Match, firstIndex, compare);

            while (-1 != keywordIndex && keywordIndex < lastIndex)
            {
                viewMatches.Select(keywordIndex, matches[matchindex].Match.Length);
                viewMatches.SelectionColor = Color.Red;

                matchindex++;
                if (matchindex >= matches.Count)
                {
                    break;
                }

                keywordIndex = viewContent.IndexOf(matches[matchindex].Match, keywordIndex + matches[matchindex].Match.Length, compare);
            }
        }
Пример #41
0
        static StackObject *LastIndexOf_10(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.StringComparison @comparisonType = (System.StringComparison) typeof(System.StringComparison).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @value = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String instance_of_this_method = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.LastIndexOf(@value, @comparisonType);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
Пример #42
0
        public static string Replace(string template, string placeholder, string replacement, System.StringComparison comparisonType)
        {
            string result;

            if (template == null)
            {
                result = null;
            }
            else
            {
                int num = template.IndexOf(placeholder, comparisonType);
                if (num < 0)
                {
                    result = template;
                }
                else
                {
                    result = new System.Text.StringBuilder(template.Substring(0, num)).Append(replacement).Append(StringUtils.Replace(template.Substring(num + placeholder.Length), placeholder, replacement, comparisonType)).ToString();
                }
            }
            return(result);
        }
Пример #43
0
        private iTextSharp.text.Rectangle GetRectangleFromText(TextChunk FirstChunk, TextChunk LastChunk, string pSearchString,
                                                               string sTextinChunks, int iFromChar, int iToChar, System.StringComparison pStrComp)
        {
            float LineRealWidth = LastChunk.PosRight - FirstChunk.PosLeft;

            float LineTextWidth = GetStringWidth(sTextinChunks, LastChunk.curFontSize,
                                                 LastChunk.charSpaceWidth,
                                                 ThisPdfDocFonts.ElementAt(LastChunk.FontIndex).Value);

            float TransformationValue = LineRealWidth / LineTextWidth;

            int iStart = sTextinChunks.IndexOf(pSearchString, pStrComp);

            int iEnd = iStart + pSearchString.Length - 1;

            string sLeft;

            if (iStart == 0)
            {
                sLeft = null;
            }
            else
            {
                sLeft = sTextinChunks.Substring(0, iStart);
            }

            string sRight;

            if (iEnd == sTextinChunks.Length - 1)
            {
                sRight = null;
            }
            else
            {
                sRight = sTextinChunks.Substring(iEnd + 1, sTextinChunks.Length - iEnd - 1);
            }

            float LeftWidth = 0;

            if (iStart > 0)
            {
                LeftWidth = GetStringWidth(sLeft, LastChunk.curFontSize,
                                           LastChunk.charSpaceWidth,
                                           ThisPdfDocFonts.Values.ElementAt(LastChunk.FontIndex));
                LeftWidth = LeftWidth * TransformationValue;
            }

            float RightWidth = 0;

            if (iEnd < sTextinChunks.Length - 1)
            {
                RightWidth = GetStringWidth(sRight, LastChunk.curFontSize,
                                            LastChunk.charSpaceWidth,
                                            ThisPdfDocFonts.Values.ElementAt(LastChunk.FontIndex));
                RightWidth = RightWidth * TransformationValue;
            }

            float LeftOffset  = FirstChunk.distParallelStart + LeftWidth;
            float RightOffset = LastChunk.distParallelEnd - RightWidth;

            return(new iTextSharp.text.Rectangle(LeftOffset, FirstChunk.PosBottom, RightOffset, FirstChunk.PosTop));
        }
Пример #44
0
        public List <iTextSharp.text.Rectangle> GetTextLocations(string pSearchString, System.StringComparison pStrComp)
        {
            List <iTextSharp.text.Rectangle> FoundMatches = new List <iTextSharp.text.Rectangle>();
            StringBuilder    sb                = new StringBuilder();
            List <TextChunk> ThisLineChunks    = new List <TextChunk>();
            bool             bStart            = false;
            bool             bEnd              = false;
            TextChunk        FirstChunk        = null;
            TextChunk        LastChunk         = null;
            string           sTextInUsedChunks = null;

            foreach (var chunk in locationalResult)
            {
                if (ThisLineChunks.Count > 0 && !chunk.SameLine(ThisLineChunks.Last()))
                {
                    if (sb.ToString().IndexOf(pSearchString, pStrComp) > -1)
                    {
                        string sLine = sb.ToString();

                        int iCount = 0;
                        int lPos   = 0;
                        lPos = sLine.IndexOf(pSearchString, 0, pStrComp);
                        while (lPos > -1)
                        {
                            iCount++;
                            if (lPos + pSearchString.Length > sLine.Length)
                            {
                                break;
                            }
                            else
                            {
                                lPos = lPos + pSearchString.Length;
                            }
                            lPos = sLine.IndexOf(pSearchString, lPos, pStrComp);
                        }

                        int curPos = 0;
                        for (int i = 1; i <= iCount; i++)
                        {
                            string sCurrentText;
                            int    iFromChar;
                            int    iToChar;

                            iFromChar         = sLine.IndexOf(pSearchString, curPos, pStrComp);
                            curPos            = iFromChar;
                            iToChar           = iFromChar + pSearchString.Length - 1;
                            sCurrentText      = null;
                            sTextInUsedChunks = null;
                            FirstChunk        = null;
                            LastChunk         = null;

                            foreach (var chk in ThisLineChunks)
                            {
                                sCurrentText = sCurrentText + chk.text;

                                if (!bStart && sCurrentText.Length - 1 >= iFromChar)
                                {
                                    FirstChunk = chk;
                                    bStart     = true;
                                }

                                if (bStart && !bEnd)
                                {
                                    sTextInUsedChunks = sTextInUsedChunks + chk.text;
                                }

                                if (!bEnd && sCurrentText.Length - 1 >= iToChar)
                                {
                                    LastChunk = chk;
                                    bEnd      = true;
                                }
                                if (bStart && bEnd)
                                {
                                    FoundMatches.Add(GetRectangleFromText(FirstChunk, LastChunk, pSearchString, sTextInUsedChunks, iFromChar, iToChar, pStrComp));
                                    curPos = curPos + pSearchString.Length;
                                    bStart = false;
                                    bEnd   = false;
                                    break;
                                }
                            }
                        }
                    }
                    sb.Clear();
                    ThisLineChunks.Clear();
                }
                ThisLineChunks.Add(chunk);
                sb.Append(chunk.text);
            }
            return(FoundMatches);
        }
Пример #45
0
 public static bool Contains(string source, string value, System.StringComparison comparisonType)
 {
     return(source.IndexOf(value, comparisonType) >= 0);
 }
Пример #46
0
 public static bool Contains(this string source, string toCheck, System.StringComparison comp)
 {
     return(source?.IndexOf(toCheck, comp) >= 0);
 }
Пример #47
0
 public void Contains(string expectedSubstring, string actualString, System.StringComparison comparisonType)
 {
     Assert.Contains(expectedSubstring, actualString, comparisonType);
 }
Пример #48
0
 // Gets a hash code for this string and this comparison. If strings A and B and comparison C are such
 // that string.Equals(A, B, C), then they will return the same hash code with this comparison C.
 public int GetHashCode(StringComparison comparisonType) => StringComparer.FromComparison(comparisonType).GetHashCode(this);
Пример #49
0
        // Provides a culture-correct string comparison. strA is compared to strB
        // to determine whether it is lexicographically less, equal, or greater, and then a
        // negative integer, 0, or a positive integer is returned; respectively.
        // The case-sensitive option is set by ignoreCase
        //
        public static int Compare(string?strA, string?strB, bool ignoreCase)
        {
            StringComparison comparisonType = ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;

            return(Compare(strA, strB, comparisonType));
        }
Пример #50
0
 public CharComparer(StringComparison stringComparison)
 {
     this.stringComparison = stringComparison;
 }
        public void UpdatePoseEditor()
        {
            var result = new List <Transform>();

            System.StringComparison compType =
                caseSensitive ? System.StringComparison.CurrentCulture : System.StringComparison.CurrentCultureIgnoreCase;


            // first, find objects already has handle
            foreach (var o in GetComponentsInChildren <SelectionHandle>())
            {
                var t = o.transform;
                // ignore duplicate
                if (result.Contains(t))
                {
                    continue;
                }
                result.Add(t);
            }
            // second, add skinned mesh bones.
            foreach (var m in GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                foreach (var b in m.bones)
                {
                    // ignore duplicate
                    if (result.Contains(b))
                    {
                        continue;
                    }
                    result.Add(b);
                }
            }
            // third, add humanoid bones
            var fingerBoneList = new List <Transform>();

            foreach (var animator in GetComponentsInChildren <Animator>())
            {
                if (!animator.isHuman)
                {
                    continue;
                }

                foreach (var boneId in Enum.GetValues(typeof(HumanBodyBones)))
                {
                    if ((HumanBodyBones)boneId == HumanBodyBones.LastBone)
                    {
                        break;
                    }

                    var bone = animator.GetBoneTransform((HumanBodyBones)boneId);
                    if (null == bone || result.Contains(bone))
                    {
                        continue;
                    }
                    result.Add(bone);
                    //Debug.Log(bone);
                }

                // finger bones
                foreach (var fingerBoneId in new HumanBodyBones[] {
                    HumanBodyBones.LeftIndexProximal,
                    HumanBodyBones.LeftMiddleProximal,
                    HumanBodyBones.LeftRingProximal,
                    HumanBodyBones.LeftLittleProximal,
                    HumanBodyBones.LeftThumbProximal,
                    HumanBodyBones.RightIndexProximal,
                    HumanBodyBones.RightMiddleProximal,
                    HumanBodyBones.RightLittleProximal,
                    HumanBodyBones.RightRingProximal,
                    HumanBodyBones.RightThumbProximal,
                })
                {
                    var fingerBone = animator.GetBoneTransform(fingerBoneId);
                    if (null == fingerBone)
                    {
                        continue;
                    }

                    foreach (var t in fingerBone.GetComponentsInChildren <Transform>())
                    {
                        fingerBoneList.Add(t);
                    }
                }
            }



            // add handle to bones except for hidden/filtered children.
            var hiddenBones = new List <Transform>();

            foreach (var b in result)
            {
                // naming filter first
                if (!string.IsNullOrEmpty(nameFilter) && -1 == b.name.IndexOf(nameFilter, compType))
                {
                    hiddenBones.Add(b);
                }

                var handle = b.GetComponent <SelectionHandle>();
                if (null == handle)
                {
                    handle = b.gameObject.AddComponent <SelectionHandle>();
                    // finger handle scale
                    if (fingerBoneList.Contains(b))
                    {
                        handle.handleScale = fingerHandleScale;
                    }
                }
                handle.manager = this;

                // hide children
                if (handle.hideChildren)
                {
                    var children = handle.GetComponentsInChildren <SelectionHandle>(true);
                    // 0 is itself
                    //Debug.Log("I'm " + handle.name + " and index 0 is: " + children[0]);
                    for (var cidx = 1; cidx < children.Length; cidx++)
                    {
                        if (hiddenBones.Contains(children[cidx].transform))
                        {
                            continue;
                        }
                        hiddenBones.Add(children[cidx].transform);
                    }
                }
            }
            result.RemoveAll(b => hiddenBones.Contains(b));
            // reverse order to change drawing order to root->child
            result.Reverse();
            bones = result.ToArray();



            // find child bones
            childBones = new Transform[bones.Length][];
            for (var i = 0; i < bones.Length; i++)
            {
                // skip if hide children
                if (bones[i].GetComponent <SelectionHandle>().hideChildren)
                {
                    continue;
                }

                var children = bones[i].GetComponentsInChildren <SelectionHandle>(true);
                var found    = new List <Transform>();
                foreach (var c in children)
                {
                    if (c.transform == bones[i])
                    {
                        continue;
                    }

                    if (c.transform.parent == bones[i])
                    {
                        found.Add(c.transform);
                    }
                }
                if (0 == found.Count)
                {
                    childBones[i] = null;
                }
                else
                {
                    childBones[i] = found.ToArray();
                }
            }
        }
Пример #52
0
        private iTextSharp.text.Rectangle GetRectangleFromText(TextChunk FirstChunk, TextChunk LastChunk, string pSearchString, string sTextinChunks, int iFromChar, int iToChar, System.StringComparison pStrComp)
        {
            //There are cases where Chunk contains extra text at begining and end, we don't want this text locations, we need to extract the pSearchString location inside
            //for these cases we need to crop this String (left and Right), and measure this excedent at left and right, at this point we don't have any direct way to make a
            //Transformation from text space points to User Space units, the matrix for making this transformation is not accesible from here, so for these special cases when
            //the String needs to be cropped (Left/Right) We'll interpolate between the width from Text in Chunk (we have this value in User Space units), then i'll measure Text corresponding
            //to the same String but in Text Space units, finally from the relation betweeenthese 2 values I get the TransformationValue I need to use for all cases

            //Text Width in User Space Units
            float LineRealWidth = LastChunk.PosRight - FirstChunk.PosLeft;

            //Text Width in Text Units
            float LineTextWidth = GetStringWidth(sTextinChunks, LastChunk.curFontSize, LastChunk.charSpaceWidth, ThisPdfDocFonts.Values[LastChunk.FontIndex]);
            //TransformationValue value for Interpolation
            float TransformationValue = LineRealWidth / LineTextWidth;

            //In the worst case, we'll need to crop left and right:
            int iStart = sTextinChunks.IndexOf(pSearchString, pStrComp);

            int iEnd = iStart + pSearchString.Length - 1;

            string sLeft = null;

            if (iStart == 0)
            {
                sLeft = null;
            }
            else
            {
                sLeft = sTextinChunks.Substring(0, iStart);
            }

            string sRight = null;

            if (iEnd == sTextinChunks.Length - 1)
            {
                sRight = null;
            }
            else
            {
                sRight = sTextinChunks.Substring(iEnd + 1, sTextinChunks.Length - iEnd - 1);
            }

            //Measure cropped Text at left:
            float LeftWidth = 0;

            if (iStart > 0)
            {
                LeftWidth = GetStringWidth(sLeft, LastChunk.curFontSize, LastChunk.charSpaceWidth, ThisPdfDocFonts.Values[LastChunk.FontIndex]);
                LeftWidth = LeftWidth * TransformationValue;
            }

            //Measure cropped Text at right:
            float RightWidth = 0;

            if (iEnd < sTextinChunks.Length - 1)
            {
                RightWidth = GetStringWidth(sRight, LastChunk.curFontSize, LastChunk.charSpaceWidth, ThisPdfDocFonts.Values[LastChunk.FontIndex]);
                RightWidth = RightWidth * TransformationValue;
            }

            //LeftWidth is the text width at left we need to exclude, FirstChunk.distParallelStart is the distance to left margin, both together will give us this LeftOffset
            float LeftOffset = FirstChunk.distParallelStart + LeftWidth;
            //RightWidth is the text width at right we need to exclude, FirstChunk.distParallelEnd is the distance to right margin, we substract RightWidth from distParallelEnd to get RightOffset
            float RightOffset = LastChunk.distParallelEnd - RightWidth;

            //Return this Rectangle
            return(new iTextSharp.text.Rectangle(LeftOffset, FirstChunk.PosBottom, RightOffset, FirstChunk.PosTop));
        }
Пример #53
0
        public List <iTextSharp.text.Rectangle> GetTextLocations(string pSearchString, System.StringComparison pStrComp)
        {
            List <iTextSharp.text.Rectangle> FoundMatches = new List <iTextSharp.text.Rectangle>();
            StringBuilder    sb                = new StringBuilder();
            List <TextChunk> ThisLineChunks    = new List <TextChunk>();
            bool             bStart            = false;
            bool             bEnd              = false;
            TextChunk        FirstChunk        = null;
            TextChunk        LastChunk         = null;
            string           sTextInUsedChunks = null;

            foreach (TextChunk chunk in locationalResult)
            {
                if (ThisLineChunks.Count > 0 && !chunk.SameLine(ThisLineChunks[ThisLineChunks.Count - 1]))
                {
                    if (sb.ToString().IndexOf(pSearchString, pStrComp) > -1)
                    {
                        string sLine = sb.ToString();

                        //Check how many times the Search String is present in this line:
                        int iCount = 0;
                        int lPos   = 0;
                        lPos = sLine.IndexOf(pSearchString, 0, pStrComp);
                        while (lPos > -1)
                        {
                            iCount += 1;
                            if (lPos + pSearchString.Length > sLine.Length)
                            {
                                break;                                 // TODO: might not be correct. Was : Exit Do
                            }
                            else
                            {
                                lPos = lPos + pSearchString.Length;
                            }
                            lPos = sLine.IndexOf(pSearchString, lPos, pStrComp);
                        }

                        //Process each match found in this Text line:
                        int curPos = 0;
                        for (int i = 1; i <= iCount; i++)
                        {
                            string sCurrentText = null;
                            int    iFromChar    = 0;
                            int    iToChar      = 0;

                            iFromChar         = sLine.IndexOf(pSearchString, curPos, pStrComp);
                            curPos            = iFromChar;
                            iToChar           = iFromChar + pSearchString.Length - 1;
                            sCurrentText      = null;
                            sTextInUsedChunks = null;
                            FirstChunk        = null;
                            LastChunk         = null;

                            //Get first and last Chunks corresponding to this match found, from all Chunks in this line
                            foreach (TextChunk chk in ThisLineChunks)
                            {
                                sCurrentText = sCurrentText + chk.text;

                                //Check if we entered the part where we had found a matching String then get this Chunk (First Chunk)
                                if (!bStart && sCurrentText.Length - 1 >= iFromChar)
                                {
                                    FirstChunk = chk;
                                    bStart     = true;
                                }

                                //Keep getting Text from Chunks while we are in the part where the matching String had been found
                                if (bStart & !bEnd)
                                {
                                    sTextInUsedChunks = sTextInUsedChunks + chk.text;
                                }

                                //If we get out the matching String part then get this Chunk (last Chunk)
                                if (!bEnd && sCurrentText.Length - 1 >= iToChar)
                                {
                                    LastChunk = chk;
                                    bEnd      = true;
                                }

                                //If we already have first and last Chunks enclosing the Text where our String pSearchString has been found
                                //then it's time to get the rectangle, GetRectangleFromText Function below this Function, there we extract the pSearchString locations
                                if (bStart & bEnd)
                                {
                                    FoundMatches.Add(GetRectangleFromText(FirstChunk, LastChunk, pSearchString, sTextInUsedChunks, iFromChar, iToChar, pStrComp));
                                    curPos = curPos + pSearchString.Length;
                                    bStart = false;
                                    bEnd   = false;
                                    break;                                     // TODO: might not be correct. Was : Exit For
                                }
                            }
                        }
                    }
                    sb.Clear();
                    ThisLineChunks.Clear();
                }
                ThisLineChunks.Add(chunk);
                sb.Append(chunk.text);
            }

            return(FoundMatches);
        }
Пример #54
0
    /// <summary>
    /// System.Reflection.Assembly editorAssembly = System.Reflection.Assembly.GetAssembly(typeof(EditorWindow));
    /// GetTypeFromAssembly("AnimationWindow", editorAssembly);
    /// </summary>
    /// <returns></returns>
    private static System.Type GetTypeFromAssembly(string typeName, System.Reflection.Assembly assembly, System.StringComparison ignoreCase = StringComparison.CurrentCultureIgnoreCase, bool showNames = false)
    {
        if (assembly == null)
        {
            return(null);
        }

        System.Type[] types = assembly.GetTypes();
        foreach (System.Type type in types)
        {
            if (showNames)
            {
                Debug.Log(type.Name);
            }
            if (type.Name.Equals(typeName, ignoreCase) || type.Name.Contains('+' + typeName))
            {
                return(type);
            }
        }
        return(null);
    }
Пример #55
0
        public static int Compare(string?strA, int indexA, string?strB, int indexB, int length, StringComparison comparisonType)
        {
            CheckStringComparison(comparisonType);

            if (strA == null || strB == null)
            {
                if (object.ReferenceEquals(strA, strB))
                {
                    // They're both null
                    return(0);
                }

                return(strA == null ? -1 : 1);
            }

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength);
            }

            if (indexA < 0 || indexB < 0)
            {
                string paramName = indexA < 0 ? nameof(indexA) : nameof(indexB);
                throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index);
            }

            if (strA.Length - indexA < 0 || strB.Length - indexB < 0)
            {
                string paramName = strA.Length - indexA < 0 ? nameof(indexA) : nameof(indexB);
                throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index);
            }

            if (length == 0 || (object.ReferenceEquals(strA, strB) && indexA == indexB))
            {
                return(0);
            }

            int lengthA = Math.Min(length, strA.Length - indexA);
            int lengthB = Math.Min(length, strB.Length - indexB);

            switch (comparisonType)
            {
            case StringComparison.CurrentCulture:
            case StringComparison.CurrentCultureIgnoreCase:
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, GetCaseCompareOfComparisonCulture(comparisonType)));

            case StringComparison.InvariantCulture:
            case StringComparison.InvariantCultureIgnoreCase:
                return(CompareInfo.Invariant.Compare(strA, indexA, lengthA, strB, indexB, lengthB, GetCaseCompareOfComparisonCulture(comparisonType)));

            case StringComparison.Ordinal:
                return(CompareOrdinalHelper(strA, indexA, lengthA, strB, indexB, lengthB));

            default:
                Debug.Assert(comparisonType == StringComparison.OrdinalIgnoreCase);     // CheckStringComparison validated these earlier
                return(CompareInfo.CompareOrdinalIgnoreCase(strA, indexA, lengthA, strB, indexB, lengthB));
            }
        }
Пример #56
0
 public FluentAsserter EndsWith(string expectedEndString, string actualString, System.StringComparison comparisonType)
 {
     Assert.EndsWith(expectedEndString, actualString, comparisonType);
     return(this);
 }
Пример #57
0
 public static bool Equals(string str1, string str2, System.StringComparison comparison = System.StringComparison.Ordinal)
 {
     return(str1.Equals(str2, comparison));
 }
Пример #58
0
 public void EndsWith(string expectedEndString, string actualString, System.StringComparison comparisonType)
 {
     Assert.EndsWith(expectedEndString, actualString, comparisonType);
 }
Пример #59
0
        /// <summary>
        /// Determines whether the beginning of this string instance matches the specified string ignoring white spaces at the start.
        /// </summary>
        /// <param name="source">source string.</param>
        /// <param name="value">The string to compare.</param>
        /// <param name="comparisonType">string comparison type.</param>
        /// <returns></returns>
        public static bool StartsWithIgnoringWhiteSpaces(string source, string value, System.StringComparison comparisonType)
        {
            if (value == null)
            {
                return(false);
            }
            // find lower bound
            int i  = 0;
            int sz = source.Length;

            while (i < sz && char.IsWhiteSpace(source[i]))
            {
                i++;
            }
            // adjust upper bound
            sz = sz - i;
            if (sz < value.Length)
            {
                return(false);
            }
            sz = value.Length;
            // search
            return(source.IndexOf(value, i, sz, comparisonType) == i);
        }
Пример #60
0
 public FluentAsserter DoesNotContain(string expectedSubstring, string actualString, System.StringComparison comparisonType)
 {
     Assert.DoesNotContain(expectedSubstring, actualString, comparisonType);
     return(this);
 }