Example #1
0
        public async Task InitializeAsync()
        {
            var options = new TOptions();
            var builder = ComposeResourceBuilder.New();

            options.Configure(builder);
            Settings = builder.Build();

            foreach (var name in BuildStartOrder())
            {
                var mgr = new ComposeResourceManager();
                mgr.ResourceSettings = Settings.Resources.First(x => x.Name == name);
                Managers.Add(name, mgr);

                var variables = new List <string>();
                foreach (ComposeResourceLink link in mgr.ResourceSettings.Links)
                {
                    foreach (EnvironmentVariableMapping map in link.EnvironmentVariables)
                    {
                        Dictionary <string, string> exports = Managers[link.Name].Exports;
                        variables.Add($"{map.Name}={GetVariableValue(map.Value, exports)}");
                    }
                }
                mgr.EnvironmentVariables = Settings.GlobalEnvionmentVariables.Concat(variables);
                await mgr.StartAsync();
            }
        }
Example #2
0
        public TResource GetResource <TResource>(string name)
        {
            ComposeResourceManager manager = Managers[name];

            return((TResource)manager.Resource);
        }