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


C# SortedList.Contains方法代码示例

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


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

示例1: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue;
     SortedList dic1;
     try 
     {
         do
         {
             strLoc = "Loc_8345vdfv";
             dic1 = new SortedList();
             for(int i=0; i<10; i++)
             {
                 strValue = "String_" + i;
                 dic1.Add(i, strValue);
             }
             iCountTestcases++;
             for(int i=0; i<10; i++)
             {
                 if(!dic1.Contains(i)) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_561dvs_" + i + "! Expected value not returned, " + dic1.Contains(i));
                 }
             }
             iCountTestcases++;
             if(dic1.IsReadOnly) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_65323gdfgb! Expected value not returned, " + dic1.IsReadOnly);
             }
             dic1.Remove(0);
             iCountTestcases++;
             if(dic1.Contains(0)) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_65323gdfgb! Expected value not returned, " + dic1.Contains(0));
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:59,代码来源:co3916get_isreadonly.cs

示例2: Simple

        public void Simple()
        {
            var sortedList = new SortedList<int>();

            for (var i = 0; i < 20; i++)
            {
                sortedList.Add(i);
            }

            Assert.IsTrue(sortedList.Contains(5));
            Assert.IsFalse(sortedList.Contains(50));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:12,代码来源:Contains.cs

示例3: TestGetIsSynchronizedBasic

        public void TestGetIsSynchronizedBasic()
        {
            SortedList slst1;
            string strValue;

            Task[] workers;
            Action ts1;
            int iNumberOfWorkers = 3;

            // Vanila test case - Synchronized returns an IList that is thread safe
            // We will try to test this by getting a number of threads to write some items
            // to a synchronized IList
            slst1 = new SortedList();
            _slst2 = SortedList.Synchronized(slst1);

            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => AddElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            //checking time
            Assert.Equal(_slst2.Count, _iNumberOfElements * iNumberOfWorkers);

            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                for (int j = 0; j < _iNumberOfElements; j++)
                {
                    strValue = "Thread worker " + i + "_" + j;
                    Assert.True(_slst2.Contains(strValue), "Error, Expected value not returned, " + strValue);
                }
            }

            // We can't make an assumption on the order of these items though
            //now we are going to remove all of these
            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => RemoveElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            Assert.Equal(0, _slst2.Count);

            // we will check IsSynchronized now
            Assert.False(slst1.IsSynchronized);
            Assert.True(_slst2.IsSynchronized);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:55,代码来源:PropertyIsSynchronizedTests.cs

示例4: TestSynchronizedBasic

        public void TestSynchronizedBasic()
        {
            SortedList slst1;
            String strValue;

            Task[] workers;
            Action ts1;
            Int32 iNumberOfWorkers = 3;

            slst1 = new SortedList();
            _slst2 = SortedList.Synchronized(slst1);

            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => AddElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            //checking time

            Assert.Equal(_slst2.Count, _iNumberOfElements * iNumberOfWorkers);


            for (int i = 0; i < iNumberOfWorkers; i++)
            {
                for (int j = 0; j < _iNumberOfElements; j++)
                {
                    strValue = "Thread worker " + i + "_" + j;

                    Assert.True(_slst2.Contains(strValue), "Error, Expected value not returned, " + strValue);
                }
            }

            //I dont think that we can make an assumption on the order of these items though
            //now we are going to remove all of these
            workers = new Task[iNumberOfWorkers];
            for (int i = 0; i < workers.Length; i++)
            {
                var name = "Thread worker " + i;
                ts1 = new Action(() => RemoveElements(name));
                workers[i] = Task.Run(ts1);
            }

            Task.WaitAll(workers);

            Assert.Equal(0, _slst2.Count);
            Assert.False(slst1.IsSynchronized);
            Assert.True(_slst2.IsSynchronized);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:53,代码来源:SynchronizedTests.cs

示例5: TestGetIsReadOnlyBasic

        public void TestGetIsReadOnlyBasic()
        {
            String strValue;
            SortedList dic1;

            dic1 = new SortedList();
            for (int i = 0; i < 10; i++)
            {
                strValue = "String_" + i;
                dic1.Add(i, strValue);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.True(dic1.Contains(i));
            }

            //we'll do the ReadOnly test
            Assert.False(dic1.IsReadOnly);

            //we'll make sure by doing a modifiable things!!
            dic1.Remove(0);
            Assert.False(dic1.Contains(0));
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:24,代码来源:PropertyIsReadOnlyTests.cs

示例6: Main

 public static void Main(String[] args)
 {
     int SIZE = int.Parse(args[0]);
     IDictionary hash = new Hashtable(2*SIZE);
     IDictionary tree = new SortedList();
     Random random = new Random();
     int i = random.Next(5000000);
     for (int j = 0; j < SIZE; j++) {
        if(!hash.Contains(i))
       hash.Add(i, i);
        if(!tree.Contains(i))
       tree.Add(i, i);
     }
     Console.WriteLine("Hash for {0}", time(hash, TEST));
     Console.WriteLine("Tree for {0}", time(tree, TEST));
 }
开发者ID:JnS-Software-LLC,项目名称:CSC153,代码行数:16,代码来源:CompareMaps+(1).cs

示例7: CountryList

    public SortedList CountryList()
    {
        SortedList slCountry = new SortedList();
        string Key = "";
        string Value = "";

        foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
        {
            RegionInfo info2 = new RegionInfo(info.LCID);
            if (!slCountry.Contains(info2.EnglishName))
            {
                Value = info2.TwoLetterISORegionName;
                Key = info2.EnglishName;
                slCountry.Add(Key, Value);
            }
        }
        return slCountry;
    }
开发者ID:moeen-aqrabawi,项目名称:trios,代码行数:18,代码来源:FormControl.ascx.cs

示例8: TestCloneWithEnumerator

        public void TestCloneWithEnumerator()
        {
            //WE will test the Clone() method of the enumerator
            DictionaryEntry dicEnt;

            var dic1 = new SortedList();

            for (int i = 0; i < 100; i++)
                dic1.Add("Key_" + i, "Value_" + i);

            var idicTest = dic1.GetEnumerator();
            var idicTest1 = dic1.GetEnumerator();

            var hsh1 = new Hashtable();

            var hsh2 = new Hashtable();
            while (idicTest1.MoveNext())
            {
                if (!dic1.Contains(idicTest1.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[idicTest1.Key] != idicTest1.Value)
                    hsh1["IDictionaryEnumerator"] = "";

                dicEnt = idicTest1.Entry;
                if (!dic1.Contains(dicEnt.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[dicEnt.Key] != dicEnt.Value)
                    hsh1["IDictionaryEnumerator"] = "";

                try
                {
                    hsh2.Add(idicTest1.Key, idicTest1.Value);
                }
                catch (Exception)
                {
                    hsh1["IDictionaryEnumerator"] = "";
                }

                dicEnt = (DictionaryEntry)idicTest1.Current;
                if (!dic1.Contains(dicEnt.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[dicEnt.Key] != dicEnt.Value)
                    hsh1["IDictionaryEnumerator"] = "";
            }

            idicTest1.Reset();
            hsh2 = new Hashtable();
            while (idicTest1.MoveNext())
            {
                if (!dic1.Contains(idicTest1.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[idicTest1.Key] != idicTest1.Value)
                    hsh1["IDictionaryEnumerator"] = "";

                dicEnt = idicTest1.Entry;
                if (!dic1.Contains(dicEnt.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[dicEnt.Key] != dicEnt.Value)
                    hsh1["IDictionaryEnumerator"] = "";

                try
                {
                    hsh2.Add(idicTest1.Key, idicTest1.Value);
                }
                catch (Exception)
                {
                    hsh1["IDictionaryEnumerator"] = "";
                }

                dicEnt = (DictionaryEntry)idicTest1.Current;
                if (!dic1.Contains(dicEnt.Key))
                    hsh1["IDictionaryEnumerator"] = "";
                if (dic1[dicEnt.Key] != dicEnt.Value)
                    hsh1["IDictionaryEnumerator"] = "";
            }

            idicTest1.Reset();
            dic1.Add("Key_Blah", "Value_Blah");
            try
            {
                idicTest1.MoveNext();
                hsh1["Enumerator"] = "NoEXception";
            }
            catch (InvalidOperationException)
            {
            }
            catch (Exception ex)
            {
                hsh1["Enumerator"] = ex;
            }

            try
            {
                object blah = idicTest1.Current;
                hsh1["Enumerator"] = "NoEXception";
            }
            catch (InvalidOperationException)
            {
            }
            catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:WrapperTests.cs

示例9: ReloadData

    /// <summary>
    /// Loads drop down list with data.
    /// </summary>
    private void ReloadData()
    {
        if (drpSelectEncoding.Items.Count == 0)
        {
            EncodingInfo[] ei = Encoding.GetEncodings();
            SortedList sl = new SortedList();

            // Load sorted list
            for (int i = 0; i < ei.Length; i++)
            {
                if (!sl.Contains(ei[i].Name))
                {
                    sl.Add(ei[i].Name, ei[i].Name);
                }
            }

            // Populate dropdownlist with data from sorted list
            drpSelectEncoding.DataSource = sl;
            drpSelectEncoding.DataTextField = "Value";
            drpSelectEncoding.DataValueField = "Key";
            drpSelectEncoding.DataBind();

            // Preselect value
            ListItem selectedItem = drpSelectEncoding.Items.FindByValue(encoding);
            if (selectedItem != null)
            {
                selectedItem.Selected = true;
            }
            else
            {
                selectedItem = drpSelectEncoding.Items.FindByValue("utf-8");
                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }
        }
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:41,代码来源:SelectEncoding.ascx.cs

示例10: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     SortedList slst1;
     Int32 iNumberOfElements;
     String strValue;
     Array ar1;
     try 
     {
         do
         {
             strLoc = "Loc_001fn";
             iNumberOfElements = 10;
             slst1 = new SortedList(iNumberOfElements);
             for(int i=iNumberOfElements-1; i>=0;i--)
             {
                 slst1.Add(50 + i, "Value_" + i);
             }
             iCountTestcases++;
             if(slst1.Count!=iNumberOfElements) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_752dsg! Expected value not returned, " + slst1.Count + " " + iNumberOfElements);
             }
             for(int i=0; i<slst1.Count;i++)
             {
                 strValue = "Value_" + i;
                 if(!strValue.Equals(slst1[slst1.GetKey(i)])) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_000oo! Expected value not returned, " + strValue + " " + slst1[slst1.GetKey(i)]);
                 }
             }
             strLoc = "Loc_756tegd";
             try
             {
                 iCountTestcases++;
                 iNumberOfElements = -5;
                 slst1 = new SortedList(iNumberOfElements);
                 iCountErrors++;
                 Console.WriteLine("Err_7439dg! Exception not thrown");
             }
             catch(ArgumentOutOfRangeException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_097243sdgg! Unexpected exception thrown, " + ex);
             }
             strLoc = "Loc_74dsg";
             slst1 = new SortedList();
             strLoc = "Loc_175fdg";
             try
             {
                 iCountTestcases++;
                 slst1.Add(null, 5);
                 iCountErrors++;
                 Console.WriteLine("Err_7439dg! Exception not thrown");
             }
             catch(ArgumentNullException)
             {
             }
             catch(Exception ex)
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0642efss! Unexpected exception thrown, " + ex);
             }
             iNumberOfElements = 10;
             slst1 = new SortedList();
             for(int i=iNumberOfElements-1; i>=0;i--)
             {
                 slst1.Add(i, null);
             }
             iCountTestcases++;
             for(int i=0; i<slst1.Count;i++)
             {
                 strValue = "Value_" + i;
                 if(slst1.GetByIndex(i)!=null) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_7620cdg! Expected value not returned, " + slst1.GetByIndex(i));
                 }
             }
             strLoc = "Loc_07534efsdgs";
             iNumberOfElements = 10;
             slst1 = new SortedList(iNumberOfElements);
             for(int i=iNumberOfElements-1; i>=0;i--)
             {
                 slst1.Add(50 + i, "Value_" + i);
             }
             iCountTestcases++;
             for(int i=0; i<slst1.Count;i++)
             {
                 strValue = "Value_" + i;
                 if(!slst1.Contains(50 + i)) 
                 {
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co3953multimethods.cs

示例11: Initialize

    /// <summary>
    /// Initialize page controls
    /// </summary>
    private void Initialize()
    {
        // Check post back
        if (!RequestHelper.IsPostBack())
        {
            FillObjectsToDelete();

            SortedList list = new SortedList();

            // Loop thru all statistic pre-defined codenames
            foreach (string codeName in SampleDataGenerator.StatisticCodeNames)
            {
                // Try get display name
                string displayName = GetString("analytics_codename." + codeName);

                // If display name is not defined use codename
                if (displayName.EqualsCSafe("analytics_codename." + codeName, true))
                {
                    displayName = codeName;
                }

                // Add to the list collection
                if (!list.Contains(displayName))
                {
                    list.Add(displayName, new ListItem(displayName, codeName));
                }
                else
                {
                    // If display name already in collection - add special display name
                    list.Add(displayName + codeName, new ListItem(displayName + " (" + codeName + ")", codeName));
                }
            }

            // Add default (all) value
            drpGenerateObjects.Items.Insert(0, new ListItem(GetString("general.selectall"), ""));

            // Add values from sorted list
            foreach (ListItem li in list.Values)
            {
                drpGenerateObjects.Items.Add(li);
            }

            // Initialize sample data range selector for 2 months range
            DateTime date = DateTime.Now;
            ucSampleFrom.SelectedDateTime = date.AddMonths(-2);
            ucSampleTo.SelectedDateTime = date;
        }
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:51,代码来源:Analytics_DataManagement.aspx.cs

示例12: FillObjectsToDelete

    /// <summary>
    /// Fills drop drop down field for deleted objects
    /// </summary>
    private void FillObjectsToDelete()
    {
        drpDeleteObjects.Items.Clear();

        SortedList list = new SortedList();

        var statistics =
            StatisticsInfoProvider.GetStatistics()
                                  .Column("StatisticsCode")
                                  .Distinct()
                                  .WhereEquals("StatisticsSiteID", SiteContext.CurrentSiteID)
                                  .WhereNotContains("StatisticsCode", ";");

        foreach (var statisticsInfo in statistics)
        {
            // Statistic codename
            string codeName = statisticsInfo.StatisticsCode;
            // Statistic dispaly name
            string displayName = GetString("analytics_codename." + codeName);
            // If resource string is not available use codename
            if (displayName.EqualsCSafe("analytics_codename." + codeName, true))
            {
                displayName = codeName;
            }

            if (!list.Contains(displayName))
            {
                // Add to the list collection
                list.Add(displayName, new ListItem(displayName, codeName));
            }
            else
            {
                // If display name already in collection - add special display name
                list.Add(displayName + codeName, new ListItem(displayName + " (" + codeName + ")", codeName));
            }
        }

        // Add A/B and M/V testing
        list.Add(GetString("analytics_codename.abtest"), new ListItem(GetString("analytics_codename.abtest"), "abtest"));
        list.Add(GetString("analytics_codename.mvtest"), new ListItem(GetString("analytics_codename.mvtest"), "mvtest"));

        // Add values from sorted list
        foreach (ListItem li in list.Values)
        {
            drpDeleteObjects.Items.Add(li);
        }

        // Add default (all) value
        drpDeleteObjects.Items.Insert(0, new ListItem(GetString("general.selectall"), ""));
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:53,代码来源:Analytics_DataManagement.aspx.cs

示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        // initialize

        ActivityAlarmOptions options = null;
        try
        {
            options = ActivityAlarmOptions.Load(Server.MapPath(@"App_Data\LookupValues"));
        }
        catch
        {
            // temporary, as the service throws an exception for options not found
            // the service is not yet complete, but this allows testing of the UI
            options = ActivityAlarmOptions.CreateNew(Server.MapPath(@"App_Data\LookupValues"));
        }

        _defaultView.DataSource = options.DefaultViewLookupList;
        _defaultView.DataTextField = options.DataTextField;
        _defaultView.DataValueField = options.DataValueField;
        _timeFrame.DataSource = options.TimeFrameLookupList;
        _timeFrame.DataTextField = options.DataTextField;
        _timeFrame.DataValueField = options.DataValueField;
        _defaultFollowupActivity.DataSource = options.DefaultFollowupActivityLookupList;
        _defaultFollowupActivity.DataTextField = options.DataTextField;
        _defaultFollowupActivity.DataValueField = options.DataValueField;
        _carryOverNotes.DataSource = options.CarryOverNotesLookupList;
        _carryOverNotes.DataTextField = options.DataTextField;
        _carryOverNotes.DataValueField = options.DataValueField;
        _carryOverAttachments.DataSource = options.CarryOverAttachmentsLookupList;
        _carryOverAttachments.DataTextField = options.DataTextField;
        _carryOverAttachments.DataValueField = options.DataValueField;
        _alarmDefaultLead.DataSource = options.AlarmDefaultLeadLookupList;
        _alarmDefaultLead.DataTextField = options.DataTextField;
        _alarmDefaultLead.DataValueField = options.DataValueField;

        Sage.SalesLogix.Security.SLXUserService slxUserService = ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>() as Sage.SalesLogix.Security.SLXUserService;
        string currentUserID = slxUserService.GetUser().Id.ToString();
        IList<IUser> calUsers = UserCalendar.GetCalendarUsers(currentUserID);
        SortedList sl = new SortedList();
        foreach (IUser calUser in calUsers)
        {
            if ((calUser != null) && (!sl.Contains(calUser.ToString())))
            {
                sl.Add(calUser.ToString(), calUser.Id);
            }
        }
        _showActivitiesFor.SelectionMode = ListSelectionMode.Multiple;
        _showActivitiesFor.DataSource = sl;
        _showActivitiesFor.DataValueField = "VALUE";
        _showActivitiesFor.DataTextField = "KEY";
        Page.DataBind();

        //}
    }
开发者ID:RyanTest,项目名称:SalesLogix_Eval,代码行数:56,代码来源:ActivityAlarmOptionsPage.ascx.cs

示例14: Test01

        public void Test01()
        {
            SortedList slst1;
            Int32 iNumberOfElements;
            String strValue;
            Array ar1;

            // ctor(Int32)
            iNumberOfElements = 10;
            slst1 = new SortedList(iNumberOfElements);

            for (int i = iNumberOfElements - 1; i >= 0; i--)
            {
                slst1.Add(50 + i, "Value_" + i);
            }

            Assert.Equal(slst1.Count, iNumberOfElements);

            //we will assume that all the keys are sorted as the name implies. lets see
            //We intially filled this lit with descending and much higher keys. now we access the keys through index
            for (int i = 0; i < slst1.Count; i++)
            {
                strValue = "Value_" + i;
                Assert.Equal(strValue, slst1[slst1.GetKey(i)]);
            }

            //paramter stuff
            Assert.Throws<ArgumentOutOfRangeException>(() =>
                             {
                                 iNumberOfElements = -5;
                                 slst1 = new SortedList(iNumberOfElements);
                             }
            );

            slst1 = new SortedList();
            Assert.Throws<ArgumentNullException>(() =>
                             {
                                 slst1.Add(null, 5);
                             }
            );

            iNumberOfElements = 10;
            slst1 = new SortedList();

            for (int i = iNumberOfElements - 1; i >= 0; i--)
            {
                slst1.Add(i, null);
            }

            for (int i = 0; i < slst1.Count; i++)
            {
                strValue = "Value_" + i;
                Assert.Null(slst1.GetByIndex(i));
            }

            //Contains()
            iNumberOfElements = 10;
            slst1 = new SortedList(iNumberOfElements);
            for (int i = iNumberOfElements - 1; i >= 0; i--)
            {
                slst1.Add(50 + i, "Value_" + i);
            }

            for (int i = 0; i < slst1.Count; i++)
            {
                strValue = "Value_" + i;
                Assert.True(slst1.Contains(50 + i));
            }

            Assert.False(slst1.Contains(1));
            Assert.False(slst1.Contains(-1));

            //paramter stuff
            Assert.Throws<ArgumentNullException>(() =>
                             {
                                 slst1.Contains(null);
                             }
            );

            //get/set_Item
            slst1 = new SortedList();
            for (int i = iNumberOfElements - 1; i >= 0; i--)
            {
                slst1[50 + i] = "Value_" + i;
            }

            Assert.Equal(slst1.Count, iNumberOfElements);

            for (int i = 0; i < slst1.Count; i++)
            {
                strValue = "Value_" + i;
                Assert.Equal(strValue, slst1[i + 50]);
            }

            //already existent ones
            strValue = "Value_1";
            Assert.Equal(strValue, slst1[51]);

            strValue = "Different value";
            slst1[51] = strValue;
//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:MultiMethodsTests.cs

示例15: FillObjectsToDelete

    /// <summary>
    /// Fills drop drop down field for deleted objects
    /// </summary>
    private void FillObjectsToDelete()
    {
        drpDeleteObjects.Items.Clear();

        SortedList list = new SortedList();

        // Get available statistics for current site
        DataSet ds = StatisticsInfoProvider.GetStatistics("StatisticsSiteID = " + CMSContext.CurrentSiteID + " AND StatisticsCode NOT LIKE '%;%'", null, 0, "DISTINCT StatisticsCode");
        // Check whether exists at least one statistic
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Loop thru all statistics
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                // Statistic codename
                string codeName = ValidationHelper.GetString(dr["StatisticsCode"], String.Empty);
                // Statistic dispaly name
                string displayName = GetString("analytics_codename." + codeName);
                // If resource string is not available use codename
                if (displayName.EqualsCSafe("analytics_codename." + codeName, true))
                {
                    displayName = codeName;
                }

                if (!list.Contains(displayName))
                {
                    // Add to the list collection
                    list.Add(displayName, new ListItem(displayName, codeName));
                }
                else
                {
                    // If display name already in collection - add special display name
                    list.Add(displayName + codeName, new ListItem(displayName + " (" + codeName + ")", codeName));
                }
            }

            // Add A/B and M/V testing
            list.Add(GetString("analytics_codename.abtest"), new ListItem(GetString("analytics_codename.abtest"), "abtest"));
            list.Add(GetString("analytics_codename.mvtest"), new ListItem(GetString("analytics_codename.mvtest"), "mvtest"));

            // Add values from sorted list
            foreach (ListItem li in list.Values)
            {
                drpDeleteObjects.Items.Add(li);
            }
        }

        // Add default (all) value
        drpDeleteObjects.Items.Insert(0, new ListItem(GetString("general.selectall"), ""));
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:53,代码来源:Analytics_DataManagement.aspx.cs


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