예제 #1
0
        public static void Initialize(IReadOnlyDictionary <string, string> appSettings)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("SampleConfiguration cannot be set twice!");
            }

            Instance = new SampleConfiguration(appSettings);
        }
예제 #2
0
        private void LoadSampleConfiguration(DotvvmConfiguration config, string applicationPath)
        {
            var jsonText = File.ReadAllText(Path.Combine(applicationPath, "sampleConfig.json"));
            var json     = JObject.Parse(jsonText);

            // find active profile
            var activeProfile = json.Value <string>("activeProfile");

            var profiles = json.Value <JArray>("profiles");
            var profile  = profiles.Single(p => p.Value <string>("name") == activeProfile);

            JsonConvert.PopulateObject(profile.Value <JObject>("config").ToString(), config);

            SampleConfiguration.Initialize(
                json.Value <JObject>("appSettings").Properties().ToDictionary(p => p.Name, p => p.Value.Value <string>())
                );
        }