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


C# Config.GetParameter方法代码示例

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


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

示例1: TestXmlDocumentConstructor

 public void TestXmlDocumentConstructor()
 {
     const string xml =
         @"<components>
             <component name='Comp1'>
                 <parameter name='Param1' value='1_1'/>
                 <parameter name='Param2' value='1_2'/>
                 <parameter name='Param3' value='1_3'/>
             </component>
         </components>";
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xml);
     Config cfg = new Config("SomeApp", doc);
     Assert.IsTrue(cfg.ComponentExists("Comp1"));
     Assert.AreEqual(3, cfg.GetParametersAsList("Comp1").Count);
     Assert.AreEqual("1_1", cfg.GetParameter("Comp1", "Param1"));
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:17,代码来源:ConfigTests.cs

示例2: GetParamInvalidHelper

 /// <summary>
 /// Call GetParameter with invalid params, catch the exception and check the message.
 /// </summary>
 private static void GetParamInvalidHelper(Config cfg, string comp, string parm, string testDesc)
 {
     try
     {
         cfg.GetParameter(comp, parm);
         Assert.Fail("Test '" + testDesc + " didn't throw with comp '" + comp + "' param '" +
             parm + "'.");
     }
     catch (Exception e)
     {
         Assert.IsTrue(e.Message.Contains(comp), "Test '" + testDesc +
             " threw an exception without comp '" + comp +
             "' in the description (param was'" + parm + "'.");
         Assert.IsTrue(e.Message.Contains(parm), "Test '" + testDesc +
             " threw an exception without param '" + parm +
             "' in the description (comp was'" + comp + "'.");
     }
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:21,代码来源:ConfigTests.cs

示例3: TestGetParamValid

 public void TestGetParamValid()
 {
     Config cfg = new Config(VALID_APPNAME);
     for (int comp = 1; comp < 3; comp++)
     {
         for (int parm = 1; parm < 4; parm++)
         {
             Assert.AreEqual(comp + "_" + parm,
                 cfg.GetParameter("Comp" + comp, "Param" + parm),
                 "Wrong value for comp " + comp + " param " + parm);
         }
     }
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:13,代码来源:ConfigTests.cs

示例4: TestGetParamNulls

 public void TestGetParamNulls()
 {
     Config cfg = new Config(VALID_APPNAME);
     try
     {
         cfg.GetParameter("Comp1", null);
         Assert.Fail("Didn't throw with null param.");
     }
     catch (ArgumentNullException e)
     {
         Assert.IsTrue(e.Message.Contains("Comp1"), "Message didn't contain component name.");
     }
     try
     {
         cfg.GetParameter(null, "Param1");
         Assert.Fail("Didn't throw with null component.");
     }
     catch (ArgumentNullException e)
     {
         Assert.IsTrue(e.Message.Contains("Param1"), "Message didn't contain param name.");
     }
     try
     {
         cfg.GetParameter(null, null);
         Assert.Fail("Didn't throw with two nulls.");
     }
     catch (ArgumentNullException)
     {
         // good
     }
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:31,代码来源:ConfigTests.cs

示例5: TestGetParamNonAttr

        public void TestGetParamNonAttr()
        {
            Config cfg = new Config(VALID_APPNAME);

            Assert.AreEqual("\"Non-Attribute Value\"", cfg.GetParameter("NonAttr", "AParam"));
        }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:6,代码来源:ConfigTests.cs

示例6: TestEmptyValue

 public void TestEmptyValue()
 {
     Config cfg = new Config(VALID_APPNAME);
     Assert.AreEqual("", cfg.GetParameter("Comp2", "OnlyIn2"),
         "Wrong value for empty string only in 2");
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:6,代码来源:ConfigTests.cs

示例7: TestCaseInsensitivity

 public void TestCaseInsensitivity()
 {
     // Try all uppercase, should work fine.
     new Config(VALID_APPNAME.ToUpper());
     // Try all lowercase, should also work fine.
     Config cfg = new Config(VALID_APPNAME.ToLower());
     // Try getting parameters using different cases.
     for (int comp = 1; comp < 3; comp++)
     {
         for (int parm = 1; parm < 4; parm++)
         {
             Assert.AreEqual(comp + "_" + parm,
                 cfg.GetParameter("COMP" + comp, "PARAM" + parm),
                 "Wrong value for uppercase comp " + comp + " param " + parm);
             Assert.AreEqual(comp + "_" + parm,
                 cfg.GetParameter("comp" + comp, "param" + parm),
                 "Wrong value for lowercase comp " + comp + " param " + parm);
             Assert.AreEqual(comp + "_" + parm,
                 cfg.GetParameter("cOmP" + comp, "pArAm" + parm),
                 "Wrong value for mixed case comp " + comp + " param " + parm);
         }
     }
 }
开发者ID:azavea,项目名称:net-om-utils-common,代码行数:23,代码来源:ConfigTests.cs


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