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


C# StringCollection.IndexOf方法代码示例

本文整理汇总了C#中System.Collections.Specialized.StringCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.IndexOf方法的具体用法?C# StringCollection.IndexOf怎么用?C# StringCollection.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.StringCollection的用法示例。


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

示例1: EvaluatePath

    /// <summary>
    /// Evaulate the path string in relation to the current item
    /// </summary>
    /// <param name="context">The Revolver context to evaluate the path against</param>
    /// <param name="path">The path to evaulate. Can either be absolute or relative</param>
    /// <returns>The full sitecore path to the target item</returns>
    public static string EvaluatePath(Context context, string path)
    {
      if (ID.IsID(path))
        return path;

      string workingPath = string.Empty;
      if (!path.StartsWith("/"))
        workingPath = context.CurrentItem.Paths.FullPath + "/" + path;
      else
        workingPath = path;

      // Strip any language and version tags
      if (workingPath.IndexOf(':') >= 0)
        workingPath = workingPath.Substring(0, workingPath.IndexOf(':'));

      // Make relative paths absolute
      string[] parts = workingPath.Split('/');
      StringCollection targetParts = new StringCollection();
      targetParts.AddRange(parts);

      while (targetParts.Contains(".."))
      {
        int ind = targetParts.IndexOf("..");
        targetParts.RemoveAt(ind);
        if (ind > 0)
        {
          targetParts.RemoveAt(ind - 1);
        }
      }

      if (targetParts[targetParts.Count - 1] == ".")
        targetParts.RemoveAt(targetParts.Count - 1);

      // Remove empty elements
      while (targetParts.Contains(""))
      {
        targetParts.RemoveAt(targetParts.IndexOf(""));
      }

      string[] toRet = new string[targetParts.Count];
      targetParts.CopyTo(toRet, 0);
      return "/" + string.Join("/", toRet);
    }
开发者ID:KerwinMa,项目名称:revolver,代码行数:49,代码来源:PathParser.cs

示例2: GetValue

        /// <summary>
        /// get a value from a row, position given by AColumnNames
        /// </summary>
        protected static string GetValue(StringCollection AColumnNames,
            string[] ACurrentRow,
            string AColumnName)
        {
            int index = AColumnNames.IndexOf(AColumnName);

            if (index == -1)
            {
                throw new Exception("TFixData.GetValue: Problem with unknown column name " + AColumnName);
            }

            return ACurrentRow[index];
        }
开发者ID:js1987,项目名称:openpetragit,代码行数:16,代码来源:FixData.cs

示例3: SetValue

        /// <summary>
        /// set a value of a row, position given by AColumnNames
        /// </summary>
        protected static void SetValue(StringCollection AColumnNames,
            ref string[] ACurrentRow,
            string AColumnName,
            string ANewValue)
        {
            int index = AColumnNames.IndexOf(AColumnName);

            if (index == -1)
            {
                throw new Exception("TFixData.SetValue: Problem with unknown column name " + AColumnName);
            }

            ACurrentRow[index] = ANewValue;
        }
开发者ID:js1987,项目名称:openpetragit,代码行数:17,代码来源:FixData.cs

示例4: PickListForm

        public PickListForm(string strTitle, string strCurrent, StringCollection strc)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            listBox1.DataSource = strc;
            listBox1.SelectedIndex = strCurrent == "" ? -1 : strc.IndexOf(strCurrent);
            Text = strTitle;
            label1.Text = label1.Text.Replace("$1", strTitle);
        }
开发者ID:RusselRains,项目名称:hostile-takeover,代码行数:15,代码来源:PickListForm.cs

示例5: Settings

        public Settings()
        {
            InitializeComponent();
            Closing += PreventTermination;
            planetList = Properties.Settings.Default.planets;
            System.Collections.IEnumerator se = Constraints.PLANETS.GetEnumerator();
            while (se.MoveNext())
            {
                string pl = (string)se.Current;
                CheckBox tmp = new CheckBox();
                tmp.Checked += delegate(object s, RoutedEventArgs e)
                {
                    if(planetList.IndexOf(pl) == -1) planetList.Add(pl);
                };
                tmp.Unchecked += delegate(object s, RoutedEventArgs e)
                {
                    if(planetList.IndexOf(pl) > -1) planetList.Remove(pl);
                };
                tmp.IsChecked = planetList.IndexOf(pl) > -1;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Children.Add(tmp);
                Label lbl = new Label();
                lbl.Content = pl;
                sp.Children.Add(lbl);
                planets.Children.Add(sp);
            }

            closetaskbar.IsChecked = Properties.Settings.Default.closeToTaskbar;
            mintaskbar.IsChecked = Properties.Settings.Default.minimizeToTaskbar;
            notify.IsChecked = Properties.Settings.Default.notify;
            hasrewards.IsChecked = Properties.Settings.Default.hasRewards;
            reward.Text = Properties.Settings.Default.rewardContains.ToLower();
            credits.Text = Properties.Settings.Default.credits.ToString();
            usefilter.IsChecked = Properties.Settings.Default.useFilter;
        }
开发者ID:naomichan,项目名称:Warmon,代码行数:36,代码来源:Settings.xaml.cs

示例6: ParseFileSection

        public int ParseFileSection(StringCollection sec, PySection section, int begin, int end)
        {
            // sec collection, doesn't contain # --- begin / # --- end
            int count = begin;

            for (int j=begin; j<end; j++)
            {
                string item = sec[j];
                if (item.Contains("# begin"))
                {
                    // here's we have a new section
                    string trimstr = item.Trim();
                    string nn = trimstr.Substring(7);
                    section.Children.Add(new PySection(nn.Trim()));
                    PySection child = (PySection)section.Children[section.Children.Count - 1];
                    child.Begin = count;
                    // find the end...
                    string ends = item.Replace("begin", "end");
                    int end_idx = sec.IndexOf(ends);
                    if ((end_idx >= begin) || (end_idx <= end))
                    {
                        child.Size = end_idx - child.Begin - 1;
                        ParseFileSection(sec, child, count + 1, end_idx);
                        j = end_idx;
                        count = end_idx;
                    } else {
                        // Not found error...
                    }
                } else if (item.Contains("# end"))
                {
                    // DO NOTHING
                } else
                {
                    section.Lines.Add(item);
                }
                count++;
            }
            return count;
        }
开发者ID:miquik,项目名称:mkdb,代码行数:39,代码来源:PyParser.cs

示例7: SavePdb

        void SavePdb(string strPdbFile)
        {
            // Make a list of unique sound files

            PdbPacker pdbp = new PdbPacker();
            int cSfx = m_alsNames.Count;
            StringCollection strcUniqueSounds = new StringCollection();
            ArrayList alsPcm = new ArrayList();
            for (int iSfx = 0; iSfx < cSfx; iSfx++) {
                if (!listViewSfx.Items[iSfx].Checked)
                    continue;
                if (!(bool)m_alsSfxEnabled[iSfx])
                    continue;
                string strFile = listViewSfx.Items[iSfx].SubItems[1].Text;
                if (strFile == null)
                    continue;
                strFile.Trim();
                if (strFile.Length == 0)
                    continue;
                int istr = strcUniqueSounds.IndexOf(strFile);
                if (istr == -1)
                    istr = strcUniqueSounds.Add(strFile);
            }

            // Serialize names out

            ArrayList alsStringOffsets = new ArrayList();
            BinaryWriter bwtr = new BinaryWriter(new MemoryStream());
            bwtr.Write(Misc.SwapUShort((ushort)strcUniqueSounds.Count));
            for (int iSound = 0; iSound < strcUniqueSounds.Count; iSound++) {
                alsStringOffsets.Add(bwtr.BaseStream.Position);
                string strFile = Path.ChangeExtension(strcUniqueSounds[iSound], ".snd");
                char[] sz = strFile.ToCharArray();
                bwtr.Write(sz);
                bwtr.Write((byte)0);
            }
            byte[] abSoundFiles = new byte[bwtr.BaseStream.Length];
            bwtr.BaseStream.Seek(0, SeekOrigin.Begin);
            bwtr.BaseStream.Read(abSoundFiles, 0, (int)bwtr.BaseStream.Length);
            bwtr.Close();

            // soundfiles file

            PdbPacker.File fileSounds = new PdbPacker.File("soundfiles", abSoundFiles);
            pdbp.Add(fileSounds);

            // Now serialize the sfx entries in the order of the names

            bwtr = new BinaryWriter(new MemoryStream());
            for (int iName = 0; iName < m_alsNames.Count; iName++) {
                // Need to find the entry in listViewSfx for this name since the persist
                // order needs to match soundeffects.h.

                string strName = ((StringCollection)m_alsNames[iName])[0];
                int iSfx;
                bool fFound = false;
                for (iSfx = 0; iSfx < cSfx; iSfx++) {
                    if (strName == listViewSfx.Items[iSfx].SubItems[0].Text) {
                        fFound = true;
                        break;
                    }
                }
                if (!fFound)
                    throw new Exception("Internal error");

                string strFile = listViewSfx.Items[iSfx].SubItems[1].Text;
                if (!listViewSfx.Items[iSfx].Checked)
                    strFile = null;
                if (!(bool)m_alsSfxEnabled[iSfx])
                    strFile = null;
                if (strFile == null) {
                    bwtr.Write((byte)0xff);
                } else {
                    strFile.Trim();
                    if (strFile.Length == 0) {
                        bwtr.Write((byte)0xff);
                    } else {
                        bwtr.Write((byte)strcUniqueSounds.IndexOf(strFile));
                    }
                }
                bwtr.Write((byte)0); // bwtr.Write(byte.Parse(listViewSfx.Items[iSfx].SubItems[2].Text));
                int nPriority = m_strcPriorities.IndexOf(listViewSfx.Items[iSfx].SubItems[3].Text);
                if (nPriority < 0) {
                    MessageBox.Show("Warning: " + listViewSfx.Items[iSfx].SubItems[0].Text + " has an unfamiliar priority.");
                }
                bwtr.Write((byte)nPriority);
            }
            byte[] abSfxEntries = new byte[bwtr.BaseStream.Length];
            bwtr.BaseStream.Seek(0, SeekOrigin.Begin);
            bwtr.BaseStream.Read(abSfxEntries, 0, (int)bwtr.BaseStream.Length);
            bwtr.Close();

            PdbPacker.File fileSfxEntries = new PdbPacker.File("SfxEntries", abSfxEntries);
            pdbp.Add(fileSfxEntries);

            // Now add in all the sounds

            for (int istrFile = 0; istrFile < strcUniqueSounds.Count; istrFile++) {
                string strFile = Path.GetFullPath(textBoxSoundsDir.Text) + "\\" + strcUniqueSounds[istrFile];
                Pcm pcm = new Pcm(strFile);
//.........这里部分代码省略.........
开发者ID:RusselRains,项目名称:hostile-takeover,代码行数:101,代码来源:Form1.cs

示例8: controlMatchingBetweenDataAndProfile

        public StringCollection controlMatchingBetweenDataAndProfile(String dataFile, String profileFile)
        {
            StringCollection errors = new StringCollection();
            CsvArchiveDocuments ad = new CsvArchiveDocuments();
            if (traceActions)
                ad.setTracesWriter(tracesWriter);
            ad.loadFile(dataFile);
            /*
            StringCollection erreursDonnees = ad.getErrorsList();
            if (erreursDonnees.Count != 0) {
                foreach (String st in erreursDonnees) {
                    errors.Add(st);
                }
            }
            */
            RngProfileController rpc = new RngProfileController();
            if (traceActions)
                rpc.setTracesWriter(tracesWriter);
            rpc.controlProfileFile(profileFile);
            /*
            StringCollection erreursProfil = rpc.getErrorsList();
            if (erreursProfil.Count != 0) {
                foreach (String st in erreursProfil) {
                    errors.Add(st);
                }
            }
            */
            String str;
            StringCollection tagsForKeys = ad.getTagsListForKeys();
            StringCollection tagsForDocs = ad.getTagsListForDocuments();
            StringCollection expectedTags = rpc.getExpectedTagsListList();

            StringCollection expectedTagsForDocs = new StringCollection();
            foreach (String st in expectedTags) {
                if (st.StartsWith("document: ")) {
                    expectedTagsForDocs.Add(st.Substring(10));
                }
            }
            foreach (String st in expectedTagsForDocs) {
                expectedTags.Remove("document: " + st);
            }

            StringCollection tagsForKeysModified = new StringCollection();
            foreach (String st in tagsForKeys) {
                str = Regex.Replace(st, @"#KeywordContent\[#[0-9]+\]", "#KeywordContent");
                tagsForKeysModified.Add(str);
            }

            StringCollection tagsForDocsModified = new StringCollection();
            foreach (String st in tagsForDocs) {
                str = Regex.Replace(st, @"#KeywordContent(\[[^]]+\])?\[#[0-9]+\]", "#KeywordContent$1");
                tagsForDocsModified.Add(str);
            }

            if (traceActions) {
                if (tagsForKeysModified.Count != 0) {
                    tracesWriter.WriteLine("\ntagsForKeysModified");
                    foreach (String st in tagsForKeysModified) {
                        tracesWriter.WriteLine(st);
                    }
                }
                if (tagsForDocsModified.Count != 0) {
                    tracesWriter.WriteLine("\ntagsForDocsModified");
                    foreach (String st in tagsForDocsModified) {
                        tracesWriter.WriteLine(st);
                    }
                }
                if (expectedTags.Count != 0) {
                    tracesWriter.WriteLine("\nexpectedTags");
                    foreach (String st in expectedTags) {
                        tracesWriter.WriteLine(st);
                    }
                }
                if (expectedTagsForDocs.Count != 0) {
                    tracesWriter.WriteLine("\nexpectedTagsForDocs");
                    foreach (String st in expectedTagsForDocs) {
                        tracesWriter.WriteLine(st);
                    }
                }
                tracesWriter.WriteLine("");
            }

            // Test des clés
            foreach (String st in tagsForKeysModified) {
                str = Regex.Replace(st, @"\[#\d+\]", "[#1]");
                str = Regex.Replace(str, @"#KeywordContent\[#[0-9]+\]", "#KeywordContent");
                if (expectedTags.IndexOf(str) == -1)
                    errors.Add("La clé '" + st + "' fournie par les données métier n'est pas attendue par le profil");
            }

            // Test des documents
            foreach (String st in tagsForDocsModified) {
                str = Regex.Replace(st, @"\[#\d+\]", "[#1]");
                str = Regex.Replace(str, @"#KeywordContent(\[[^]]+\])?\[#[0-9]+\]", "#KeywordContent$1");
                if (expectedTagsForDocs.IndexOf(str) == -1)
                    errors.Add("Le document typé par le tag '" + st + "' n'est pas attendu par le profil");
            }

            // Test du profil
            foreach (String st in expectedTags) {
//.........这里部分代码省略.........
开发者ID:PatPercot,项目名称:Seda-Generator,代码行数:101,代码来源:BusinessDataController.cs

示例9: TryFindAndRemoveWord

        /// <summary>
        /// Tries to find and remove a word from the word list.
        /// </summary>
        /// <param name="wordList">The word list.</param>
        /// <param name="word">The word to find and remove.</param>
        /// <returns>Whether or not the word was found and removed.</returns>
        private static bool TryFindAndRemoveWord(StringCollection wordList, string word)
        {
            bool removed = false;

            int wordIndex = wordList.IndexOf(word);
            if (wordIndex >= 0)
            {
                wordList.RemoveAt(wordIndex);
                removed = true;
            }

            return removed;
        }
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:19,代码来源:CSharpParser.cs

示例10: Test01

        public void Test01()
        {
            IntlStrings intl;
            StringCollection sc;
            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aa",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            int cnt = 0;            // Count
            // initialize IntStrings
            intl = new IntlStrings();


            // [] StringCollection is constructed as expected
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // [] Remove() from empty collection
            //
            for (int i = 0; i < values.Length; i++)
            {
                sc.Remove(values[i]);
                if (sc.Count != 0)
                {
                    Assert.False(true, string.Format("Error, Remove changed Count for empty collection", i));
                }
            }


            // [] Remove() from collection filled with simple strings
            //

            sc.Clear();
            sc.AddRange(values);
            if (sc.Count != values.Length)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
            }

            for (int i = 0; i < values.Length; i++)
            {
                // verify that collection contains all added items
                //
                if (!sc.Contains(values[i]))
                {
                    Assert.False(true, string.Format("Error, doesn't contain {0} item", i));
                }

                cnt = sc.Count;

                // Remove each item
                //
                sc.Remove(values[i]);

                if (sc.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, didn't remove anything", i));
                }

                if (sc.Contains(values[i]))
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }

            //
            // Intl strings
            // [] Remove() from collection filled with Intl strings
            //

            string[] intlValues = new string[values.Length];

            // fill array with unique strings
            //
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }

            int len = values.Length;
            Boolean caseInsensitive = false;
            for (int i = 0; i < len; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:RemoveStrTests.cs

示例11: ValueExists

 public bool ValueExists(string Section, string Ident)
 {
     StringCollection Idents = new StringCollection();
     ReadSection(Section, Idents);
     return Idents.IndexOf(Ident) > -1;
 }
开发者ID:Mradxz,项目名称:XLoader,代码行数:6,代码来源:IniFileOp.cs

示例12: Test01

        public void Test01()
        {
            IntlStrings intl;
            StringCollection sc;
            string itm;         // returned value of Item
            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aa",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            intl = new IntlStrings();


            // [] StringCollection Item is returned as expected
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // exception expected
            // all indexes should be invalid for empty collection

            //
            // [] Invalid parameter - set Item() on empty collection
            //
            itm = intl.GetRandomString(MAX_LEN);
            Assert.Throws<ArgumentOutOfRangeException>(() => { sc[-1] = itm; });
            Assert.Throws<ArgumentOutOfRangeException>(() => { sc[0] = itm; });
            Assert.Throws<ArgumentOutOfRangeException>(() => { sc[0] = null; });

            // [] set Item() on collection filled with simple strings
            //

            sc.Clear();
            sc.AddRange(values);
            int cnt = values.Length;
            if (sc.Count != cnt)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, cnt));
            }
            for (int i = 0; i < cnt; i++)
            {
                sc[i] = values[cnt - i - 1];
                if (String.Compare(sc[i], values[cnt - i - 1]) != 0)
                {
                    Assert.False(true, string.Format("Error, value is {1} instead of {2}", i, sc[i], values[cnt - i - 1]));
                }
            }


            //
            // Intl strings
            // [] set Item() on collection filled with Intl strings
            //

            string[] intlValues = new string[values.Length];

            // fill array with unique strings
            //
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }


            int len = values.Length;
            Boolean caseInsensitive = false;
            for (int i = 0; i < len; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                    caseInsensitive = true;
            }



            sc.Clear();
            cnt = intlValues.Length;
            sc.AddRange(intlValues);
            if (sc.Count != intlValues.Length)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, intlValues.Length));
            }

            for (int i = cnt; i < cnt; i++)
            {
                sc[i] = intlValues[cnt - i - 1];
                if (String.Compare(sc[i], intlValues[cnt - i - 1]) != 0)
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:SetItemTests.cs

示例13: extractUrlFromSwfHtml

        protected string extractUrlFromSwfHtml(string swfHtml)
        {
            try
            {
                StringCollection videoURLsBrut = new StringCollection();
                StringCollection videoURLs = new StringCollection();
                String[] separateur = new String[1];
                StringCollection paramNames;
                separateur[0] = Settings.Default.separateurUrlYoutube;
                int index = -1;

                swfHtml = swfHtml.Substring(swfHtml.IndexOf(Settings.Default.debutUrlYoutube) + Settings.Default.debutUrlYoutube.Length);
                swfHtml = swfHtml.Substring(swfHtml.IndexOf(separateur[0]) + separateur[0].Length);
                swfHtml = swfHtml.Substring(0, swfHtml.IndexOf(Settings.Default.finSwfHtmlRelevant));
                paramNames = GetAllParamNames(swfHtml);

                videoURLsBrut.AddRange(swfHtml.Split(separateur, StringSplitOptions.RemoveEmptyEntries));

                foreach (String chaine in videoURLsBrut)
                {
                    if (chaine.StartsWith("http"))
                    {
                        String videoUrl = chaine.Trim();
                        separateur[0] = ",";
                        videoUrl = RemoveExtraParams(videoUrl, Settings.Default.paramNamesToRemoveYoutube.Split(separateur, StringSplitOptions.RemoveEmptyEntries));
                        int indexLastComa = chaine.LastIndexOf(",");
                        if (indexLastComa == videoUrl.Length - 1)
                            videoUrl = videoUrl.Substring(0, indexLastComa);

                        videoURLs.Add(videoUrl);
                    }
                }

                int currentTagPriorite = 998;
                foreach (String url in videoURLs)
                {
                    int itagIndex = url.IndexOf(Settings.Default.itagParam);
                    if (itagIndex != -1)
                    {
                        itagIndex += Settings.Default.itagParam.Length;
                        int indexSeparator = url.IndexOf(Settings.Default.paramSeparator, itagIndex);
                        String itagString = url.Substring(itagIndex, indexSeparator - itagIndex);
                        int itag = Convert.ToInt32(itagString);
                        int priorite = manager.getPrioriteFromFormatTag(itag);
                        if (priorite < currentTagPriorite)
                        {
                            currentTagPriorite = priorite;
                            index = videoURLs.IndexOf(url);
                        }
                    }
                }

                /*separateur[0] = ",";
                String resultUrl = RemoveExtraParams(videoURLs[index], null);*/
                return videoURLs[index];

                //Settings.Default.paramNamesToRemoveYoutube.Split(separateur, StringSplitOptions.RemoveEmptyEntries));
                /*                int nombreParamNamesAEnlever = (Settings.Default.paramNamesToRemoveYoutube.Split(separateur, StringSplitOptions.RemoveEmptyEntries)).Length;
                                for (int i = 0; i < nombreParamNamesAEnlever; i++)
                                {
                                    paramNames.RemoveAt(paramNames.Count - 1);
                                }

                                return videoURLs[index].Substring(0, GetIndexFinParams(videoURLs[index], paramNames));
                 * */
            }
            catch (Exception ex)
            {
                AddErrorMsg("YoutubeDownload.extractUrlFromSwfHtml swfHtml= " + swfHtml, ex);
                return null;
            }
        }
开发者ID:ed4053,项目名称:YDownloader,代码行数:72,代码来源:YoutubeDownload.cs

示例14: Test01

        public void Test01()
        {
            IntlStrings intl;
            StringCollection sc;
            // simple string values
            string[] values =
            {
                "",
                " ",
                "a",
                "aa",
                "text",
                "     spaces",
                "1",
                "$%^#",
                "2222222222222222222222222",
                System.DateTime.Today.ToString(),
                Int32.MaxValue.ToString()
            };

            int cnt = 0;            // Count

            // initialize IntStrings
            intl = new IntlStrings();


            // [] StringCollection is constructed as expected
            //-----------------------------------------------------------------

            sc = new StringCollection();

            // [] for empty collection
            //
            for (int i = 0; i < values.Length; i++)
            {
                if (sc.IndexOf(values[i]) != -1)
                {
                    Assert.False(true, string.Format("Error, returned {1} for empty collection", i, sc.IndexOf(values[i])));
                }
            }

            //
            // [] add simple strings and verify IndexOf()


            cnt = sc.Count;
            sc.AddRange(values);
            if (sc.Count != values.Length)
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
            }

            for (int i = 0; i < values.Length; i++)
            {
                // verify that collection contains all added items
                //
                if (sc.IndexOf(values[i]) != i)
                {
                    Assert.False(true, string.Format("Error, IndexOf returned {1} instead of {0}", i, sc.IndexOf(values[i])));
                }
            }

            //
            // Intl strings
            // [] add Intl strings and verify IndexOf()
            //

            string[] intlValues = new string[values.Length];

            // fill array with unique strings
            //
            for (int i = 0; i < values.Length; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }

            int len = values.Length;
            Boolean caseInsensitive = false;
            for (int i = 0; i < len; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
                    caseInsensitive = true;
            }

            cnt = sc.Count;
            sc.AddRange(intlValues);
            if (sc.Count != (cnt + intlValues.Length))
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length));
            }

            for (int i = 0; i < intlValues.Length; i++)
            {
                // verify that collection contains all added items
                //
                if (sc.IndexOf(intlValues[i]) != values.Length + i)
                {
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:IndexOfStrTests.cs

示例15: AddInstalledHakInfos

        /// <summary>
        /// Adds the passed hif name / version number to the list of hifs installed on
        /// the module.  Both arrays must be the same length.
        /// </summary>
        /// <param name="hifs">The hifs to add</param>
        /// <param name="versions">The version numbers of the hifs</param>
        public void AddInstalledHakInfos(string[] hifs, float[] versions)
        {
            // Get the current values if any.
            string[] currentHifs;
            float[] currentVersions;
            GetInstalledHakInfos(out currentHifs, out currentVersions);

            // Create StringCollections for them so we can use IndexOf() for searching.
            StringCollection colHifs = new StringCollection();
            colHifs.AddRange(currentHifs);
            ArrayList colVersions = new ArrayList();
            colVersions.AddRange(currentVersions);

            // Check for duplicates, pruning duplicates out of the current list.
            foreach (string hif in hifs)
            {
                // Find the hif in the current values, if we don't find it then
                // skip it.
                int index = colHifs.IndexOf(hif);
                if (-1 == index) continue;

                // Remove it from the current list.
                colHifs.RemoveAt(index);
                colVersions.RemoveAt(index);
            }

            // Now build a string with all of the current hifs/version numbers then
            // all of the added hif/version numbers.
            System.Text.StringBuilder b = new StringBuilder();
            for (int i = 0; i < colHifs.Count; i++)
            {
                if (b.Length > 0) b.Append(";");
                b.AppendFormat("{0};{1}", colHifs[i], colVersions[i].ToString());
            }
            for (int i = 0; i < hifs.Length; i++)
            {
                if (b.Length > 0) b.Append(";");
                b.AppendFormat("{0};{1}", hifs[i], versions[i].ToString());
            }

            // Get the schema for the field and get it, creating it if it is not there.
            // Then save the StringBuilder text as the field's value.
            GffFieldSchema schema = properties["installedhifs"];
            GffExoStringField field = (GffExoStringField) GetField(schema);
            field.Value = b.ToString();
        }
开发者ID:BackupTheBerlios,项目名称:nwnprc,代码行数:52,代码来源:ModuleInfo.cs


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