IndexOf() 공개 메소드

public IndexOf ( String source, String value ) : int
source String
value String
리턴 int
예제 #1
0
        private void LoXIVUpdateHandler(object sender, PropertyChangedEventArgs e)
        {
            var worker = sender as LoXIV;

            if (worker != null)
            {
                foreach (var log in worker.FFXIVlog)
                {
                    if (String.IsNullOrEmpty(Name) || String.IsNullOrEmpty(Prefix))
                    {
                        continue;
                    }

                    if (log.StartsWith(Name))
                    {
                        string prefix;
                        if (Prefix == "{{ss}}")
                        {
                            prefix = " ";
                        }
                        else
                        {
                            prefix = Prefix;
                        }

                        if (ci.IndexOf(log.Substring(Name.Length + 1), prefix, CompareOptions.IgnoreWidth) == 0)
                        {
                            var lorelei = new Lorelei(
                                "",
                                "",
                                "",
                                "");
                            try
                            {
                                lorelei.PostTweet(log.Substring(Name.Length + prefix.Length + 1));
                            }
                            catch { }
                        }
                    }
                }

                var dispatcher = Application.Current.Dispatcher;

                if (dispatcher.CheckAccess())
                {
                    LogList = worker.FFXIVlog;
                }
                else
                {
                    dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
                    {
                        LogList = worker.FFXIVlog;
                    }));
                }
            }
        }
예제 #2
0
	void AssertIndexOf (string message, int expected, string source,
		string target, int idx, int len, CompareOptions opt, CompareInfo ci)
	{
		Assert.AreEqual (expected, ci.IndexOf (source, target, idx, len, opt), message);
	}
예제 #3
0
        // Returns the index and length of the first or last occurance of one string 
        // within another string.
        private static int StandardMatchIndexCalculation(string textString, string findPattern, bool matchWholeWord, bool matchLast, bool ignoreCase, CompareInfo compareInfo, bool hasPreceedingSeparatorChar, bool hasFollowingSeparatorChar, out int matchLength) 
        {
            CompareOptions options = ignoreCase ? CompareOptions.IgnoreCase : 0;
            int matchIndex = -1;
            int searchStart = 0; 
            int searchLength = textString.Length;
 
            matchLength = 0; 

            while (searchLength > 0) 
            {
                matchIndex = matchLast ?
                             compareInfo.LastIndexOf(textString, findPattern, searchStart + searchLength - 1, searchLength, options) :
                             compareInfo.IndexOf(textString, findPattern, searchStart, searchLength, options); 

                matchLength = findPattern.Length; 
 
                if (matchIndex == -1)
                { 
                    break;
                }

                if (!matchWholeWord || IsAtWordBoundary(textString, matchIndex, matchLength, hasPreceedingSeparatorChar, hasFollowingSeparatorChar)) 
                {
                    break; 
                } 

                if (matchLast) 
                {
                    searchStart = 0;
                    searchLength = matchIndex + matchLength - 1;
                } 
                else
                { 
                    searchStart = matchIndex + 1; 
                    searchLength = textString.Length - searchStart;
                } 

                matchIndex = -1;
            }
 
            return matchIndex;
        } 
예제 #4
0
	void AssertIndexOf (string message, int expected, string source,
		char target, int idx, int len, CompareOptions opt, CompareInfo ci)
	{
		AssertEquals (message, expected,
			ci.IndexOf (source, target, idx, len, opt));
	}