コード例 #1
0
        public ShellContext CreateShellContext(IShellSettings settings)
        {
            // Build minimal shell descriptor
            var describedContext = CreateDescribedContext(settings, MinimumShellDescriptor());

            // Do we have a shell descriptor within the database
            IShellDescriptor currentDescriptor = null;

            using (var scope = describedContext.CreateServiceScope())
            {
                var shellDescriptorStore = scope.ServiceProvider.GetService <IShellDescriptorStore>();
                var descriptor           = shellDescriptorStore.GetAsync().Result;
                if (descriptor != null)
                {
                    currentDescriptor = descriptor;
                }
            }

            if (currentDescriptor != null)
            {
                return(CreateDescribedContext(settings, currentDescriptor));
            }

            return(describedContext);
        }
コード例 #2
0
        public Task <IShellDescriptor> GetAsync()
        {
            if (_shellDescriptor == null)
            {
                _shellDescriptor = new ShellDescriptor
                {
                    Modules = _shellFeatures.ToList()
                };
            }

            return(Task.FromResult(_shellDescriptor));
        }
コード例 #3
0
        public ShellContext CreateDescribedContext(IShellSettings settings, IShellDescriptor descriptor)
        {
            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug("Creating described context for tenant {0}", settings.Name);
            }

            var blueprint       = _compositionStrategy.ComposeAsync(settings, descriptor).Result;
            var serviceProvider = _shellContainerFactory.CreateContainer(settings, blueprint);

            return(new ShellContext
            {
                Settings = settings,
                Blueprint = blueprint,
                ServiceProvider = serviceProvider
            });
        }
コード例 #4
0
        public async Task <ShellBlueprint> ComposeAsync(IShellSettings settings, IShellDescriptor descriptor)
        {
            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug($"Composing blueprint for tennet {settings.Name} ");
            }

            // Get all module names registered with the current tennet
            var moduleNames = descriptor.Modules.Select(x => x.ModuleId).ToArray();

            // Get module entries for active modules
            var modules = await _moduleManager.LoadModulesAsync(moduleNames);

            //// Get all dependencies for loaded modules
            var entries = new Dictionary <Type, IModuleEntry>();

            if (modules != null)
            {
                foreach (var module in modules)
                {
                    var types = module.Assemblies.SelectMany(assembly =>
                                                             assembly.ExportedTypes.Where(IsComponentType));
                    foreach (var type in types)
                    {
                        if (!entries.ContainsKey(type))
                        {
                            entries.Add(type, module);
                        }
                    }
                }
            }

            var result = new ShellBlueprint
            {
                Settings     = settings,
                Descriptor   = descriptor,
                Dependencies = entries
            };

            if (_logger.IsEnabled(LogLevel.Debug))
            {
                _logger.LogDebug("Done composing blueprint");
            }
            return(result);
        }
コード例 #5
0
        public static void ChangeFolder(this ConEmuControl terminal, IShellDescriptor shell, string path)
        {
            if (terminal?.RunningSession is null || shell is null || string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            string command = shell.GetChangeDirCommand(path);

            switch (shell.Name)
            {
            case BashShell.ShellName:
                terminal.RunningSession.BeginGuiMacro("Keys").WithParam("^A").WithParam("^K").ExecuteSync();
                terminal.RunningSession.WriteInputTextAsync(command + Environment.NewLine);
                break;

            default:
                terminal.RunningSession.WriteInputTextAsync($"\x1B{command}{Environment.NewLine}");
                break;
            }
        }
コード例 #6
0
ファイル: ShellDescriptorStore.cs プロジェクト: radtek/Plato
        public async Task <IShellDescriptor> SaveAsync(IShellDescriptor shellDescriptor)
        {
            // Add & get features
            var features = await AddAndGetFeaturesAsync(shellDescriptor.Modules);;

            shellDescriptor.Modules = features.ToList();

            // Update descriptor
            var descriptor = await _dictionaryStore.UpdateAsync <ShellDescriptor>(Key, shellDescriptor);

            if (descriptor != null)
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation($"Shell descriptor updated successfully");
                }
                // Expire cache
                _cacheManager.CancelTokens(this.GetType(), Key);
            }

            return(descriptor);
        }
コード例 #7
0
 public Task <IShellDescriptor> SaveAsync(IShellDescriptor model)
 {
     return(Task.FromResult(default(IShellDescriptor)));
 }