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


C# Settings.Add方法代码示例

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


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

示例1: SaveAndLoadConfigData

        public void SaveAndLoadConfigData()
        {
            try {
                var config = new BuildStatusConfig();
                config.Settings.Add("PollFrequency", "15");

                var setting = new Settings();
                setting.Add("Host", "nzakledci01:8080");
                setting.Add("ProjectID", "project8");

                var monitor1 = config.Monitors.Add("Monitor1", "Assembly1", "Class1", setting);
                var monitor2 = config.Monitors.Add("Monitor2", "Assembly2", "Class2", setting);

                var visualiser1 = config.Visualisers.Add("Visualiser1", "Assembly1", "Class1",setting);
                var visualiser2 = config.Visualisers.Add("Visualiser2", "Assembly2", "Class2",setting);

                config.Schedules.Add(new Schedule("6:00AM", "8:00PM", "ON", "Week"));
                config.Schedules.DefaultState = "OFF";

                config.Save("C:\\Test.xml");

                BuildStatusConfig newConfig = BuildStatusConfig.Load("C:\\Test.xml");

                Assert.AreEqual(config.Settings["PollFrequency"], newConfig.Settings["PollFrequency"]);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:29,代码来源:ConfigurationTest.cs

示例2: TestMonitorInstantiation

 public void TestMonitorInstantiation()
 {
     var settings = new Settings();
     settings.Add("Host", "nzakledci01:8080");
     settings.Add("ProjectID", "project8");
     var instance = ComponentFactory<IMonitor>.CreateComponent(new Monitor("TestMonitor", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor", settings));
     Assert.IsNotNull(instance);
 }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:8,代码来源:ComponentFactoryTest.cs

示例3: ConnectedTest2

 public void ConnectedTest2()
 {
     var monitor = new TeamCityMonitor();
     var setting = new Settings();
     setting.Add("Host", "nzakledci01:8080");
     setting.Add("ProjectID", "project8");
     monitor.Initialise("Test", setting);
     Assert.IsTrue(monitor.IsInitialised);
 }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:9,代码来源:TeamCityTest.cs

示例4: PollTest

 public void PollTest()
 {
     var monitor = new TeamCityMonitor();
     var setting = new Settings();
     setting.Add("Host", "nzakledci01:8080");
     setting.Add("ProjectID", "project8");
     monitor.Initialise("Test", setting);
     var result = monitor.Poll();
     Assert.IsNotNull(result);
 }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:10,代码来源:TeamCityTest.cs

示例5: MinimalConstructorTest

 public void MinimalConstructorTest()
 {
     var monitor = new TeamCityMonitor();
     var setting = new Settings();
     setting.Add("Host", "Host");
     monitor.Initialise("Test", setting);
     Assert.IsTrue(monitor.IsInitialised);
 }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:8,代码来源:TeamCityTest.cs

示例6: Settings

        void IUtilityCommand.Run(Utility utility, string[] args)
        {
            Game.ModData = utility.ModData;
            Console.WriteLine(
                "This documentation is aimed at server administrators. It displays all settings with default values and description. " +
                "Please do not edit it directly, but add new `[Desc(\"String\")]` tags to the source code. This file has been " +
                "automatically generated for version {0} of OpenRA.", utility.ModData.Manifest.Metadata.Version);
            Console.WriteLine();
            Console.WriteLine("All settings can be changed by starting the game via a command-line parameter like `Game.Mod=ra`.");
            Console.WriteLine();
            Console.WriteLine("## Location");
            Console.WriteLine("* Windows: `My Documents\\OpenRA\\settings.yaml`");
            Console.WriteLine("* Mac OS X: `~/Library/Application Support/OpenRA/settings.yaml`");
            Console.WriteLine("* Linux `~/.openra/settings.yaml`");
            Console.WriteLine();
            Console.WriteLine(
                "If you create the folder `Support` relative to the OpenRA main directory, everything " +
                "including settings gets stored there to aid portable installations.");
            Console.WriteLine();

            var sections = new Settings(null, new Arguments()).Sections;
            sections.Add("Launch", new LaunchArguments(new Arguments(new string[0])));
            foreach (var section in sections.OrderBy(s => s.Key))
            {
                var fields = section.Value.GetType().GetFields();
                if (fields.Length > 0 && fields.Where(field => field.GetCustomAttributes<DescAttribute>(false).Length > 0).Count() > 0)
                    Console.WriteLine("## {0}", section.Key);
                else
                    Console.WriteLine();

                foreach (var field in fields)
                {
                    if (!field.HasAttribute<DescAttribute>())
                        continue;

                    Console.WriteLine("### {0}", field.Name);
                    var lines = field.GetCustomAttributes<DescAttribute>(false).SelectMany(d => d.Lines);
                    foreach (var line in lines)
                    {
                        Console.WriteLine("{0}", line);
                        Console.WriteLine();
                    }

                    var value = field.GetValue(section.Value);
                    if (value != null && !value.ToString().StartsWith("System."))
                    {
                        Console.WriteLine("**Default Value:** {0}", value);
                        Console.WriteLine();
                        Console.WriteLine("```yaml");
                        Console.WriteLine("{0}: ", section.Key);
                        Console.WriteLine("\t{0}: {1}", field.Name, value);
                        Console.WriteLine("```  ");
                    }
                    else
                        Console.WriteLine();
                }
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:58,代码来源:ExtractSettingsDocsCommand.cs

示例7: SaveSettings

 private void SaveSettings()
 {
     List<Control> controls = GetTaggedControls(tabEmail);
     Settings settings = new Settings();
     foreach (Control c in controls)
     {
         settings.Add((String)c.Tag, c.Text);
     }
     Settings.Save(settings);
 }
开发者ID:Infarch,项目名称:MyPerlModules,代码行数:10,代码来源:Form1.cs

示例8: CreateDefaultConfigFile

        /// <summary>
        /// Creates the default configuration File
        /// </summary>
        public static void CreateDefaultConfigFile()
        {
            var config = new BuildStatusConfig();

            #region Add Default Core Data (Schedule and Controllers)
            config.Settings.Add(new Setting("PollFrequency","5"));
            config.Schedules.DefaultState = "OFF";
            config.Schedules.Add(new Schedule("6:00AM", "8:00PM", "ON", "Week"));
            config.Schedules.Add(new Schedule("12:00AM","11:59PM", "OFF", "Weekend"));
            config.Controllers.Add(new Controller("Controller1", "Monitor1","Visualiser1","Transition1"));
            config.Controllers.Add(new Controller("Controller2", "Monitor1","Visualiser2","Transition2"));
            #endregion

            #region Add the Sample Monitors
            var settings1 = new Settings();
            settings1.Add(new Setting("Host","yourhost:8080"));
            settings1.Add(new Setting("User", "guest"));
            settings1.Add(new Setting("Password", "guest"));
            settings1.Add(new Setting("UseGuest", "true"));
            settings1.Add(new Setting("ProjectID", "project2"));
            settings1.Add(new Setting("ProjectID", "project6"));
            settings1.Add(new Setting("ProjectID","project4"));
            config.Monitors.Add(new Monitor("Monitor1", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor",settings1));

            var settings2 = new Settings();
            settings2.Add(new Setting("Host","yourhost:8080"));
            settings2.Add(new Setting("User", "guest"));
            settings2.Add(new Setting("Password", "guest"));
            settings2.Add(new Setting("UseGuest", "true"));
            settings2.Add(new Setting("ProjectID", "projectID"));
            settings2.Add(new Setting("BuildID", "buildID"));
            settings2.Add(new Setting("ProjectName","projectName"));
            config.Monitors.Add(new Monitor("Monitor2", "BuildStatusMonitor", "BuildStatusMonitor.Monitors.TeamCityMonitor",settings2));
            #endregion

            #region Add Sample Visualisers
            var settings3 = new Settings();
            settings3.Add(new Setting("DeviceID",@"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;141d6465&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#1","BuildStatusMonitor","BuildStatusMonitor.Visualisers.DelcomVisualiser",settings3));

            var settings4 = new Settings();
            settings4.Add(new Setting("DeviceID",@"\\?\hid#vid_0fc5&amp;pid_b080#7&amp;26d7150a&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"));
            config.Visualisers.Add(new Visualiser("DelcomLight#2","BuildStatusMonitor","BuildStatusMonitor.Visualisers.DelcomVisualiser",settings4));

            var settings5 = new Settings();
            settings5.Add(new Setting("File",@"C:\Status.Log"));
            config.Visualisers.Add(new Visualiser("FileTrace","BuildStatusMonitor","BuildStatusMonitor.Visualisers.FileTraceVisualiser",settings5));
            #endregion

            #region Add Transitions

            var transition1 = config.Transitions.Add(new Transition("Transition1"));
            var t1s1 = transition1.Add(new State("Unknown","YELLOW:ON",null));
            var t1s2 = transition1.Add(new State("Success","GREEN:ON"));
            t1s2.SubState.Add(new SubState("Success1","TIME:0-15","GREEN:FLASH"));
            var t1s3 = transition1.Add(new State("SuccessInProgress","GREEN:ON;YELLOW:FLASH",null));
            var t1s4 = transition1.Add(new State("Failed","RED:ON"));
            t1s4.SubState.Add(new SubState("Failed1","TIME:0-15","RED:FLASH-SLOW"));
            t1s4.SubState.Add(new SubState("Failed2","TIME:15-30","RED:FLASH"));
            t1s4.SubState.Add(new SubState("Failed3","TIME:30-60","RED:FLASH-FAST"));
            var t1s5 = transition1.Add(new State("FailedInProgress","RED:ON;YELLOW:FLASH",null));
            var t1s6 = transition1.Add(new State("InProgress","YELLOW:FLASH",null));
            var t1s7 = transition1.Add(new State("Error","RED:FLASH",null));

            var transition2 = config.Transitions.Add(new Transition("Transition2"));
            var t2s1 = transition2.Add(new State("Unknown","Build State is UNKNOWN",null));
            var t2s2 = transition2.Add(new State("Success","Build was Sucessfull"));
            t2s2.SubState.Add(new SubState("Success1","TIME:0-15","Build Sucessfull - Ready For QA"));
            var t2s3 = transition2.Add(new State("SuccessInProgress","Last build was Sucessfull. New Build in Progress",null));
            var t2s4 = transition2.Add(new State("Failed","Build Failed."));
            t2s4.SubState.Add(new SubState("Failed1","TIME:0-15","Build Failed: First Warning"));
            t2s4.SubState.Add(new SubState("Failed2","TIME:15-30","Build Failed: Second Warning"));
            t2s4.SubState.Add(new SubState("Failed3","TIME:30-60","Build Failed: Third Warning"));
            var t2s5 = transition2.Add(new State("FailedInProgress","Build Failed - New Build in Progress",null));
            var t2s6 = transition2.Add(new State("InProgress","Build in Progress - Previus State is Unknown",null));
            var t2s7 = transition2.Add(new State("Error","WARNING: Unknown Error Has Occurred",null));
            #endregion

            config.Save("BuildStatusMonitor.settings.sample.xml");
        }
开发者ID:gitsly,项目名称:BuildStatusMonitor,代码行数:83,代码来源:BuildStatusConfig.cs


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