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


C# NameValueCollection.Get方法代码示例

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


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

示例1: Add

        public void Add()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            Assert.False(nameValueCollection.HasKeys());
            for (int i = 0; i < 10; i++)
            {
                string name = "Name_" + i;
                string value = "Value_" + i;
                nameValueCollection.Add(name, value);
                Assert.Equal(i + 1, nameValueCollection.Count);
                Assert.Equal(i + 1, nameValueCollection.AllKeys.Length);
                Assert.Equal(i + 1, nameValueCollection.Keys.Count);

                // We should be able to access values by the name
                Assert.Equal(value, nameValueCollection[name]);
                Assert.Equal(value, nameValueCollection.Get(name));

                Assert.Contains(name, nameValueCollection.AllKeys);
                Assert.Contains(name, nameValueCollection.Keys.Cast<string>());

                Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name));

                // Get(string), GetValues(string) and this[string] should be case insensitive
                Assert.Equal(value, nameValueCollection[name.ToUpperInvariant()]);
                Assert.Equal(value, nameValueCollection[name.ToLowerInvariant()]);

                Assert.Equal(value, nameValueCollection.Get(name.ToUpperInvariant()));
                Assert.Equal(value, nameValueCollection.Get(name.ToLowerInvariant()));

                Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name.ToUpperInvariant()));
                Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name.ToLowerInvariant()));

                Assert.DoesNotContain(name.ToUpperInvariant(), nameValueCollection.AllKeys);
                Assert.DoesNotContain(name.ToLowerInvariant(), nameValueCollection.AllKeys);

                Assert.DoesNotContain(name.ToUpperInvariant(), nameValueCollection.Keys.Cast<string>());
                Assert.DoesNotContain(name.ToLowerInvariant(), nameValueCollection.Keys.Cast<string>());

                // We should be able to access values and keys in the order they were added
                Assert.Equal(value, nameValueCollection[i]);
                Assert.Equal(value, nameValueCollection.Get(i));
                Assert.Equal(name, nameValueCollection.GetKey(i));
                Assert.Equal(new string[] { value }, nameValueCollection.GetValues(i));
            }
            Assert.True(nameValueCollection.HasKeys());
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:46,代码来源:NameValueCollection.AddStringStringTests.cs

示例2: Set_OvewriteExistingValue

        public void Set_OvewriteExistingValue()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string name = "name";
            string value = "value";
            nameValueCollection.Add(name, "old-value");

            nameValueCollection.Set(name, value);
            Assert.Equal(value, nameValueCollection.Get(name));
            Assert.Equal(new string[] { value }, nameValueCollection.GetValues(name));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:11,代码来源:NameValueCollection.SetTests.cs

示例3: Set

        public void Set()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            int newCount = 10;
            for (int i = 0; i < newCount; i++)
            {
                string newName = "Name_" + i;
                string newValue = "Value_" + i;
                nameValueCollection.Set(newName, newValue);

                Assert.Equal(i + 1, nameValueCollection.Count);
                Assert.Equal(newValue, nameValueCollection.Get(newName));
            }
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:14,代码来源:NameValueCollection.SetTests.cs

示例4: Add_NullName

        public void Add_NullName()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string value = "value";
            nameValueCollection.Add(null, value);
            Assert.Equal(1, nameValueCollection.Count);
            Assert.Equal(1, nameValueCollection.AllKeys.Length);
            Assert.Equal(1, nameValueCollection.Keys.Count);

            Assert.Contains(null, nameValueCollection.AllKeys);
            Assert.Contains(null, nameValueCollection.Keys.Cast<string>());

            Assert.Equal(value, nameValueCollection[null]);
            Assert.Equal(value, nameValueCollection.Get(null));

            Assert.Equal(value, nameValueCollection[0]);
            Assert.Equal(value, nameValueCollection.Get(0));

            Assert.Equal(new string[] { value }, nameValueCollection.GetValues(null));
            Assert.Equal(new string[] { value }, nameValueCollection.GetValues(0));

            Assert.Null(nameValueCollection.GetKey(0));
            Assert.False(nameValueCollection.HasKeys());
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:24,代码来源:NameValueCollection.AddStringStringTests.cs

示例5: CopyFormToDict

    public static Dictionary<string, object> CopyFormToDict(NameValueCollection nv, string[] deleteItems)
    {
        Dictionary<string, object> dict = new Dictionary<string, object>();

        for (int i = 0; i < nv.Count; i++)
        {
            bool toDelete = false;
            if (deleteItems != null)
            {
                foreach (string item in deleteItems)
                {
                    if (item == nv.GetKey(i))
                    {
                        toDelete = true;
                        break;
                    }
                }
            }
            if (toDelete) continue;

            dict.Add(nv.GetKey(i), nv.Get(i));
        }
        return dict;
    }
开发者ID:honj51,项目名称:ideacode,代码行数:24,代码来源:Common.cs

示例6: Set_IsCaseSensitive

 public void Set_IsCaseSensitive()
 {
     NameValueCollection nameValueCollection = new NameValueCollection();
     nameValueCollection.Set("name", "value1");
     nameValueCollection.Set("Name", "value2");
     nameValueCollection.Set("NAME", "value3");
     Assert.Equal(1, nameValueCollection.Count);
     Assert.Equal("value3", nameValueCollection.Get("name"));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:9,代码来源:NameValueCollection.SetTests.cs

示例7: Page_HS3_EnOcean

        public PageReturn Page_HS3_EnOcean(String pPageName, String pCleanName, NameValueCollection pArgs)
        {
            var stb = new StringBuilder();

            string conf_node_id = pArgs.Get("configure_node");
            string conf_controller_id = pArgs.Get("controller_id");
            stb.Append(DivStart("pluginpage", ""));

            // Add message area for (ajax) errors
            stb.Append(DivStart("errormessage", "class='errormessage'"));
            stb.Append(DivEnd());

            stb.Append(DivEnd());
            if (conf_node_id != null)
            {
                stb.AppendLine(DivStart("configuration_" + conf_node_id, ""));
                stb.AppendLine("<h2>Configuration for node " + conf_node_id + "</h2>");
                stb.AppendLine("<form name=\"cfgForm\" method=\"post\" action=\"" + pPageName + "\">");
                stb.AppendLine("<input type=\"hidden\" name=\"controller_id\" value=\"" + conf_controller_id + "\">");
                stb.AppendLine("<input type=\"hidden\" name=\"configure_node\" value=\"" + conf_node_id + "\">");
                stb.AppendLine("<table>");
                stb.AppendLine("<tr><td>");
                stb.AppendLine("Please give device a name: ");
                stb.AppendLine("</td><td>");
                stb.AppendLine("<input type=\"text\" name=\"node_name\" value=\"" + conf_node_id + "\">");
                stb.AppendLine("</td></tr>");
                stb.AppendLine("<tr><td>");
                stb.AppendLine("Please select a device profile: ");
                stb.AppendLine("</td><td>");
                stb.AppendLine("<select name=\"device_profile\" >");
                foreach (var pType in Enum.GetValues(typeof(EnOcean.EDeviceTypes)))
                {
                    if ((int)pType == (int)EnOcean.EDeviceTypes.UNKNOWN)
                        continue;
                    stb.AppendLine("<option value=\"" + (int)pType + "\">" + pType.ToString() + "</option>");
                }
                stb.AppendLine("</select>");
                stb.AppendLine("</td></tr>");
                stb.AppendLine("<tr><td>&nbsp;</td><td>");
                stb.AppendLine("<input type=\"submit\" name=\"Save\">");
                stb.AppendLine("</td></tr>");
                stb.AppendLine("</table>");
                stb.AppendLine("</form>");
                stb.Append(DivEnd());
                stb.AppendLine("<br/>");
                return new PageReturn(stb.ToString(), false);
            }
            stb.AppendLine("<form name=\"cfgForm\" method=\"POST\">");

            stb.AppendLine("<h2>Unconfigured EnOcean devices</h2>\n");
            stb.AppendLine("<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" style=\"width: 100%\">\n");
            stb.AppendLine("<tr><th>Node id</th><th>First seen</th><th>Configured</th><th>Actions</th></tr>");
            foreach (var iface in mCore.GetInterfaces())
            {
                foreach (JObject deviceInfo in iface.getSeenDevices().Values)
                {
                    stb.AppendLine("<tr><td>" + deviceInfo["address"] + "</td><td>" + deviceInfo["first_seen"] + "</td><td>" + deviceInfo["configured"] + "</td>");
                    stb.AppendLine("<td><a href=\"?configure_node=" + deviceInfo["address"] + "&controller_id=" + iface.ControllerId + "\">Configure</a></td>");
                    stb.Append("</tr>");
                }

            }
            stb.AppendLine("</table>");
            stb.Append("<br/>");
            stb.AppendLine("</form>");
            stb.AppendLine(DivEnd());

            return new PageReturn(stb.ToString(), false);
        }
开发者ID:NicolaiPetri,项目名称:HS3_EnOcean_Plugin,代码行数:69,代码来源:PageBuilder.cs

示例8: Page_HS3_EnOcean_Interfaces

        public PageReturn Page_HS3_EnOcean_Interfaces(String pPageName, String pCleanName, NameValueCollection pArgs)
        {
            var stb = new StringBuilder();

            string conf_node_id = pArgs.Get("configure_node");
            stb.Append(DivStart("pluginpage", ""));

            // Add message area for (ajax) errors
            stb.Append(DivStart("errormessage", "class='errormessage'"));
            stb.Append(DivEnd());

            stb.Append(DivEnd());

            var ifList = mCore.GetInterfaces();
            stb.AppendLine("<h3>Existing controllers</h3>");
            stb.AppendLine("<table border=\"1\" style=\"width: 400px\" cellspacing=\"0\">");
            stb.AppendLine("<tr><th>Interface port</th><th>Status</th></tr>");
            int ifCount = 0;
            foreach (var iface in ifList)
            {
                stb.AppendLine("<tr><td>" + iface.getPortName() + "</td><td>" + iface.getControllerStatus() + "</td></tr>");
                ifCount++;
            }
            if (ifCount == 0)
                stb.AppendLine("<tr><td colspan=\"2\">No interfaces added.</td></tr>");
            stb.AppendLine("</table>");
            // TODO: Show table with existing interfaces and status!

            clsJQuery.jqButton ctrlBtnAddInterface = new clsJQuery.jqButton("add_interface", "Add interface", pPageName, true);
            //            var ctrlComPortList = new clsJQuery.jqListBox("com_selector", "");
            stb.AppendLine(FormStart("addForm", pPageName, "POST"));
            stb.AppendLine("<h3>Add new controller instance</h3>");
            stb.AppendLine("<table cellspacing=\"0\">");
            stb.AppendLine("<tr><td>");
            stb.AppendLine("<input type=\"text\" name=\"name\" value=\"Primary Controller\">");
            stb.AppendLine("</td><td>");
            stb.AppendLine("<select name=\"com_selector\">\n");
            foreach (var p in SerialPort.GetPortNames())
            {
                var validPort = true;
                foreach (var i in ifList)
                {
                    if (i.getPortName() == p)
                        validPort = false;
                }
                if (validPort)
                    stb.AppendLine("\t<option value=\"" + p + "\">" + p + "</option>\n");
            }
            stb.AppendLine("</select>\n");
            stb.AppendLine("</td></tr>");
              //          stb.Append(ctrlComPortList.Build());
            stb.AppendLine("<tr><td>&nbsp;</td><td>");
            stb.Append("<input type=\"submit\" name=\"add_interface\" value=\"Add\">");
            stb.AppendLine("</td></tr>");
            stb.AppendLine("</table>");
            stb.AppendLine(FormEnd());
            stb.AppendLine("<br/>");
            return new PageReturn(stb.ToString(), false);
        }
开发者ID:NicolaiPetri,项目名称:HS3_EnOcean_Plugin,代码行数:59,代码来源:PageBuilder.cs

示例9: PostHandler_HS3_EnOcean

 public PageReturn PostHandler_HS3_EnOcean(String pPageName, String pCleanName, NameValueCollection pArgs)
 {
     var node_id = pArgs.Get("configure_node");
     var controller_id = pArgs.Get("controller_id");
     var node_type = pArgs.Get("device_profile");
     var node_name = pArgs.Get("node_name");
     var ctrl = mCore.GetInterfaceById(controller_id);
     var newConfig = new JObject();
     newConfig["node_name"] = node_name;
     DeviceTypes.CreateDeviceInstance(HS, ctrl, node_id, node_type, newConfig);
     if (ctrl.getSeenDevices().ContainsKey(node_id))
         ctrl.getSeenDevices().Remove(node_id);
     return new PageReturn("<script>window.location='" + pPageName + "';</script>\n", true);
 }
开发者ID:NicolaiPetri,项目名称:HS3_EnOcean_Plugin,代码行数:14,代码来源:PageBuilder.cs

示例10: PostHandler_HS3_EnOcean_Interfaces

        public PageReturn PostHandler_HS3_EnOcean_Interfaces(String pPageName, String pCleanName, NameValueCollection pArgs)
        {
            var stb = new StringBuilder();
            if (pArgs.Get("add_interface") != null)
            {
                String port = pArgs.Get("com_selector");
                Console.WriteLine("Adding interface: " + port);
                var ifList = mCore.GetInterfaces();
                foreach (var i in ifList)
                {
                    if (i.getPortName() == port)
                        return new PageReturn("ERROR - port exist");
                }

                var initCfg = new JObject();
                initCfg.Add("portname", port);
                var newCtrl = new EnOceanController(hsHost, hsHostCB, pluginInstance, initCfg);
                if (newCtrl.Initialize())
                {
                    newCtrl.SaveConfiguration();
                    mCore.AddInterface(newCtrl);
                }
                else
                {
                    Console.WriteLine("Error adding interface: could not get id");
                    newCtrl.Close();
                }

            }
            return new PageReturn("<script>window.location='" + pPageName + "';</script>\n", true);
        }
开发者ID:NicolaiPetri,项目名称:HS3_EnOcean_Plugin,代码行数:31,代码来源:PageBuilder.cs

示例11: runTest

 public virtual 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";
     NameValueCollection nvc; 
     NameValueCollection nvc1;         
     string [] values = 
     {
         "",
         " ",
         "a",
         "aa",
         "tExt",
         "     SPaces",
         "1",
         "$%^#",
         "2222222222222222222222222",
         System.DateTime.Today.ToString(),
         Int32.MaxValue.ToString()
     };
     string [] names = 
     {
         "zero",
         "oNe",
         " ",
         "",
         "aA",
         "1",
         System.DateTime.Today.ToString(),
         "$%^#",
         Int32.MaxValue.ToString(),
         "     spaces",
         "2222222222222222222222222"
     };
     try
     {
         Console.WriteLine("--- default ctor ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         nvc1 = new NameValueCollection();
         Console.WriteLine("1. Create from another empty collection");
         nvc = new NameValueCollection(nvc1);
         Console.WriteLine("1.1 compare to null");
         iCountTestcases++;
         if (nvc == null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.1, collection is null");
         } 
         Console.WriteLine("1.2. check Count");
         iCountTestcases++;
         if (nvc.Count != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.2, Count = {0} ", nvc.Count);
         }
         Console.WriteLine("1.3. check Get(some_key)");
         iCountTestcases++;
         if (nvc.Get("key") != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.3, Get(some_key) returned non-null after default ctor");
         }
         Console.WriteLine("1.4. check ToString()");
         iCountTestcases++;
         string temp = nvc.ToString();
         Console.WriteLine(" ToString(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.4, ToString() doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("1.5. check returned Type");
         iCountTestcases++;
         temp = nvc.GetType().ToString().Trim();
         Console.WriteLine(" GetType(): " + temp);
         if (temp.IndexOf("NameValueCollection") == -1) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.5: returned type doesn't contain \"NameValueCollection\"");
         }
         Console.WriteLine("1.6. compare returned Type of two collection");
         iCountTestcases++;
         string temp1 = (new NameValueCollection()).GetType().ToString().Trim();
         if (String.Compare(temp, temp1) != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.6: returned types of two collections differ");
         }
         Console.WriteLine("1.7. check AllKeys array");
         iCountTestcases++;
         string [] keys = nvc.AllKeys;
         if ( keys.Length != 0) 
         {  
             iCountErrors++;
             Console.WriteLine("Err_0001.7: AllKeys contains {0} keys after default ctor", keys.Length);
         }
         Console.WriteLine("1.8. check Item(some_key)");
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8719ctor_nvc.cs

示例12: NameValueToSql

    // 根据form提交的数据生成对应的sql语句
    public static string NameValueToSql(NameValueCollection nvc, string table, string primary, bool insert)
    {
        string shortTableName = table;
        if (table.IndexOf('.') > -1)
        {
            shortTableName = table.Substring(table.IndexOf('.')+1);
        }
        Dictionary<string, string> columns = GetAllTableColumns(shortTableName);

        if (insert)
        {
            StringBuilder names = new StringBuilder();
            StringBuilder values = new StringBuilder();

            foreach (String name in nvc.AllKeys)
            {
                string value = nvc.Get(name);
                if (!columns.ContainsKey(name)) continue;
                bool quote = true;
                // TODO: SQL 关键字处理
                if (name == primary)
                {
                    continue;
                }
                else if (value == "null" || columns[name] == "56" || columns[name] == "60") // 数字
                {
                    quote = false;
                }
                names.AppendFormat("{0},", name);
                if (quote)
                {
                    values.AppendFormat("'{0}',", value);
                }
                else
                {
                    values.AppendFormat("{0},", value);
                }
            }
            names.Remove(names.Length - 1, 1);
            values.Remove(values.Length - 1, 1);

            return string.Format("insert into {0} ({1}) values ({2})", table, names.ToString(), values.ToString());
        }
        else
        {
            StringBuilder sb = new StringBuilder();

            foreach (String s in nvc.AllKeys)
            {
                if (!columns.ContainsKey(s)) continue;
                // TODO: SQL 关键字处理
                if (s == primary)
                {
                    if (insert)
                    {
                        sb.AppendFormat("{0}={1},", s, nvc.Get(s));
                        // TODO: 自增?
                    }
                }
                else if (columns[s] == "56" || columns[s] == "60") // 数字,money
                {
                    sb.AppendFormat("{0}={1},", s, nvc.Get(s));
                }
                else
                {
                    sb.AppendFormat("{0}='{1}',", s, nvc.Get(s));
                }
            }
            sb.Remove(sb.Length - 1, 1);

            return string.Format("update {0} set {1} where {2}='{3}'", table, sb.ToString(), primary, nvc.Get(primary));
        }
    }
开发者ID:honj51,项目名称:ideacode,代码行数:74,代码来源:SqlBuilder.cs

示例13: Add_NullValue

        public void Add_NullValue()
        {
            NameValueCollection nameValueCollection = new NameValueCollection();
            string name = "name";
            nameValueCollection.Add(name, null);
            Assert.Equal(1, nameValueCollection.Count);
            Assert.Equal(1, nameValueCollection.AllKeys.Length);
            Assert.Equal(1, nameValueCollection.Keys.Count);

            Assert.Contains(name, nameValueCollection.AllKeys);
            Assert.Contains(name, nameValueCollection.Keys.Cast<string>());

            Assert.Null(nameValueCollection[name]);
            Assert.Null(nameValueCollection.Get(name));

            Assert.Null(nameValueCollection[0]);
            Assert.Null(nameValueCollection.Get(0));

            Assert.Null(nameValueCollection.GetValues(name));
            Assert.Null(nameValueCollection.GetValues(0));

            Assert.Equal(name, nameValueCollection.GetKey(0));
            Assert.True(nameValueCollection.HasKeys());
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:24,代码来源:NameValueCollection.AddStringStringTests.cs

示例14: 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";
     NameValueCollection nvc; 
     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 collection ---");
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         nvc = new NameValueCollection();
         Console.WriteLine("1. Get() on empty collection");
         iCountTestcases++;
         Console.WriteLine("     - Get(-1)");
         try 
         {
             nvc.Get(-1);
             iCountErrors++;
             Console.WriteLine("Err_0001a, no exception");
         }
         catch (ArgumentOutOfRangeException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_001b, unexpected exception: {0}", e.ToString());
         }
         iCountTestcases++;
         Console.WriteLine("     - Get(0)");
         try 
         {
             nvc.Get(0);
             iCountErrors++;
             Console.WriteLine("Err_0001c, no exception");
         }
         catch (ArgumentException ex) 
         {
             Console.WriteLine("  Expected exception: {0}", ex.Message);
         }
         catch (Exception e) 
         {
             iCountErrors++;
             Console.WriteLine("Err_001d, unexpected exception: {0}", e.ToString());
         }
         Console.WriteLine("2. add simple strings access them via Get()");
         strLoc = "Loc_002oo"; 
         iCountTestcases++;
         cnt = nvc.Count;
         int len = values.Length;
         for (int i = 0; i < len; i++) 
         {
             nvc.Add(keys[i], values[i]);
         }
         if (nvc.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002a, count is {0} instead of {1}", nvc.Count, values.Length);
         } 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             if ( String.Compare(nvc.Get(i), values[i], false) != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}b, returned: \"{1}\", expected \"{2}\"", i, nvc.Get(i), values[i]);
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8725get_int.cs

示例15: runTest

 public virtual 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";
     NameValueCollection nvc; 
     string [] values = 
     {
         "item",
         "Item",
         "iTem"
     };
     string [] names = 
     {
         "key",
         "Key",
         "kEy"
     };
     string exp = "";
     try
     {
         strLoc = "Loc_001oo"; 
         iCountTestcases++;
         for (int i = 0; i < values.Length; i++) 
         {
             if (i == 0)
                 exp += values[i];
             else
                 exp += "," + values[i];
         }
         Console.WriteLine("1. ctor(int, sensitive_IHashCodeProvider, case_insensitive_comparer)");
         Console.WriteLine(" 1.1. Capacity 0");
         nvc = new NameValueCollection(0, new Co8775_SensitiveHashCodeProvider(), new Co8775_CaseInsensitiveComparer());
         iCountTestcases++;
         int len = values.Length;
         for (int i = 0; i < len; i++) 
         {
             nvc.Add(names[i], values[i]);
         }
         if (nvc.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.1a, Count is {0} instead of {1}", nvc.Count, len);
         } 
         iCountTestcases++;
         if (String.Compare(nvc[names[0]], values[0], false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.1b, returned {0} instead of {1}", nvc[names[0]], values[0]);
         }
         iCountTestcases++;
         if (nvc["KEY"] != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.1c, returned {0} instead of null", nvc.Get("KEY"));
         }
         Console.WriteLine(" 1.2. Capacity 10");
         nvc = new NameValueCollection(10, new Co8775_SensitiveHashCodeProvider(), new Co8775_CaseInsensitiveComparer());
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {
             nvc.Add(names[i], values[i]);
         }
         if (nvc.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.2a, Count is {0} instead of {1}", nvc.Count, len);
         } 
         iCountTestcases++;
         if (String.Compare(nvc[names[0]], values[0], false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.2b, returned {0} instead of {1}", nvc[names[0]], values[0]);
         }
         iCountTestcases++;
         if (nvc["KEY"] != null) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.2c, returned {0} instead of null", nvc.Get("KEY"));
         }
         Console.WriteLine(" 1.3. Capacity 100");
         nvc = new NameValueCollection(100, new Co8775_SensitiveHashCodeProvider(), new Co8775_CaseInsensitiveComparer());
         iCountTestcases++;
         for (int i = 0; i < len; i++) 
         {
             nvc.Add(names[i], values[i]);
         }
         if (nvc.Count != len) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.3a, Count is {0} instead of {1}", nvc.Count, len);
         } 
         iCountTestcases++;
         if (String.Compare(nvc[names[0]], values[0], false) != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001.3b, returned {0} instead of {1}", nvc[names[0]], values[0]);
         }
         iCountTestcases++;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8775ctor_int_ihcp_ic.cs


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