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


C# StringDictionary.Clear方法代码示例

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


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

示例1: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     string itm;         
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. set Item on empty dictionary");
         iCountTestcases++;
         for (int i = 0; i < keys.Length; i++) 
         {
             if (sd.Count > 0)
                 sd.Clear();
             sd[keys[i]] = values[i];
             if (sd.Count != 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001a_{0}, didn't add item with {0} key", i);
             }
             if (String.Compare(sd[keys[i]], values[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001b_{0}, added wrong value", i);
             }
         }
         Console.WriteLine("2. set Item on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             itm = "item" + i;
             sd[keys[i]] = itm;
             if (String.Compare(sd[keys[i]], itm, false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, returned {1} instead of {2}", i, sd[keys[i]], itm);
             } 
         }
         Console.WriteLine("3. set Item on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         string intlStr1 = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
         if (sd.Count != len+2) 
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8768set_item_str_str.cs

示例2: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "tExt",
         "     spAces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     Array arr;
     ICollection vs;         
     int ind;
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. get Values for empty dictionary");
         iCountTestcases++;
         if (sd.Count > 0)
             sd.Clear();
         if (sd.Values.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, returned Values.Count = {0}", sd.Values.Count);
         }
         Console.WriteLine("2. get Values on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         vs = sd.Values;
         if (vs.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, returned Values.Count = {0}", vs.Count);
         }
         arr = Array.CreateInstance(typeof(string), len);
         vs.CopyTo(arr, 0);
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             ind = Array.IndexOf(arr, values[i]);
             if (ind < 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, Values doesn't contain \"{1}\" value. Search result: {2}", i, keys[i], ind);
             } 
         }
         Console.WriteLine("3. get Values on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
         if (sd.Count != len+2) 
         {
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8767get_values.cs

示例3: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     int cnt = 0;
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Remove() from empty dictionary");
         iCountTestcases++;
         if (sd.Count > 0)
             sd.Clear();
         for (int i = 0; i < keys.Length; i++) 
         {
             sd.Remove(keys[0]);
         }
         Console.WriteLine("2. Remove() on filled dictionary");  
         strLoc = "Loc_002oo"; 
         int len = values.Length;
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, len);
         } 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Remove(keys[i]);
             if (sd.Count != cnt - 1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002b_{0}, didn't remove element with {0} key", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsValue(values[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002c_{0}, removed wrong value", i);
             } 
             iCountTestcases++;
             if ( sd.ContainsKey(keys[i]) ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002d_{0}, removed wrong value", i);
             } 
         }
         Console.WriteLine("3. Remove() on dictionary with duplicate values ");
         strLoc = "Loc_003oo"; 
         iCountTestcases++;
         sd.Clear();
         string intlStr = intl.GetString(MAX_LEN, true, true, true);
         sd.Add("keykey1", intlStr);        
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         sd.Add("keykey2", intlStr);        
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8761remove_str.cs

示例4: runTest


//.........这里部分代码省略.........
             if (!sd.ContainsKey(intlValues[i+len])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, collection doesn't contain key of new item", i);
             } 
             ind = intlValues[i+len];
             iCountTestcases++;
             if (String.Compare(sd[ind], intlValues[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[ind], intlValues[i]);
             } 
         }
         Console.WriteLine("4. add null string with non-null key and verify ContainsValue()");
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         string k = "keykey";
         sd.Add(k, null);
         if (sd.Count != cnt+1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {1} instead of {2}", sd.Count, cnt+1);
         } 
         iCountTestcases++;
         if (!sd.ContainsValue(null)) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, dictionary doesn't contain value null");
         }
         Console.WriteLine("5. Case sensitivity");
         strLoc = "Loc_005oo"; 
         iCountTestcases++;
         sd.Clear();
         if (sd.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005, count is {1} instead of {2} after Clear()", sd.Count, 0);
         } 
         string [] intlValuesLower = new string [len * 2];
         for (int i = 0; i < len * 2; i++) 
         {
             intlValues[i] = intlValues[i].ToUpper();
         }
         for (int i = 0; i < len * 2; i++) 
         {
             intlValuesLower[i] = intlValues[i].ToLower();
         } 
         sd.Clear();
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = sd.Count;
             sd.Add(intlValues[i+len], intlValues[i]);     
             if (sd.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
             } 
             iCountTestcases++;
             if (!sd.ContainsValue(intlValues[i])) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0005_{0}b, collection doesn't contain value of new item", i);
             } 
             iCountTestcases++;
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:co8758containsvalue_str.cs

示例5: runTest


//.........这里部分代码省略.........
         iCountTestcases++;
         cnt = sd.Count;
         int len = values.Length;
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003a, count is {0} instead of {1}", sd.Count, values.Length);
         } 
         destination = Array.CreateInstance(typeof(Object), len);
         sd.CopyTo(destination, 0);
         IEnumerator en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i)).Key, curr.Key);
             }  
         }
         Console.WriteLine("4. add simple strings and CopyTo(Array, {0})", values.Length);
         sd.Clear();
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004a, count is {0} instead of {1}", sd.Count, values.Length);
         } 
         destination = Array.CreateInstance(typeof(Object), len*2);
         sd.CopyTo(destination, len);
         en = sd.GetEnumerator();
         for (int i = 0; i < len; i++) 
         {
             en.MoveNext();
             DictionaryEntry curr = (DictionaryEntry)en.Current;
             iCountTestcases++;
             if ( String.Compare(curr.Value.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Value.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}b, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Value, curr.Value);
             }  
             iCountTestcases++;
             if ( String.Compare(curr.Key.ToString(), ((DictionaryEntry)destination.GetValue(i+len)).Key.ToString(), false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0003_{0}c, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i+len)).Key, curr.Key);
             }  
         }
         Console.WriteLine("5. add intl strings and CopyTo(Array, 0)");
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:67,代码来源:co8759copyto_array_int.cs

示例6: runTest


//.........这里部分代码省略.........
         iCountTestcases++;
         sd.Remove(keys[0]);
         if ( sd.Count != cnt - 1 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003b, didn't remove item with 0th key");
         }
         Console.WriteLine("     - get Current");
         iCountTestcases++;
         DictionaryEntry curr2 = (DictionaryEntry)en.Current;
         if (! curr.Equals(curr2) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003c, current returned different value after midification");
         }
         Console.WriteLine("     - call MoveNext");
         iCountTestcases++;
         try 
         {
             res = en.MoveNext();
             iCountErrors++;
             Console.WriteLine("Err_0003d, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003e, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("4. Modify dictionary after enumerated beyond the end");
         strLoc = "Loc_004oo"; 
         iCountTestcases++;
         sd.Clear();
         for (int i = 0; i < values.Length; i++) 
         {
             sd.Add(keys[i], values[i]);
         }
         iCountTestcases++;
         en = sd.GetEnumerator();
         for (int i = 0; i < sd.Count; i ++) 
         {
             en.MoveNext();
         }
         Console.WriteLine("     - get Current at the end of the dictionary");
         curr = (DictionaryEntry)en.Current;
         Console.WriteLine("     - modify collection");
         curr = (DictionaryEntry)en.Current;
         cnt = sd.Count;
         iCountTestcases++;
         sd.Remove(keys[0]);
         if ( sd.Count != cnt - 1 ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004b, didn't remove item with 0th key");
         }
         Console.WriteLine("     - get Current after modifying");
         iCountTestcases++;
         curr2 = (DictionaryEntry)en.Current;
         if (! curr.Equals(curr2) ) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004c, current returned different value after midification");
         }
         Console.WriteLine("     - call MoveNext after modifying");
         iCountTestcases++;
         try 
         {
             res = en.MoveNext();
             iCountErrors++;
             Console.WriteLine("Err_0004d, no exception");
         }
         catch (InvalidOperationException ex) 
         {
             Console.WriteLine("  expected exception: " + ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004e, unexpected exception: {0}", e.ToString());
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_general!  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:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8760getenumerator.cs

示例7: xmlparse

    // pseudo SAX reader
    public static void xmlparse(string fname)
    {
        XmlReader reader = new XmlTextReader(fname);
        string line;

        urls    =       new ArrayList();
        int cnt  = 0;
        // http://msdn.microsoft.com/en-us/library/1z92b1d4.aspx
        // http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readsubtree.aspx
        while (reader.Read()) {
        if (reader.MoveToContent() == XmlNodeType.Element &&
            reader.Name == "formvals") {

            XmlReader inner = reader.ReadSubtree();
            StringDictionary myCol = new StringDictionary();
            while (inner.Read()) {

                if (inner.MoveToContent() == XmlNodeType.Element &&
                    inner.Name == "input") {

                    inner.MoveToFirstAttribute();
        // to avoid dependency on the attribute order, key them by the attribute name
        // amended with the unique count of the current input element.
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    inner.MoveToNextAttribute();
                    myCol.Add(String.Format("{0}-{1}", inner.Name, cnt.ToString()), inner.Value);
                    cnt++;
                }

                DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
                myCol.CopyTo(myArr, 0);

                for (int i = 0; i < myArr.Length; i++) {

                    try{

                        string inputNameRegExp = @"name\-(?<input>\d+)";
                        MatchCollection myMatchCollection =
                            Regex.Matches(myArr[i].Key.ToString(), inputNameRegExp );

                        foreach (Match myMatch in myMatchCollection) {

                            string pos =  myMatch.Groups["input"].Value.ToString();
                            // do not use StringDictionary for final formvals or you have your keyc converted to lower case.
                            formvals.Add(myCol[String.Format("name-{0}", pos)], myCol[String.Format("value-{0}", pos)]);

                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.ToString());
                    }

                }
                myCol.Clear();
            }
            foreach ( KeyValuePair<string, string> kvp in formvals )
                Console.WriteLine("formvals[ {0} ] = {1}", kvp.Key, kvp.Value);

            inner.Close();

        }
        if (reader.MoveToContent() == XmlNodeType.Element &&   reader.Name == "url") {
            line    =       reader.ReadString();
            urls.Add(line);
            Console.WriteLine(line);
        }
        }
    }
开发者ID:testpulse,项目名称:powershell_selenium,代码行数:68,代码来源:xparse.cs

示例8: runTest

 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     IntlStrings intl;
     String strLoc = "Loc_000oo";
     StringDictionary sd; 
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "text",
         "     spaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] keys = 
     {
         "zero",
         "one",
         " ",
         "",
         "aa",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     int cnt = 0;            
     try
     {
         intl = new IntlStrings(); 
         Console.WriteLine("--- create dictionary ---");
         strLoc = "Loc_001_oo"; 
         iCountTestcases++;
         sd = new StringDictionary();
         Console.WriteLine("1. Count of empty dictionary");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001a, count is {0} instead of {1} after default ctor", sd.Count, 0);
         }
         sd.Clear();
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001b, count is {0} instead of {1} after Clear()", sd.Count, 0);
         }
         Console.WriteLine("2. add simple strings and Clear()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         cnt = sd.Count;
         for (int i = 0; i < values.Length; i++) 
         {    
             sd.Add(keys[i], values[i]);
         }
         if (sd.Count != values.Length) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", sd.Count, values.Length);
         }
         iCountTestcases++;
         sd.Clear();
         cnt = sd.Count;
         if ( cnt != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002b, count is {0} instead of {1} after Clear()", sd.Count, 0);
         }
         Console.WriteLine("3. add intl strings and Clear()");
         strLoc = "Loc_003oo"; 
         int len = values.Length;
         string [] intlValues = new string [len * 2];
         for (int i = 0; i < len * 2; i++) 
         {
             string val = intl.GetString(MAX_LEN, true, true, true);
             while (Array.IndexOf(intlValues, val) != -1 )
                 val = intl.GetString(MAX_LEN, true, true, true);
             intlValues[i] = val;
         } 
         cnt = sd.Count;
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {    
             sd.Add(intlValues[i+len], intlValues[i]);
         }
         if (sd.Count != (cnt + len)) 
         {
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8762get_count.cs

示例9: InitializeMappings

        private void InitializeMappings()
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "InitializeMappings"))
            {
                IDictionary<string, IMonitorHandler> handlerInstances = null;

                try
                {
                    _handlerMappings = new StringDictionary<IMonitorHandler>();
                    handlerInstances = new StringDictionary<IMonitorHandler>();

                    foreach (var mappingType in _handlerMappingTypes.AsParallel())
                    {
                        MonitorHandlerBase handler = null;
                        string mappingTypeKey = mappingType.Value.FullName;

                        if (handlerInstances.ContainsKey(mappingTypeKey))
                        {
                            handler = handlerInstances[mappingTypeKey] as MonitorHandlerBase;
                        }
                        else
                        {
                            handler = Activator.CreateInstance(mappingType.Value, true) as MonitorHandlerBase;
                            handlerInstances.Add(mappingTypeKey, handler);
                        }

                        if (handler == null) continue;
                        if (!_handlerMappings.ContainsKey(mappingType.Key))
                        {
                            _handlerMappings.Add(mappingType.Key, handler);
                        }
                    }

                    const string faultKey = "-1_-1";
                    _faultHandler = _handlerMappings[faultKey];
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
                finally
                {
                    if (handlerInstances != null)
                    {
                        handlerInstances.Clear();
                        handlerInstances = null;
                    }
                }
            }
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:50,代码来源:MonitorHandler.cs

示例10: runTest


//.........这里部分代码省略.........
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
                } 
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}b, collection doesn't contain value of new item", i);
                } 
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i+len])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}c, collection doesn't contain key of new item", i);
                } 
                ind = intlValues[i+len];
                iCountTestcases++;
                if (String.Compare(sd[ind], intlValues[i], false) != 0) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}d, returned item \"{1}\" instead of \"{2}\"", i, sd[ind], intlValues[i]);
                } 
            }
            Console.WriteLine("3. Case sensitivity");
            string [] intlValuesLower = new string [len * 2];
            for (int i = 0; i < len * 2; i++) 
            {
                intlValues[i] = intlValues[i].ToUpper();
            }
            for (int i = 0; i < len * 2; i++) 
            {
                intlValuesLower[i] = intlValues[i].ToLower();
            } 
            sd.Clear();
            Console.WriteLine(" initial number of items: " + sd.Count);
            strLoc = "Loc_003oo"; 
            for (int i = 0; i < len; i++) 
            {
                iCountTestcases++;
                cnt = sd.Count;
                sd.Add(intlValues[i+len], intlValues[i]);
                if (sd.Count != cnt+1) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}a, count is {1} instead of {2}", i, sd.Count, cnt+1);
                } 
                iCountTestcases++;
                if (!sd.ContainsValue(intlValues[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}b, collection doesn't contain value of new item", i);
                } 
                iCountTestcases++;
                if (!sd.ContainsKey(intlValues[i+len])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}c, collection doesn't contain key of new item", i);
                } 
                iCountTestcases++;
                if (!caseInsensitive && sd.ContainsValue(intlValuesLower[i])) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0003_{0}d, collection contains lowercase value of new item", i);
                } 
                iCountTestcases++;
                if ( !sd.ContainsKey(intlValuesLower[i+len])) 
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:67,代码来源:co8755add_str_str.cs


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