Exemple #1
0
        public static Config GetConfig(string options)
        {
            var document    = GetDocument(options);
            var rootTagName = document.ChildNodes.OfType <XmlNode>()
                              .First(n => n.Name == FxComConfig.Name || n.Name == FxEnetConfig.Name || n.Name == QConfig.Name)
                              .Name;
            Config config;

            switch (rootTagName)
            {
            case FxComConfig.Name:
                config = new FxComConfig();
                break;

            case FxEnetConfig.Name:
                config = new FxEnetConfig();
                break;

            case QConfig.Name:
                config = new QConfig();
                break;

            default:
                throw new NotSupportedException(rootTagName);
            }
            config.SetDocument(document);
            return(config);
        }
Exemple #2
0
 public void GetSetXmlTest()
 {
     var config = new QConfig()
     {
         Address = "Address",
         Port = 123,
         NetworkNumber = 234,
         PcNumber = 21
     };
     var config2 = new QConfig();
     config2.SetXml(config.GetXml());
     var actual = config.GetXml();
     var expected = config2.GetXml();
     Assert.That(actual, Is.EqualTo(expected));
 }
Exemple #3
0
 public static Config GetConfig(string options)
 {
     var document = GetDocument(options);
     var rootTagName = document.ChildNodes.OfType<XmlNode>()
         .First(n => n.Name == FxComConfig.Name || n.Name == FxEnetConfig.Name || n.Name == QConfig.Name)
         .Name;
     Config config;
     switch (rootTagName)
     {
         case FxComConfig.Name:
             config = new FxComConfig();
             break;
         case FxEnetConfig.Name:
             config = new FxEnetConfig();
             break;
         case QConfig.Name:
             config = new QConfig();
             break;
         default:
             throw new NotSupportedException(rootTagName);
     }
     config.SetDocument(document);
     return config;
 }
 private void UpdateConfig()
 {
     switch (ConfigType)
     {
         case ConfigType.FxCom:
             if (FxComConfig == null)
             {
                 Config = new FxComConfig();
             }
             break;
         case ConfigType.FxEnet:
             if (FxEnetConfig == null)
             {
                 Config = new FxEnetConfig();
             }
             break;
         case ConfigType.Q:
             if (QConfig == null)
             {
                 Config = new QConfig();
             }
             break;
         default:
             throw new NotSupportedException(ConfigType.ToString());
     }
 }