Beispiel #1
0
        public MainViewModel()
        {
            this.RunCommand = new DelegateCommand(Execute);

            var factory = new ConfigFactory();

            this._executer = new Executer(factory.Create <CommonConfig>(), factory.Create <BFCommandConfig>());
        }
        private IConfig CreateConfig(string xml)
        {
            var document = new XmlDocument();

            document.LoadXml(xml);
            return(ConfigFactory.Create("config", document.DocumentElement));
        }
        private static IConfig GetConfig()
        {
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(string.Format(testConfig));
            return(ConfigFactory.Create("testConfig", xmlDocument.DocumentElement));
        }
Beispiel #4
0
        private IConfig CreateConfig(string xml)
        {
            var document = new XmlDocument();

            document.LoadXml(string.Format("<config><ldapServers>{0}</ldapServers></config>", xml));
            return(ConfigFactory.Create("config", document.DocumentElement));
        }
Beispiel #5
0
        public static string GetConfigValue(String path, string key)
        {
            string  value  = "";
            IConfig config = ConfigFactory.Create(AppDomain.CurrentDomain.BaseDirectory + @"bin\" + path + ".config");

            value = config.GetValue(key);
            return(value);
        }
        public void Create_WithNullName_ThrowsException()
        {
            var logger  = new Mock <ILogger <ConfigFactory <ClientConfig> > >(MockBehavior.Loose);
            var factory = new ConfigFactory <ClientConfig>(logger.Object);

            Assert.ThrowsException <ArgumentException>(
                () => factory.Create(null), "Create should throw.");
        }
        public void Create_WithEmptyJson_ReturnsNull()
        {
            string setting = "{ }";
            var    logger  = new Mock <ILogger <ConfigFactory <ClientConfig> > >(MockBehavior.Loose);
            var    factory = new ConfigFactory <ClientConfig>(logger.Object);

            ClientConfig client = factory.Create(setting);

            Assert.IsNull(client, "Client config should be null");
        }
Beispiel #8
0
 public void InitConfigs()
 {
     ConfigFactory.Create <ClassConfig>(ClassConfig.ID);
     ConfigFactory.Create <RaceConfig>(RaceConfig.ID);
     ConfigFactory.Create <DungeonConfig>(DungeonConfig.ID);
     ConfigFactory.Create <EquipConfig>(EquipConfig.ID);
     ConfigFactory.Create <NamesConfig>(NamesConfig.ID);
     ConfigFactory.Create <MapConfig>(MapConfig.ID);
     ConfigFactory.Create <RoomConfig>(RoomConfig.ID);
     ConfigFactory.Create <EventConfig>(EventConfig.ID);
 }
Beispiel #9
0
        public void ConfigFactorytTest()
        {
            var factory = ConfigFactory.Create("ConfigText.config");

            TestContext.WriteLine(factory.GetAppSettings("LoginServiceBusPassword", false));
            var sec = factory.GetConfigSections("GoogleMailSetting");

            foreach (var configSection in sec)
            {
                TestContext.WriteLine(configSection.SectionType);
            }
        }
Beispiel #10
0
        public void Discarded_WathcerAttachedWhenCreated_ReturnsConfigWithWatcher()
        {
            XmlElement configXmlElement = GetConfigXmlDocument(@"<testconfig />");
            var        configSource     = A.Fake <IConfigSource>();
            var        watcher          = new FakeWatcher();

            A.CallTo(() => configSource.Watcher).Returns(watcher);

            var config = ConfigFactory.Create("testConfig", configXmlElement, configSource);

            Assert.NotNull(config.ConfigSource.Watcher != null);
        }
        public static SystemConfig3 Load()
        {
            if (_configFac == null)
            {
                _configFac = new ConfigFactory();
            }

            var cfg = _configFac.Create();

            cfg.FillDefaulValues();

            return(cfg);
        }
        public void ApplySettings(IList <IOSDSetting> settings)
        {
            ClearOptions();
            ClearScreens();

            ScreenControl.ScreenToCopy = null;

            config = ConfigFactory.Create(settings, Enumerable.Range(1, 6));

            FillGlobalOptions();

            foreach (var scr in config.Screens)
            {
                AddScreen(scr);
            }
        }
Beispiel #13
0
        private static Boolean MainImpl(String[] args)
        {
            AppArgs appArgs = AppArgsParser.Parse(args);

            switch (appArgs.Mode)
            {
            case AppUsageMode.Help:
                Console.WriteLine(AppDescription);
                return(true);

            case AppUsageMode.Version:
                Console.WriteLine(VersionNumber);
                return(true);

            case AppUsageMode.Analysis:
                Console.OutputEncoding = Encoding.UTF8;
                IConfig externalConfig = ConfigFactory.Create(appArgs);
                if (externalConfig == null)
                {
                    Console.Error.WriteLine(BadConfigMessage);
                    return(false);
                }
                OutputImpl            output    = new OutputImpl(Console.Out, Console.Error, appArgs.OutputLevel);
                ISourceProcessor      processor = SourceProcessorFactory.Create(appArgs.Source, externalConfig, output);
                IList <IFileAnalyzer> analyzers = AnalyzersFactory.Create(output);
                Boolean processResult           = processor.Process(analyzers);
                output.WriteInfoLine($"Result of analysis: analysis is {(processResult ? "succeeded" : "failed")}");
                return(processResult);

            case AppUsageMode.BadSource:
                Console.Error.WriteLine(BadSourceMessage);
                return(false);

            case AppUsageMode.BadConfig:
                Console.Error.WriteLine(BadConfigMessage);
                return(false);

            case AppUsageMode.BadAppUsage:
            case AppUsageMode.Unknown:
                Console.Error.WriteLine(BadUsageMessage);
                Console.WriteLine(AppDescription);
                return(false);

            default:
                throw new InvalidOperationException();
            }
        }
        public void Create_WithValidSetting_ReturnsClientConfig()
        {
            HashSet <string> policies = new HashSet <string> {
                "F", "C", "A"
            };
            string setting = "{ baseAddress : 'https://github.com/', policies : [ 'C', 'A', 'F' ], headers : { 'Accept' : 'application/json' } }";
            var    logger  = new Mock <ILogger <ConfigFactory <ClientConfig> > >(MockBehavior.Loose);
            var    factory = new ConfigFactory <ClientConfig>(logger.Object);

            ClientConfig client = factory.Create(setting);

            Assert.IsNotNull(client, "Client config should not be null");
            Assert.AreEqual("https://github.com/", client.BaseAddress, "Base address should be set correctly");
            Assert.IsTrue(policies.SetEquals(client.Policies), "Policies should be set correctly");
            Assert.AreEqual("C", client.Policies.First(), "Policies should be in correct order");
            Assert.IsTrue(client.RequestHeaders.ContainsKey("Accept"), "Request header should be present");
            Assert.AreEqual("application/json", client.RequestHeaders["Accept"], "Request header should be set correctly");
        }
Beispiel #15
0
        internal static IPredefinedNames GetDummyCommonNames()
        {
            const string settings = @"<settings>
									<predefinedProperties>
										<userName value=""userName"" />
										<firstName value=""firstName"" />
										<fullName value=""fullName"" />
										<lastName value=""lastName"" />
										<description value=""description"" />
										<email value=""email"" />
										<homePage value=""homePage"" />
										<streetAddress value=""address"" />
										<company value=""company"" />
										<department value=""property1"" context=""anotherContext"" />
										<city value=""city"" />
										<telephone value=""telephoneNumber"" />
										<fax value=""fax"" />
										<homeTelephone value=""homeTelephone"" />
										<mobileTelephone value=""mobileTelephone"" />
										<postOfficeBox value=""postOfficeBox"" />
										<postalCode value=""zipCode"" />
										<country value=""country"" />
										<title value=""title"" />
										<passwordQuestion value=""passwordQuestion"" />
										<passwordAnswer value=""passwordAnswer"" />
										<lastActivityDate value=""lastActivityDate"" />
										<creationDate value=""creationDate"" />
										<lastLoginDate value=""lastLoginDate"" />
										<lastPasswordChangedDate value=""lastPasswordChangedDate"" />
										<locked value=""locked"" />
										<active value=""active"" />
										<lastUpdatedDate value=""lastUpdatedDate"" />
										<isAnonymous value=""isAnonymous"" />
									</predefinedProperties>			
								</settings>"                                ;

            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(settings);
            var config = ConfigFactory.Create("config", xmlDocument.DocumentElement);

            return(PredefinedNamesFactory.Create(config));
        }
Beispiel #16
0
        public void Discarded_WathcerAttachedWhenCreated_DiscaredIsCalledWhenWathcerChanged()
        {
            XmlElement configXmlElement = GetConfigXmlDocument(@"<testconfig />");
            var        configSource     = A.Fake <IConfigSource>();
            var        watcher          = new FakeWatcher();

            A.CallTo(() => configSource.Watcher).Returns(watcher);

            var config = ConfigFactory.Create("testConfig", configXmlElement, configSource);

            var listener = new DiscardListener();

            config.Discarded += listener.ConfigDiscarded;

            watcher.OnWatchedFileChange();

            Assert.NotNull(config.ConfigSource.Watcher != null);
            Assert.AreEqual(1, listener.NumberOfCalled);
        }
        public Config GetConfig(String namespaceName)
        {
            Config config;

            m_configs.TryGetValue(namespaceName, out config);

            if (config == null)
            {
                lock (this)
                {
                    m_configs.TryGetValue(namespaceName, out config);

                    if (config == null)
                    {
                        ConfigFactory factory = m_factoryManager.GetFactory(namespaceName);

                        config = factory.Create(namespaceName);
                        m_configs[namespaceName] = config;
                    }
                }
            }

            return(config);
        }
Beispiel #18
0
 internal static System.Configuration.Configuration OpenExeConfiguration(ConfigurationUserLevel userLevel)
 {
     return(ConfigFactory.Create(typeof(ClientSettingsStore.ClientSettingsConfigurationHost), new object[] { userLevel }));
 }
Beispiel #19
0
        private static IConfig GetTestConfig(string innerXml)
        {
            XmlElement configXmlElement = GetConfigXmlDocument(innerXml);

            return(ConfigFactory.Create("testConfig", configXmlElement));
        }
Beispiel #20
0
 public void Create_FromNullStream_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ConfigFactory.Create("myConfig", (System.IO.Stream)null, null));
 }
Beispiel #21
0
 public void Create_FromNullElement_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => ConfigFactory.Create("myConfig", null));
 }