예제 #1
0
        public GremlinConsole(GizmoConfig settings, IInteractiveConsole console)
        {
            _settings = settings;
            _console  = console;

            _connection = new ConnectionManager(_settings, _console);
        }
예제 #2
0
 public CommandDefinitions(GizmoConfig settings, IInteractiveConsole console, ConnectionManager connectionManager)
 {
     _settings           = settings;
     _console            = console;
     _connectionManager  = connectionManager;
     _connectionCommands = new ConnectionCommands(settings, console);
 }
예제 #3
0
        public CommandDefinitionTest()
        {
            var console           = new InteractiveConsole();
            var settings          = new GizmoConfig();
            var connectionManager = new ConnectionManager(settings, console);

            definitions = new CommandDefinitions(settings, console, connectionManager);
        }
예제 #4
0
        public async Task <int> AddConnection(string connectionName, CosmosDbConnection connection, bool global = false)
        {
            string configPath = global ? GizmoConfig.ProfileConfigPath : GizmoConfig.LocalConfigPath;

            _console.WriteLine($"Adding {connectionName} to {configPath}");

            var settings = await GizmoConfig.LoadConfig(configPath);

            settings.CosmosDbConnections[connectionName] = connection;
            await GizmoConfig.SaveConfig(configPath, settings);

            return(0);
        }
예제 #5
0
        public async Task <int> RemoveConnection(string connectionName, bool global)
        {
            string configPath = global ? GizmoConfig.ProfileConfigPath : GizmoConfig.LocalConfigPath;

            _console.WriteLine($"Removing {connectionName} from {configPath}");

            var settings = await GizmoConfig.LoadConfig(configPath);

            settings.CosmosDbConnections.Remove(connectionName);
            await GizmoConfig.SaveConfig(configPath, settings);

            return(0);
        }
예제 #6
0
        private static IContainer BuildContainer()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterType <InteractiveConsole>().As <IInteractiveConsole>().As <IConsole>().SingleInstance();
            containerBuilder.Register(c =>
            {
                var builder  = GetConfig();
                var settings = new GizmoConfig();
                builder.Bind(settings);
                return(settings);
            }).As <GizmoConfig>();

            containerBuilder.RegisterType <CommandDefinitions>().AsSelf();
            containerBuilder.RegisterType <ConnectionManager>().AsSelf().SingleInstance();

            var container = containerBuilder.Build();

            return(container);
        }
예제 #7
0
 public ConnectionCommands(GizmoConfig settings, IConsole console)
 {
     _settings = settings;
     _console  = console;
 }
예제 #8
0
 public ConnectionManager(GizmoConfig settings, IConsole console)
 {
     _settings = settings;
     _console  = console;
 }