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


C# NameValueCollection.Set方法代码示例

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


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

示例1: 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

示例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: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string url = QueryHelper.GetString("splitUrl", null);

        if (!string.IsNullOrEmpty(url) && CMSContext.DisplaySplitMode)
        {
            // Register script files
            ltlScript.Text += ScriptHelper.GetIncludeScript("~/CMSModules/Content/CMSDesk/SplitView.js");

            // Decode url
            url = HttpUtility.UrlDecode(url);

            // Update view mode
            UpdateViewMode(CMSContext.ViewMode);

            // Set frame1 url
            docSplitView.Frame1Url = url;

            // Get the URL of the other frame
            NameValueCollection param = new NameValueCollection();
            param.Add("culture", CMSContext.SplitModeCultureCode);

            // Set frame2 url
            docSplitView.Frame2Url = VirtualContext.GetVirtualContextPath(url, param);

            // Set script prefix
            param.Set("culture", "##c##");
            string scriptPrefix = VirtualContext.GetVirtualContextPrefix(param);

            StringBuilder script = new StringBuilder();
            script.Append(
        @"function InitSplitViewSyncScroll(frameElement, body, refreshSameCulture, unbind) {
          if (InitSyncScroll) {
        InitSyncScroll(frameElement, body, refreshSameCulture, unbind);
          }
        }
        function SplitModeRefreshFrame() {
        if (FSP_SplitModeRefreshFrame) {
        FSP_SplitModeRefreshFrame();
        }
        }
        var FSP_appPref = '", URLHelper.GetFullApplicationUrl(), @"';
        var FSP_cntPref = '", scriptPrefix, "';");

            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "splitViewSync_" + Page.ClientID, ScriptHelper.GetScript(script.ToString()));
        }
    }
开发者ID:v-jli,项目名称:jean0407large,代码行数:47,代码来源:SplitView.aspx.cs

示例5: 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. set new simple strings");
         for (int i = 0; i < values.Length; i++) 
         {
             iCountTestcases++;
             cnt = nvc.Count;
             nvc.Set(keys[i], values[i]);
             if (nvc.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}a, count is {1} instead of {2}", i, nvc.Count, cnt+1);
             } 
             iCountTestcases++;
             if (Array.IndexOf(nvc.AllKeys, keys[i]) < 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}b, collection doesn't contain key of new item", i);
             } 
             iCountTestcases++;
             if (String.Compare(nvc[keys[i]], values[i], false) != 0) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}c, returned item \"{1}\" instead of \"{2}\"", i, nvc[keys[i]], values[i]);
             } 
         }
         Console.WriteLine("2. set new intl strings");
         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;
         } 
         Boolean caseInsensitive = false;
         for (int i = 0; i < len * 2; i++) 
         {
             if(intlValues[i].Length!=0 && intlValues[i].ToLower()==intlValues[i].ToUpper())
                 caseInsensitive = true;
         }
         Console.WriteLine(" initial number of items: " + nvc.Count);
         strLoc = "Loc_002oo"; 
         for (int i = 0; i < len; i++) 
         {
             iCountTestcases++;
             cnt = nvc.Count;
             nvc.Set(intlValues[i+len], intlValues[i]);
             if (nvc.Count != cnt+1) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0002_{0}a, count is {1} instead of {2}", i, nvc.Count, cnt+1);
             } 
             iCountTestcases++;
             if (Array.IndexOf(nvc.AllKeys, intlValues[i+len]) < 0) 
             {
                 iCountErrors++;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co8732set_str_str.cs


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