private void SetValue(XmlNode groupNode, SettingsPropertyValue propVal)
        {
            XmlElement settingNode;

            try
            {
                settingNode = (XmlElement)groupNode.SelectSingleNode("setting[@name='" + propVal.Name + "']");
            }
            catch (Exception ex)
            {
                settingNode = null;
            }

            //Check to see if the node exists, if so then set its new value
            if (settingNode != null)
            {
                var valueNode = (XmlElement)settingNode.SelectSingleNode("value");
                SetValueNodeContentsFromProp(propVal, valueNode);
            }
            else
            {
                settingNode = SettingsXml.CreateElement("setting");
                settingNode.SetAttribute("name", propVal.Name);
                settingNode.SetAttribute("serializeAs", propVal.Property.SerializeAs.ToString());
                var valueNode = SettingsXml.CreateElement("value");
                SetValueNodeContentsFromProp(propVal, valueNode);
                settingNode.AppendChild(valueNode);
                groupNode.AppendChild(settingNode);
            }
        }
Example #2
0
 public void Save(SettingsXml xml, string section)
 {
     xml.OpenSection(section);
     //xml.Write("TailType", CurrentInstalledTestTailType.ToString());
     xml.CloseSection();
     xml.Save();
 }
Example #3
0
        protected virtual SettingsXml LoadSettings(string settingsFilename)
        {
            //ensure the file is existing
            if (!File.Exists(settingsFilename))
            {
                throw new ArgumentException(string.Format("The file '{0}' has been referenced for settings by the configuration file but this file hasn't been not found!", settingsFilename));
            }

            //Create an empty XmlRoot.
            //This is needed because the class settingsXml is not decorated with an attribute "XmlRoot".
            XmlRootAttribute xmlRoot = new XmlRootAttribute();

            xmlRoot.ElementName = "settings";
            xmlRoot.Namespace   = "http://NBi/TestSuite";
            xmlRoot.IsNullable  = true;

            SettingsXml settings = null;

            // Create the XmlReader object.
            using (var xmlReader = BuildXmlReaderForSettings(settingsFilename, false))
            {
                // Create an instance of the XmlSerializer specifying type.
                var serializer = new XmlSerializer(typeof(SettingsXml), xmlRoot);
                // Use the Deserialize method to restore the object's state.
                settings = (SettingsXml)serializer.Deserialize(xmlReader);
            }

            return(settings);
        }
 public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
 {
     lock (LockObject)
     {
         //Iterate through the settings to be stored, only dirty settings for this provider are in collection
         foreach (SettingsPropertyValue propval in collection)
         {
             var groupName = context["GroupName"].ToString();
             var groupNode = SettingsXml.SelectSingleNode("/configuration/userSettings/" + context["GroupName"]);
             if (groupNode == null)
             {
                 var parentNode = SettingsXml.SelectSingleNode("/configuration/userSettings");
                 groupNode = SettingsXml.CreateElement(groupName);
                 parentNode.AppendChild(groupNode);
             }
             var section = (XmlElement)SettingsXml.SelectSingleNode("/configuration/configSections/sectionGroup/section");
             if (section == null)
             {
                 var parentNode = SettingsXml.SelectSingleNode("/configuration/configSections/sectionGroup");
                 section = SettingsXml.CreateElement("section");
                 section.SetAttribute("name", groupName);
                 section.SetAttribute("type", String.Format("{0}, {1}", typeof(ClientSettingsSection), Assembly.GetAssembly(typeof(ClientSettingsSection))));
                 parentNode.AppendChild(section);
             }
             SetValue(groupNode, propval);
         }
         Directory.CreateDirectory(UserConfigLocation);
         SettingsXml.Save(Path.Combine(UserConfigLocation, "user.config"));
     }
 }
 public void Load(string section, SettingsXml xml)
 {
     xml.OpenSection(section + "/Sort" + SortName);
     MinSpec = xml.Read("MinSpec", 0.00);
     MaxSpec = xml.Read("MaxSpec", 0.00);
     xml.CloseSection();
 }
Example #6
0
 public TestSuiteXml()
 {
     Tests     = new List <TestXml>();
     Groups    = new List <GroupXml>();
     Settings  = new SettingsXml();
     Variables = new List <GlobalVariableXml>();
 }
 public void Save(string section, SettingsXml xml)
 {
     xml.OpenSection(section + "/Sort" + SortName);
     xml.Write("MinSpec", MinSpec);
     xml.Write("MaxSpec", MaxSpec);
     xml.CloseSection();
 }
 public void Load(string section, SettingsXml xml)
 {
     xml.OpenSection(section + "/DetectCondition" + Name);
     RowTopic = xml.Read("RowTopic", string.Empty);
     ColTopic = xml.Read("ColTopic", string.Empty);
     xml.CloseSection();
 }
 public void Save(string section, SettingsXml xml)
 {
     xml.OpenSection(section + "/DetectCondition" + Name);
     xml.Write("RowTopic", RowTopic);
     xml.Write("ColTopic", ColTopic);
     xml.CloseSection();
 }
Example #10
0
 public ScalarHelper(ServiceLocator serviceLocator, SettingsXml settings, SettingsXml.DefaultScope scope, Context context)
 {
     ServiceLocator = serviceLocator;
     Settings       = settings;
     Scope          = scope;
     Context        = context;
 }
Example #11
0
 public void Load(SettingsXml xml, string section)
 {
     xml.OpenSection(section);
     //CurrentInstalledTestTailType = (HGAProductTailType)Enum.Parse(typeof(HGAProductTailType),
     //xml.Read("TailType", HGAProductTailType.Unknown.ToString()));
     xml.CloseSection();
 }
Example #12
0
        /// <summary>
        /// Store the value as an element of the Settings Root Node
        /// </summary>
        private void CreateRoamingValue(SettingsPropertyValue propVal)
        {
            var settingNode = SettingsXml.CreateElement(propVal.Name);

            settingNode.InnerText = propVal.SerializedValue.ToString();
            SettingsRootNode.AppendChild(settingNode);
        }
 public void Save(string section, SettingsXml xml)
 {
     for (int i = 0; i < _topicListCount; i++)
     {
         _adjacentPads[i].Save(section, xml);
     }
 }
Example #14
0
        void setValue(SettingsPropertyValue propVal)
        {
            var settingNode = getSettingsNode(propVal.Property, propVal.Name) as XmlElement;

            if (settingNode != null)
            {
                settingNode.InnerText = propVal.SerializedValue.ToString();
            }
            else if (isRoaming(propVal.Property))
            {
                settingNode           = SettingsXml.CreateElement(propVal.Name);
                settingNode.InnerText = propVal.SerializedValue.ToString();
                SettingsXml.SelectSingleNode(SettingsRoot).AppendChild(settingNode);
            }
            else
            {
                // it's machine specific, store as an element of the machine name node.
                var machineNode = SettingsXml.SelectSingleNode(SettingsRoot + '/' + Environment.MachineName) as XmlElement;
                if (machineNode == null)
                {
                    machineNode = SettingsXml.CreateElement(Environment.MachineName);
                    SettingsXml.SelectSingleNode(SettingsRoot).AppendChild(machineNode);
                }
                settingNode           = SettingsXml.CreateElement(propVal.Name);
                settingNode.InnerText = propVal.SerializedValue.ToString();
                machineNode.AppendChild(settingNode);
            }
        }
Example #15
0
 public void DefineSettings(IEnumerable <Setting> settings)
 {
     this.settingsXml = new SettingsXml();
     foreach (var s in settings)
     {
         if (s.Name.StartsWith("Default - System-under-test"))
         {
             this.settingsXml.Defaults.Add(new DefaultXml {
                 ApplyTo = SettingsXml.DefaultScope.SystemUnderTest, ConnectionString = s.Value
             });
         }
         else if (s.Name.StartsWith("Default - Assert"))
         {
             this.settingsXml.Defaults.Add(new DefaultXml {
                 ApplyTo = SettingsXml.DefaultScope.Assert, ConnectionString = s.Value
             });
         }
         else
         {
             this.settingsXml.References.Add(new ReferenceXml()
             {
                 Name = s.Name.Split(' ')[2], ConnectionString = s.Value
             });
         }
     }
 }
Example #16
0
        public SettingsXml GetSettingsXml()
        {
            var settings = new SettingsXml();

            settings.ParallelizeQueries = parallelizeQueries;
            if (DefaultSut != null)
            {
                settings.Defaults.Add(DefaultSut);
            }
            if (DefaultAssert != null)
            {
                settings.Defaults.Add(DefaultAssert);
            }

            foreach (var s in Dictionary)
            {
                if (!s.Key.StartsWith("Default"))
                {
                    settings.References.Add(new ReferenceXml()
                    {
                        Name = s.Key.Split(' ')[2], ConnectionString = s.Value
                    });
                }
            }

            return(settings);
        }
Example #17
0
 private void SetValueNodeContentsFromProp(SettingsPropertyValue propVal, XmlElement valueNode)
 {
     if (valueNode == null)
     {
         throw new ArgumentNullException("valueNode");
     }
     if (propVal.Property.SerializeAs == SettingsSerializeAs.String)
     {
         // In some cases the serialized value in the propVal can return null.
         // Set the contents of the setting xml to the empty string in that case.
         var serializedValue = propVal.SerializedValue;
         valueNode.InnerText = serializedValue != null?serializedValue.ToString() : String.Empty;
     }
     else if (propVal.Property.SerializeAs == SettingsSerializeAs.Xml)
     {
         if (!String.IsNullOrEmpty(propVal.SerializedValue as String))
         {
             var subDoc = new XmlDocument();
             subDoc.LoadXml((string)propVal.SerializedValue);
             if (valueNode.FirstChild != null)
             {
                 valueNode.RemoveChild(valueNode.FirstChild);
             }
             valueNode.AppendChild(SettingsXml.ImportNode(subDoc.DocumentElement, true));
         }
     }
     else
     {
         throw new NotImplementedException("CrossPlatformSettingsProvider does not yet handle settings of " +
                                           propVal.Property.SerializeAs);
     }
 }
        private RootElement settings = new RootElement(); // Конфигурация

        /// <inheritdoc />
        /// <summary>Initializes a new instance of the <see cref="T:MemsourceHelper.MainWindow" /> class.</summary>
        public MainWindow()
        {
            this.InitializeComponent();
            this.logger.Info("Запуск программы Memsource Helper.");

            this.Title = $"Memsource Helper v{Assembly.GetExecutingAssembly().GetName().Version}";

            // Вычитывание параметров из XML
            // Инициализация модели настроек
            var settingsXml = new SettingsXml <RootElement>(SettingsPath);

            this.settings.Api = new Api();

            if (!File.Exists(SettingsPath))
            {
                this.settings = this.SetDefaultValue(this.settings); // Значения по умолчанию
                settingsXml.WriteXml(this.settings);
            }
            else
            {
                this.settings = settingsXml.ReadXml(this.settings);
            }

            this.parcer = new XmlParser(this.logger, this.settings);
        }
Example #19
0
 public void Open(string fullPath)
 {
     var manager = new XmlManager();
     manager.Load(fullPath);
     listTestXml =  manager.TestSuite.Tests;
     settingsXml = manager.TestSuite.Settings;
 }
        public void Load(SettingsXml xml, string section)
        {
            HGAProduct.Clear();
            int  pid = 0;
            bool end = false;

            while (!end)
            {
                pid++;
                var pidname = string.Format("PID{0}", pid.ToString());
                xml.OpenSection(section);
                var name = xml.Read(pidname + "/ProductName", string.Empty);

                if (name != String.Empty)
                {
                    HGAProductType GetPid = new HGAProductType(name);
                    GetPid.ConversionBoardID = xml.Read(pidname + "/ConversionBoardID", 0);
                    GetPid.HGATailType       = (HGAProductTailType)Enum.Parse(typeof(HGAProductTailType),
                                                                              xml.Read(pidname + "/HGAProductTailType", HGAProductTailType.Unknown.ToString()));
                    GetPid.TestProbeType    = xml.Read(pidname + "/TestProbeType", String.Empty);
                    GetPid.RecipeGlobalPath = xml.Read(pidname + "/GlobalPath", String.Empty);
                    HGAProduct.Add(GetPid);
                }
                else
                {
                    end = true;
                }
            }

            xml.CloseSection();
        }
        /// <summary>
        /// Its machine specific, store as an element of the machine name node,
        /// creating a new machine name node if one doesnt exist.
        /// </summary>
        private void CreateLocalValue(SettingsPropertyValue propVal)
        {
            XmlElement machineNode;

            try
            {
                machineNode = (XmlElement)SettingsXml.SelectSingleNode(
                    SettingsRootName + "/" + Environment.MachineName);
            }
            catch (Exception)
            {
                machineNode = SettingsXml.CreateElement(Environment.MachineName);
                SettingsRootNode.AppendChild(machineNode);
            }

            if (machineNode == null)
            {
                machineNode = SettingsXml.CreateElement(Environment.MachineName);
                SettingsRootNode.AppendChild(machineNode);
            }

            var settingNode = SettingsXml.CreateElement(propVal.Name);

            settingNode.InnerText = propVal.SerializedValue.ToString();
            machineNode.AppendChild(settingNode);
        }
Example #22
0
 public void Setup(ExecutableXml executableXml, SettingsXml settingsXml, IDictionary <string, ITestVariable> variables)
 {
     obj       = executableXml;
     Settings  = settingsXml ?? SettingsXml.Empty;
     Scope     = SettingsXml.DefaultScope.SystemUnderTest;
     Variables = variables;
     isSetup   = true;
 }
Example #23
0
        public void Open(string fullPath)
        {
            var manager = new XmlManager();

            manager.Load(fullPath);
            listTestXml = manager.TestSuite.Tests;
            settingsXml = manager.TestSuite.Settings;
        }
Example #24
0
        // Constructors & Finalizers -------------------------------------------

        internal FormLayout()
        {
            _fromLayoutTalbe = new Dictionary <string, FormPosition>();

            string filePath = Path.GetDirectoryName(this.GetType().Assembly.Location) + @"\FormLayout.xml";

            _xml = new SettingsXml(filePath);
        }
Example #25
0
 public void Setup(QueryXml queryXml, SettingsXml settingsXml, SettingsXml.DefaultScope scope, IDictionary <string, ITestVariable> variables)
 {
     obj       = queryXml;
     Settings  = settingsXml ?? SettingsXml.Empty;
     Scope     = scope;
     Variables = variables;
     isSetup   = true;
 }
Example #26
0
 public SettingsForm(SettingsXml settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     _settings = settings;
     InitializeComponent();
 }
Example #27
0
        private static void Main(string[] args)
        {
            SettingsAppConfig settings = new SettingsAppConfig();
            string            isbn     = settings.bookstore.book[1].ISBN;
            int someInt = settings.IntValue; // from appSettings

            SettingsXml xmlSettings = new SettingsXml(false);
            decimal     price       = xmlSettings.bookstore.book[0].price;
        }
Example #28
0
        /// <summary>
        /// Gets the Folder Path for the given Platform and Media Type.
        ///
        /// Users can override the default image paths for platforms. This information is stored in the Data/Platforms.xml file in PlatfromFolder nodes.
        /// </summary>
        public static string GetPlatformFolder(string platform, string mediaType)
        {
            XElement platformFolder = (from SettingsXml in PlatformList.Descendants("PlatformFolder")
                                       where SettingsXml.Element("Platform").Value == platform &&
                                       SettingsXml.Element("MediaType").Value == mediaType
                                       select SettingsXml).FirstOrDefault();

            return(platformFolder != null?platformFolder.Element("FolderPath").Value : "");
        }
Example #29
0
        private void LoadSettingsFile()
        {
            SettingsXml s = SettingsXml.Load(Path);

            if (s.F1.Empty)
            {
                throw new Exception("F1 matrix empty");
            }
            if (s.F2.Empty)
            {
                throw new Exception("F2 matrix empty");
            }
            if (s.F1.Cols != s.F1.Rows)
            {
                throw new Exception("F1 matrix must be a square matrix");
            }
            if (s.F2.Cols != s.F2.Rows)
            {
                throw new Exception("F2 matrix must be a square matrix");
            }
            if (s.F1.Cols != s.F2.Cols)
            {
                throw new Exception("F1 must be the same size as F2");
            }

            uint oldCols = engine.Matrix1.Cols;

            if (LoadMatricies)
            {
                engine.Matrix1    = s.F1;
                engine.Matrix2    = s.F2;
                engine.NodesCount = s.F1.Cols;
                engine.Mutation   = s.Mutation;
            }

            if (LoadPopSize)
            {
                engine.IndividualsLength = s.PopSize;
                engine.ReCreateEvolutionary();
            }
            else if (LoadIndividuals)
            {
                engine.Evolutionary.Individuals = s.Individuals;
            }
            else
            {
                if (oldCols != s.F1.Cols)
                {
                    throw new Exception("Cannot leave old population, matricies size are different");
                }

                var copy = engine.Evolutionary.Individuals.ToArray();
                engine.ReCreateEvolutionary();
                engine.Evolutionary.Individuals = copy;
            }
        }
Example #30
0
 public GenerationState()
 {
     CaseCollection = new CaseCollection();
     Templates      = new List <string>();
     Suite          = new RootNode();
     Settings       = new SettingsXml();
     Variables      = new List <GlobalVariableXml>();
     Consumables    = new Dictionary <string, object>();
     (new AutoConsumableAction(true)).Execute(this);
 }
Example #31
0
 public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
 {
     foreach (SettingsPropertyValue propVal in collection)
     {
         setValue(propVal);
     }
     try{
         SettingsXml.Save(Path.Combine(AppSettingsPath, AppSettingsFilename));
     }catch (IOException e) {
         SysDbg.WriteLine("Xml saving error: " + e);
     }
 }
Example #32
0
 public void DefineSettings(IEnumerable<Setting> settings)
 {
     this.settingsXml = new SettingsXml();
     foreach (var s in settings)
     {
         if (s.Name.StartsWith("Default - System-under-test"))
             this.settingsXml.Defaults.Add(new DefaultXml { ApplyTo = SettingsXml.DefaultScope.SystemUnderTest, ConnectionString = s.Value });
         else if (s.Name.StartsWith("Default - Assert"))
             this.settingsXml.Defaults.Add(new DefaultXml { ApplyTo = SettingsXml.DefaultScope.Assert, ConnectionString = s.Value });
         else
             this.settingsXml.References.Add(new ReferenceXml() { Name = s.Name.Split(' ')[2], ConnectionString = s.Value });
     }
 }
        public void GetSystemUnderTest_ConnectionStringInReference_CorrectlyInitialized()
        {
            var sutXml = new MembersXml();

            var item = new HierarchyXml();
            sutXml.Item = item;
            item.Perspective = "perspective";
            item.Dimension = "dimension";
            item.Caption = "hierarchy";
            item.ConnectionString = "@ref-connStr";

            var settingsXml = new SettingsXml();
            settingsXml.References.Add(new ReferenceXml() {Name="ref-connStr", ConnectionString="connectionString-ref"});
            sutXml.Settings = settingsXml;

            var ctrXml = new CountXml();

            var discoFactoMockFactory = new Mock<DiscoveryRequestFactory>();
            discoFactoMockFactory.Setup(dfs =>
                dfs.Build(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<List<string>>(),
                    It.IsAny<List<PatternValue>>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>()))
                    .Returns(new MembersDiscoveryRequest());
            var discoFactoMock = discoFactoMockFactory.Object;

            var builder = new MembersCountBuilder(discoFactoMock);
            builder.Setup(sutXml, ctrXml);
            builder.Build();
            var sut = builder.GetSystemUnderTest();

            Assert.That(sut, Is.InstanceOf<MembersDiscoveryRequest>());
            discoFactoMockFactory.Verify(dfm => dfm.Build("connectionString-ref", It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<PatternValue>>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null));
        }
Example #34
0
        public SettingsXml GetSettingsXml()
        {
            var settings = new SettingsXml();
            settings.ParallelizeQueries = parallelizeQueries;
            if (DefaultSut!=null)
                settings.Defaults.Add(DefaultSut);
            if (DefaultAssert != null)
                settings.Defaults.Add(DefaultAssert);

            foreach (var s in Dictionary)
            {
                if (!s.Key.StartsWith("Default"))
                    settings.References.Add(new ReferenceXml() { Name = s.Key.Split(' ')[2], ConnectionString = s.Value });
            }

            return settings;
        }
Example #35
0
        SyndicationFeed LoadRSS( SettingsXml.RssFeedXml feedSettings )
        {
            if ( feedSettings.IsRss10 )
            {
                try
                {
                    return LoadRSS10( feedSettings.URL );
                }
                catch ( WebException ex )
                {
                    if ( ex.Status != WebExceptionStatus.Timeout )
                    {
                        Log.WriteWarn( "RSS", "Unable to load RSS 1.0 feed {0}: {1}", feedSettings.URL, ex.Message );
                    }

                    return null;
                }
            }

            try
            {
                HttpWebRequest webReq = WebRequest.Create( feedSettings.URL ) as HttpWebRequest;
                webReq.Timeout = ( int )TimeSpan.FromSeconds( 5 ).TotalMilliseconds;
                webReq.ReadWriteTimeout = (int)TimeSpan.FromSeconds( 5 ).TotalMilliseconds;

                using ( var resp = webReq.GetResponse() )
                using ( var reader = DateXmlReader.Create( resp.GetResponseStream() ) )
                {
                    return SyndicationFeed.Load( reader );
                }
            }
            catch ( WebException ex )
            {
                if ( ex.Status != WebExceptionStatus.Timeout )
                {
                    Log.WriteWarn( "RSS", "Unable to load RSS feed {0}: {1}", feedSettings.URL, ex.Message );
                }

                return null;
            }
        }
Example #36
0
 public void DefineSettings(SettingsXml settingsXml)
 {
     this.settingsXml = settingsXml;
 }
Example #37
0
 internal RowCountXml(SettingsXml settings)
 {
     this.Settings = settings;
 }
Example #38
0
 internal EqualToXml(SettingsXml settings)
     : this()
 {
     this.Settings = settings;
 }
 public AbstractSystemUnderTestXml()
 {
     Default = new DefaultXml();
     Settings = new SettingsXml();
 }
Example #40
0
 public TestSuiteXml()
 {
     Tests = new List<TestXml>();
     Groups = new List<GroupXml>();
     Settings = new SettingsXml();
 }
Example #41
0
        public void Serialize_SemiColumnAndCrLf_CsvProfileNotSpecified()
        {
            var settings = new SettingsXml();
            settings.CsvProfile.FieldSeparator = ';';
            settings.CsvProfile.RecordSeparator = "\r\n";

            var manager = new XmlManager();
            var xml = manager.XmlSerializeFrom<SettingsXml>(settings);

            Assert.That(xml, Is.Not.StringContaining("field-separator"));
            Assert.That(xml, Is.Not.StringContaining("record-separator"));
            Assert.That(xml, Is.Not.StringContaining("csv-profile"));
        }
Example #42
0
 public DefaultXml(SettingsXml.DefaultScope applyTo)
     : this()
 {
     ApplyTo = applyTo;
 }
Example #43
0
 public BaseItem()
 {
     Default = new DefaultXml();
     Settings = new SettingsXml();
 }