public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);

            // Create configuration
            SchoolRegistrySection section = new SchoolRegistrySection();

            // NOTE: Can really be any name, but the same name must be used when reading.
            config.Sections.Add("schoolRegistrySection", section);

            Professor flimflop = new Professor {
                Name = "Dr. Flimflop", YearOfBirth = 1968
            };

            section.Professors.Add(flimflop);
            Professor mania = new Professor {
                Name = "Dr. Maniä", YearOfBirth = 1972
            };

            section.Professors.Add(mania);

            Student johnson = new Student {
                Name = "Johnson", YearOfBirth = 1989
            };

            section.Students.Add(johnson);
            mania.Students.Add(johnson);

            config.Save();
        }
        public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);

            // Create configuration
            //ExternalTypesFooDemoGroup grp = new ExternalTypesFooDemoGroup();
            ConfigurationSectionGroup sectionGroup = new ConfigurationSectionGroup();

            ExternalTypesFooDemoSection section = new ExternalTypesFooDemoSection();

            config.SectionGroups.Add("externalTypesFooDemoGroup", sectionGroup);

            config.Sections.Add("externalTypesFooDemoSection", section);

            section.Foo.Baz = new CustomBlock {
                Height = 42, Width = 314, Depth = 312
            };

            section.Bars.Add(new Bar {
                Crackle = 3.14F, Snap = true
            });
            section.Bars.Add(new Bar {
                Crackle = 2.71828F, Snap = false
            });

            config.Save();
        }
        public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);


            // Create configuration
            var defaultCollDemoSection = new DefaultCollDemoSection();

            // NOTE: Can really be any name, but the same name must be used when reading.
            config.Sections.Add("defaultCollDemoSection", defaultCollDemoSection);

            // Create configuration
            var keylessCollectionSection = new KeylessCollectionSection();

            // NOTE: Can really be any name, but the same name must be used when reading.
            config.Sections.Add("keylessCollectionSection", keylessCollectionSection);



            config.Save();
        }
        public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);


            throw new NotImplementedException();



            config.Save();
        }
예제 #5
0
        public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);

            // Create configuration
            var section = new ValidationSampleSection();

            // NOTE: Can really be any name, but the same name must be used when reading.
            config.Sections.Add("validationSampleSection", section);

            var foo = new Samples.Configuration.ValidationSample.Foo();

            foo.Baz     = "I have dots!..."; // Exception will fire here!
            section.Foo = foo;

            config.Save();
        }
        public static ConfigurationFile CreateTempConfigurationFile(SampleRunnerOptions options, ITempSampleConfigFileCreator sampleCreator)
        {
            ConfigurationFile configFile = new ConfigurationFile {
                IsTempFile = true
            };

            //WriteStartResult(groupName + " DEMO");
            try
            {
                // Create temp config file
                string newConfigFilePath = "";
                sampleCreator.CreateConfigFile(options, out newConfigFilePath);
                //configFile.OnTempConfigFileCreated(configFilePath);
                configFile.ConfigFilePath = newConfigFilePath;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(configFile);
        }
        public void CreateConfigFile(SampleRunnerOptions options, out string newConfigFilePath)
        {
            newConfigFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".config");
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = newConfigFilePath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None, options.EnablePreloadConfigFileCheckBox);

            // Create configuration
            var section = new SimpleSection();

            // NOTE: Can really be any name, but the same name must be used when reading.
            config.Sections.Add("simpleSection", section);

            var simple = new Samples.Configuration.SimpleSample.SimpleElement();

            simple.Foo = "fooval";
            simple.Bar = "barval";

            config.Save();
        }