Пример #1
0
        public YamlServiceConfig(string baseName, string directory)
        {
            this.defaults = new DefaultSettings();

            this.BaseName = baseName;
            this.BasePath = Path.Combine(directory, baseName);

            using (var reader = new StreamReader(this.BasePath + ".yml"))
            {
                var deserializer = new DeserializerBuilder().IgnoreUnmatchedProperties().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
                this.raw = deserializer.Deserialize <RawYamlServiceConfig>(reader);
            }

            Environment.SetEnvironmentVariable("BASE", directory);

            // ditto for ID
            Environment.SetEnvironmentVariable("SERVICE_ID", this.Name);

            // New name
            Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameExecutablePath, this.ExecutablePath);

            // Also inject system environment variables
            Environment.SetEnvironmentVariable(WinSWSystem.EnvVarNameServiceId, this.Name);

            this.LoadEnvironmentVariables();
        }
Пример #2
0
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
        private YamlServiceConfig(RawYamlServiceConfig raw)
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
        {
            this.defaults = new DefaultSettings();
            this.raw      = raw;
        }