Пример #1
0
 public static void Init(string environmentConfig, string config = DEFAULT_CONFIG_FILENAME)
 {
     _currentConfigName = config;
     using (var configStream = GetStreamReader(config))
         using (var environmentStream = GetStreamReader(environmentConfig))
         {
             var xDocument = TransformationHelper.Transform(configStream.ReadToEnd(), environmentStream.ReadToEnd());
             InitInternal(xDocument);
         }
 }
Пример #2
0
        public static void Init(string environmentConfig, string config = DEFAULT_CONFIG_FILENAME)
        {
            _currentConfigName = config;
            using (var configStream = GetStreamReader(config))
                using (var environmentStream = GetStreamReader(environmentConfig))
                {
                    var xDocument = TransformationHelper.Transform(configStream.ReadToEnd(), environmentStream.ReadToEnd());
                    InitInternal(xDocument);
                }

            var files = Directory.EnumerateFiles("Assets", "app.*.config");

            Environments = files.Select(x => x.Split('.')[1]).ToList();
        }
Пример #3
0
        public static void Init(Context context, string environmentConfig, string config = DEFAULT_CONFIG_FILENAME)
        {
            _currentContext    = context;
            _currentConfigName = config;

            using (var configStream = GetStreamReader(config))
                using (var environmentStream = GetStreamReader(environmentConfig))
                {
                    var xDocument = TransformationHelper.Transform(configStream.ReadToEnd(), environmentStream.ReadToEnd());
                    InitInternal(xDocument);
                }

            var assets = CurrentContext.Assets.List("app.*.config");

            Environments = assets.Select(x => x.Split('.')[1]).ToList();
        }
Пример #4
0
        public void Transform(string name)
        {
            if (!_environmentsEnabled)
            {
                return;
            }

            if (EnvironmentExists(name, out var actualEnvironmentName))
            {
                using var configStream      = _platformConfig.GetStreamReader(DefaultAppConfigName);
                using var environmentStream = _platformConfig.GetStreamReader($"app.{actualEnvironmentName}.config");
                var xDocument = TransformationHelper.Transform(configStream.ReadToEnd(), environmentStream.ReadToEnd());
                InitInternal(xDocument);
            }
            else
            {
                Reset();
            }
        }