public command_context() { Command = CecilCommandExporter.GetCommandFrom <T>(); Commands = new CommandRepository { Command }; }
static void Main(string[] args) { WrapServices.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); WrapServices.TryRegisterService<IPackageManager>(() => new PackageManager()); var commands = ReadCommands(WrapServices.GetService<IEnvironment>()); var repo = new CommandRepository(commands); WrapServices.TryRegisterService<ICommandRepository>(() => repo); var processor = new CommandLineProcessor(repo); var backedupConsoleColor = System.Console.ForegroundColor; foreach (var commandResult in processor.Execute(args).Where(x => x != null)) { try { if (!commandResult.Success) System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(commandResult); } finally { System.Console.ForegroundColor = backedupConsoleColor; } } System.Console.ReadLine(); }
public PropertyLister(Workspace workspace, Options options, CommandRepository commandRepository, ExtendedExtendedPropertyProvider extendedPropertyProvider) : base(workspace, options, commandRepository) { _extendedPropertyProvider = extendedPropertyProvider; _contentProvider = new FilePropertyProvider(workspace); }
public CommandInitializer(ICommandRepository repository, [Named("CommandHelper")] IHelper <Action> helper, IStaticDataManager staticDataManager) { Repository = (CommandRepository)repository; Helper = helper; _staticDataManager = staticDataManager; }
public EnergyMetersController(CommandRepository commandRepository, UserManager <ApplicationUser> userManager, EnergyMeterRepository energyMeterRepository, IHubContext <ChatHub> chatHubContext) { this.commandRepository = commandRepository; _userManager = userManager; repository = energyMeterRepository; _chatHubContext = chatHubContext; }
public void testSelectPlanAndKillApp() { var ctrlMock = new Mock <IDirigentControl>(); var appIdTuple = new AppIdTuple("m1.a"); var appDef = new AppDef() { AppIdTuple = appIdTuple }; var plan = new LaunchPlan("plan1", new List <AppDef>() { appDef }); var planRepo = new List <ILaunchPlan>() { plan }; ctrlMock.Setup(f => f.GetPlanRepo()).Returns(planRepo); //ctrlMock.Setup(f => f.SelectPlan(plan)).Verifiable(); var cmdRepo = new CommandRepository(); //cmdRepo.Register( new Commands.SelectPlan(ctrlMock.Object) ); //cmdRepo.ParseAndExecute(new List<string>() { ";SelectPlan", "plan1;", "KillApp", "m1.a1;" }); cmdRepo.ParseAndExecute(new List <string>() { "KillApp", "m1.a1;" }); ctrlMock.Verify(); //Assert.AreEqual("); }
static void RegisterServices() { ServiceLocator.RegisterService(new RuntimeAssemblyResolver()); ServiceLocator.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); ServiceLocator.TryRegisterService<IConfigurationManager>( () => new DefaultConfigurationManager(ServiceLocator.GetService<IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); ServiceLocator.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); ServiceLocator.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver()); ServiceLocator.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter( new IExportProvider[] { new DefaultAssemblyExporter() })); ServiceLocator.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer()); ServiceLocator.TryRegisterService<IPackageManager>(() => new DefaultPackageManager( ServiceLocator.GetService<IPackageDeployer>(), ServiceLocator.GetService<IPackageResolver>(), ServiceLocator.GetService<IPackageExporter>())); ServiceLocator.RegisterService<ITaskManager>(new TaskManager()); var commands = Services.ServiceLocator.GetService<IPackageManager>().CommandExports(ServiceLocator.GetService<IEnvironment>()); var commandRepository = new CommandRepository(commands.SelectMany(x => x).Select(x => x.Descriptor)); ServiceLocator.TryRegisterService<ICommandRepository>(() => commandRepository); }
static void RegisterServices() { ServiceLocator.RegisterService(new RuntimeAssemblyResolver()); ServiceLocator.TryRegisterService <IFileSystem>(() => LocalFileSystem.Instance); ServiceLocator.TryRegisterService <IConfigurationManager>( () => new DefaultConfigurationManager(ServiceLocator.GetService <IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); ServiceLocator.TryRegisterService <IEnvironment>(() => new CurrentDirectoryEnvironment()); ServiceLocator.TryRegisterService <IPackageResolver>(() => new ExhaustiveResolver()); ServiceLocator.TryRegisterService <IPackageExporter>(() => new DefaultPackageExporter( new IExportProvider[] { new DefaultAssemblyExporter() })); ServiceLocator.TryRegisterService <IPackageDeployer>(() => new DefaultPackageDeployer()); ServiceLocator.TryRegisterService <IPackageManager>(() => new DefaultPackageManager( ServiceLocator.GetService <IPackageDeployer>(), ServiceLocator.GetService <IPackageResolver>(), ServiceLocator.GetService <IPackageExporter>())); ServiceLocator.RegisterService <ITaskManager>(new TaskManager()); var commands = Services.ServiceLocator.GetService <IPackageManager>().CommandExports(ServiceLocator.GetService <IEnvironment>()); var commandRepository = new CommandRepository(commands.SelectMany(x => x).Select(x => x.Descriptor)); ServiceLocator.TryRegisterService <ICommandRepository>(() => commandRepository); }
public async Task <ActionResult> DeleteCase(int id) { if (ModelState.IsValid) { var caseCmnd = new CommandRepository <Case>(db); // Check if user has access to this case string userId = User.Identity.GetUserId(); //Case aCase = await db.Cases.Where(m => m.CaseId == id).Where(p => p.AspNetUserId == userId).FirstAsync(); // Case aCase = await caseCmnd.CaseByIdAsync(id, userId); //if (aCase == null) //{ // // User does not have access // // ~~TODO~~ Make this redirect to a nicer message // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //else //{ // db.Cases.Remove(aCase); // await db.SaveChangesAsync(); await caseCmnd.RemoveAsync(id, userId); //} } return(RedirectToAction("Index", "Cases")); }
private static TabItem CreateATabItem(Region child) { var label = child.ChildrenLabel ?? child.ControlResult.MainView.Meta.Label; var tabHeader = new Label() { Content = label.Translate() }; tabHeader.MouseDoubleClick += (s, e) => { CommandRepository.TryExecuteCommand(typeof(MaxShowViewCommand), child.ControlResult.MainView); }; var tabItem = new TabItem() { Header = tabHeader, Content = child.ControlResult.Control }; AutomationProperties.SetName(tabItem, label); WPFMeta.SetLogicalView(tabItem, child.ControlResult.MainView); ViewAdapter.AdaptView(child.ControlResult.MainView, tabItem); return(tabItem); }
public static ComputingCore InitComputingCore() { var data_cell_repository = new DataCellRepository(); var function_repository = new FunctionRepository(data_cell_repository); var command_repository = new CommandRepository(); var control_execution_service = new ControlExecutionService(); var execution_manager = new ExecutionManager( new List <IExecutionService>() { new BasicExecutionService(), control_execution_service, new CSharpExecutionService(function_repository) } ); var job_manager = new JobManager(execution_manager); var preparation_command_service = new PreparationCommandService(data_cell_repository, function_repository); var data_flow_logics_service = new DataFlowLogicsService(job_manager, preparation_command_service, data_cell_repository); control_execution_service.SetDataFlowLogicsService(data_flow_logics_service); var computing_core = new ComputingCore( function_repository, data_cell_repository, command_repository, data_flow_logics_service ); function_repository.Add(BasicFunctionModel.AllMethods.Select(x => (Function)x.Value.BasicFunction).ToList()); return(computing_core); }
public ServiceLister(Workspace workspace, Options options, CommandRepository commandrepository) : base(workspace, options, commandrepository) { Title = PathName = Path = "Services"; Thumbnail = Thumb.Value; GotItems += ServiceLister_GotItems; }
public FileListerCommands(Workspace workspace, CommandRepository commandRepository, INotificationHost notificationHost) { _workspace = workspace; _notificationHost = notificationHost; _commandRepository = commandRepository; }
public void Should_Be_Able_To_Retrieve_Null_For_An_Unknown_Command() { var cmdRepository = new CommandRepository(); ICommand results = cmdRepository.GetCommand("ThisIsNotACommand"); Assert.IsNull(results); }
public void Should_Discover_And_Load_Local_Parts() { var cmdRepository = new CommandRepository(); Assert.IsNotNull(cmdRepository.Commands); Assert.AreEqual(2, cmdRepository.Commands.Count); }
private void waterMarkTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { CommandRepository.InvokeCommand(waterMarkTextBox1.Text); } }
/// <summary> /// 把 CommandBinding 都创建在聚合视图上。 /// </summary> /// <param name="control"></param> /// <param name="view"></param> private void CreateCommandBindings(FrameworkElement control, LogicalView view) { var iptBindings = control.InputBindings; var cmdBindings = control.CommandBindings; foreach (var cmd in view.Commands) { //添加一个 CommandBinding。 var binding = CommandRepository.CreateCommandBinding(cmd); cmdBindings.Add(binding); //同时,添加一个 InputBinding,并把它的 Parameter 设置为 View。 var gestures = cmd.UICommand.InputGestures; if (gestures != null && gestures.Count > 0) { if (gestures.Count > 1) { throw new NotSupportedException("暂时不支持复杂快捷健!"); } var iptBinding = new InputBinding(cmd.UICommand, gestures[0]); iptBinding.CommandParameter = view; iptBindings.Add(iptBinding); } } }
private void Init(DatabaseFixture data) { DbContext = data.GetDbContext(); UserCommandRepository = new CommandRepository <User>(DbContext); UserQueryRepository = new QueryRepository <User>(new RepositoryDevContextInitializer <User>(this.DbContext)); Initialized = true; }
public KeyCommandsLister(Workspace workspace, Options options, CommandRepository commandRepository, KeyBindingsProvider keyBindingsProvider, SetKeyBindingPopupViewModel keyBindingPopupViewModel) : base(workspace, options, commandRepository) { _keyBindingsProvider = keyBindingsProvider; _keyBindingPopupViewModel = keyBindingPopupViewModel; Title = PathName = Path = "Key Bindings"; }
public void Should_Be_Able_To_Retrieve_A_Command_By_CommandName() { var cmdRepository = new CommandRepository(); ICommand results = cmdRepository.GetCommand("TestCommand"); Assert.IsNotNull(results); Assert.IsTrue(results is MockCommand1); }
private void MainView_Load(object sender, EventArgs e) { NavigationService.Init(this); UIStyle.Apply(UIStyle.Default, panel1); CommandRepository.Collect(); }
protected override void ItemSelected(ConsoleCommandItem selectedItem) { CommandRepository.GetCommandByName(nameof(ExecuteConsoleCommand)).Execute(ItemSelectedFromListView ? selectedItem?.Command : Text); Text = ""; base.ItemSelected(selectedItem); }
public SettingsLister(Workspace workspace, Options options, CommandRepository commandRepository, PropertyEditorPopupViewModel propertyEditorPopup) : base(workspace, options, commandRepository) { _propertyEditorPopup = propertyEditorPopup; Title = PathName = Path = "Settings"; Thumbnail = Utils.GetImageFromRessource("process.png"); }
public ConsoleLister(Workspace workspace, Options options, CommandRepository commandRepository) : base(workspace, options, commandRepository) { Title = PathName = Path = "Console"; Items = new ObservableCollection <ConsoleItem>(); BindingOperations.EnableCollectionSynchronization(Items, _locker); CommandHistory = new Stack <ConsoleCommandItem>(); }
protected override void ItemSelected(IItem selectedItem) { CommandRepository.GetCommandByName(nameof(DoActionCommand)).Execute(); //avoid flickering on filter popup, when current list is filtered, filter is set to null //and all items from current list are shown before refresh happens _pauseFilter = true; Text = ""; _pauseFilter = false; }
private static void Main(string[] args) { iaso_v001Context context = new iaso_v001Context(); ICommandRepository <Guid, Board> boardCommandRepo = new CommandRepository <Guid, Board>(context); IQueryRepository <Guid, Board> boardQueryRepo = new QueryRepository <Guid, Board>(context); IParameterisedQuery <int, Board> pQuery = new PQ(); var b = pQuery.GetParameter(); var boardList = boardQueryRepo.Items.ToList(); foreach (var t in boardList.ToList()) { Console.WriteLine(string.Format("{0} >>>> {1}", t.Id, t.Name)); } var board = new Board { Id = 1, Name = "No Base 21/03", BoardTypeId = 1, CreateDate = DateTime.Now, CreatedById = 1 }; ISaveCommand <Board> createCom = new CreateCommand <Guid, Board>() { Entity = board, Repository = new CommandRepository <Guid, Board>(context) }; var task = Task.Run(() => createCom.ExecuteAsync()); task.Wait(); try { IDeleteCommand <int> deleteCommand = new DeleteCommand <int, Board>() { Repository = new CommandRepository <int, Board>(context) }; deleteCommand.Id = 1; var tk = Task.Run(() => deleteCommand.ExecuteAsync()); tk.Wait(); } catch (Exception ex) { } Console.ReadKey(); }
public ReferenceLister(Workspace workspace, Options options, CommandRepository commandRepository) : base(workspace, options, commandRepository) { Items = new ObservableCollection <ReferenceItem>(); Title = PathName = ProtocolPrefix; PropertyChanged += ReferenceLister_PropertyChanged; History = new BrowsingHistory(); }
private async void PlayCommand_Execute(object parameter) { var cmd = new RobotCommand(SelectedRobotIndex, SelectedCommand, Double.Parse(Payload)); await RobotCommandExecuter.ExecuteAsync(cmd); //add to in memory repo CommandRepository.Add(cmd); //update UI ExecutedCommandText.Add(GetCommandText(cmd)); }
public FileLister(Workspace workspace, Options options, CommandRepository commandRepository) : base(workspace, options, commandRepository) { Title = "Files"; History = new BrowsingHistory(); _watcher = new FilesystemChangeWatcher(this); _watcher.Register(); _itemProvider = new FileItemProvider(workspace); PathChanged += FileLister_PathChanged; }
/// <summary> /// Program constructor, instantiates primary repository objects. /// </summary> private Program(IConfigurationManager configManager) { _commandRepo = new CommandRepository(); _logger = new LogRepository(); string logFullErrorsSetting = configManager.AppSettings[AppSettingKeys.LogFullErrors]; bool.TryParse(logFullErrorsSetting, out _logFullErrors); _keepConsoleOpen = ProgramLaunchedInSeparateConsoleWindow(); }
public static int Main(string[] args) { if (args == null || args.Length == 0) { Console.WriteLine("No command was entered. Type 'get-help' to get a list of supported commands."); } Services.Services.RegisterService<RuntimeAssemblyResolver>(new RuntimeAssemblyResolver()); Services.Services.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); Services.Services.TryRegisterService<IConfigurationManager>(() => new ConfigurationManager(Services.Services.GetService<IFileSystem>().GetDirectory(InstallationPaths.ConfigurationDirectory))); Services.Services.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); Services.Services.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver()); Services.Services.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter()); Services.Services.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer()); Services.Services.TryRegisterService<IPackageManager>(() => new DefaultPackageManager( Services.Services.GetService<IPackageDeployer>(), Services.Services.GetService<IPackageResolver>(), Services.Services.GetService<IPackageExporter>() )); Services.Services.RegisterService<ITaskManager>(new TaskManager()); var commands = Services.Services.GetService<IEnvironment>().Commands(); var repo = new CommandRepository(commands); Services.Services.TryRegisterService<ICommandRepository>(() => repo); var processor = new CommandLineProcessor(repo); var backedupConsoleColor = Console.ForegroundColor; var returnCode = 0; foreach (var commandOutput in AllOutputs(processor, args).Where(x => x != null)) { try { if (HiddenVerboseOutput(args, commandOutput)) continue; SetCommandColor(commandOutput.Type); RenderOutput(commandOutput); if (commandOutput.Type == CommandResultType.Error) { returnCode = -1; } } finally { Console.ForegroundColor = backedupConsoleColor; } } if (Debugger.IsAttached) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } return returnCode; }
public override void PreviewKeyDown(object sender, KeyEventArgs ea) { var shift = (ea.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift; if (ea.Key == Key.Tab && !shift) { var v = Workspace.ActiveLister.ItemsView; if (v != null) //maybe no items in Listview (filter) { v.MoveCurrentToNext(); if (v.IsCurrentAfterLast) { v.MoveCurrentToFirst(); } } ea.Handled = true; } else if (ea.Key == Key.Tab && shift) { var v = Workspace.ActiveLister.ItemsView; if (v != null) { v.MoveCurrentToPrevious(); if (v.IsCurrentBeforeFirst) { v.MoveCurrentToLast(); } } ea.Handled = true; } else if (ea.Key == Key.OemPeriod) { if (Workspace.ActiveLister is IHistorisationProvider history) { if (Text == ".") { var previousItem = history.History.Peek(); if (previousItem != null) { var filter = previousItem.Filter; CommandRepository.GetCommandByName(nameof(HistoryBackKeepFilterCommand)).Execute(); Text = filter; SelectAll(); _firstInput = true; } ea.Handled = true; } } } else { base.PreviewKeyDown(sender, ea); } }
public void testUnknownCommand() { var ctrlMock = new Mock <IDirigentControl>(); var cmdRepo = new CommandRepository(); cmdRepo.ParseAndExecute(new List <string>() { "Unknown!!!", "plan1" }); }
/// <summary> /// The Main method of the project. /// </summary> /// <param name="args">Arguments passed to the Main method.</param> public static void Main(string[] args) { IRepository<ICommand> commandRepository = new CommandRepository(); IHandler<ICommandArguments> commandHandler = new CommandHandler(commandRepository); IInputReader inputReader = new ConsoleInputReader(); IOutputWriter outputWriter = new ConsoleOutputWriter(); IRepository<IBlob> blobRepository = new BlobRepository(); ICommandArguments commandArguments = new CommandArguments(blobRepository, outputWriter); IEngine gameEngine = new Engine(commandHandler, commandArguments, inputReader, (IUpdateable)blobRepository); commandArguments.Stopable = gameEngine; gameEngine.Run(); }
protected override void OnStartup(StartupEventArgs e) { Services.Services.RegisterService<RuntimeAssemblyResolver>(new RuntimeAssemblyResolver()); Services.Services.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); Services.Services.TryRegisterService<IConfigurationManager>(() => new ConfigurationManager(Services.Services.GetService<IFileSystem>().GetDirectory(InstallationPaths.ConfigurationDirectory))); Services.Services.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); Services.Services.TryRegisterService<IPackageResolver>(() => new PackageResolver()); Services.Services.RegisterService<ITaskManager>(new TaskManager()); var repo = new CommandRepository(Services.Services.GetService<IEnvironment>().Commands()); Services.Services.TryRegisterService<ICommandRepository>(() => repo); base.OnStartup(e); }
public static IDictionary<string, string> Initialize(string projectFile, string currentDirectory) { Services.ServiceLocator.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); Services.ServiceLocator.TryRegisterService<IConfigurationManager>( () => new DefaultConfigurationManager(Services.ServiceLocator.GetService<IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); Services.ServiceLocator.TryRegisterService<IEnvironment>(() => new MSBuildEnvironment(System.IO.Path.GetDirectoryName(projectFile), currentDirectory)); Services.ServiceLocator.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver()); Services.ServiceLocator.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter(new List<IExportProvider>() { new DefaultAssemblyExporter(), new CecilCommandExporter() })); Services.ServiceLocator.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer()); Services.ServiceLocator.TryRegisterService<IPackageManager>(() => new DefaultPackageManager( Services.ServiceLocator.GetService<IPackageDeployer>(), Services.ServiceLocator.GetService<IPackageResolver>(), Services.ServiceLocator.GetService<IPackageExporter>() )); Services.ServiceLocator.RegisterService<ITaskManager>(new TaskManager()); ServiceLocator.TryRegisterService<IAssemblyResolver>(() => new CecilStaticAssemblyResolver(ServiceLocator.GetService<IPackageManager>(), ServiceLocator.GetService<IEnvironment>())); var commands = Services.ServiceLocator.GetService<IPackageManager>().CommandExports(ServiceLocator.GetService<IEnvironment>()); var commandRepository = new CommandRepository(commands.SelectMany(x => x).Select(x => x.Descriptor)); Services.ServiceLocator.TryRegisterService<ICommandRepository>(() => commandRepository); Services.ServiceLocator.RegisterService(new RuntimeAssemblyResolver()); var env = Services.ServiceLocator.GetService<IEnvironment>(); var scope = PathFinder.GetCurrentScope(env.Descriptor.DirectoryStructure, new Path(projectFile)); var currentDescriptor = env.GetOrCreateScopedDescriptor(scope); return new Dictionary<string, string> { { BuildConstants.PACKAGE_NAME, currentDescriptor.Value.Name }, { BuildConstants.PROJECT_SCOPE, scope }, {BuildConstants.DESCRIPTOR_PATH, currentDescriptor.File.Path.FullPath} }; }
public static int Main(string[] args) { WrapServices.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); WrapServices.TryRegisterService<IConfigurationManager>(() => new ConfigurationManager(WrapServices.GetService<IFileSystem>().GetDirectory(InstallationPaths.ConfigurationDirectory))); WrapServices.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); WrapServices.TryRegisterService<IPackageManager>(() => new PackageManager()); WrapServices.RegisterService<RuntimeAssemblyResolver>(new RuntimeAssemblyResolver()); WrapServices.RegisterService<ITaskManager>(new TaskManager()); var commands = ReadCommands(WrapServices.GetService<IEnvironment>()); var repo = new CommandRepository(commands); WrapServices.TryRegisterService<ICommandRepository>(() => repo); var processor = new CommandLineProcessor(repo); var backedupConsoleColor = Console.ForegroundColor; var returnCode = 0; foreach (var commandOutput in AllOutputs(processor, args).Where(x => x != null)) { try { if (HiddenVerboseOutput(args, commandOutput)) continue; SetCommandColor(commandOutput.Type); if (!commandOutput.Success) { returnCode = -1; } RenderOutput(commandOutput); } finally { Console.ForegroundColor = backedupConsoleColor; } } if (Debugger.IsAttached) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } return returnCode; }
private static void RegisterServices() { Services.Services.RegisterService(new RuntimeAssemblyResolver()); Services.Services.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); Services.Services.TryRegisterService<IConfigurationManager>(() => new DefaultConfigurationManager(Services.Services.GetService<IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); Services.Services.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); Services.Services.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver()); Services.Services.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter()); Services.Services.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer()); Services.Services.TryRegisterService<IPackageManager>(() => new DefaultPackageManager( Services.Services.GetService<IPackageDeployer>(), Services.Services.GetService<IPackageResolver>())); Services.Services.RegisterService<ITaskManager>(new TaskManager()); var repo = new CommandRepository(Services.Services.GetService<IEnvironment>().Commands()); Services.Services.TryRegisterService<ICommandRepository>(() => repo); }
static void Main(string[] args) { WrapServices.RegisterService<IEnvironment>(new CurrentDirectoryEnvironment()); var repo = new CommandRepository { new AttributeBasedCommandDescriptor<AddWrapCommand>(), new AttributeBasedCommandDescriptor<HelpCommand>(), new AttributeBasedCommandDescriptor<SyncWrapCommand>() }; WrapServices.RegisterService<ICommandRepository>(repo); var processor = new CommandLineProcessor(repo); var backedupConsoleColor = System.Console.ForegroundColor; try { var commandResult = processor.Execute(args); if (!commandResult.Success) System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(commandResult); } finally { System.Console.ForegroundColor = backedupConsoleColor; } }
public verb_noun_handler() { Repository = new CommandRepository(); Handler = new VerbNounCommandLineHandler(Repository); }
public noun_verb_handler() { Repository = new CommandRepository(); Handler = new NounVerbCommandLineHandler(Repository); }
public static int Main(IDictionary<string, object> env) { Services.ServiceLocator.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance); Services.ServiceLocator.TryRegisterService<IConfigurationManager>( () => new DefaultConfigurationManager(Services.ServiceLocator.GetService<IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); Services.ServiceLocator.TryRegisterService<IEnvironment>(() => { var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory())); if (env.SysPath() != null) cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(env.SysPath()).Combine("wraps")); return cdenv; }); Services.ServiceLocator.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver()); Services.ServiceLocator.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter(new List<IExportProvider>() { new DefaultAssemblyExporter(), new CecilCommandExporter() })); Services.ServiceLocator.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer()); Services.ServiceLocator.TryRegisterService<IPackageManager>(() => new DefaultPackageManager( Services.ServiceLocator.GetService<IPackageDeployer>(), Services.ServiceLocator.GetService<IPackageResolver>(), Services.ServiceLocator.GetService<IPackageExporter>() )); Services.ServiceLocator.RegisterService<ITaskManager>(new TaskManager()); ServiceLocator.TryRegisterService<IAssemblyResolver>(() => new CecilStaticAssemblyResolver(ServiceLocator.GetService<IPackageManager>(), ServiceLocator.GetService<IEnvironment>())); var commands = Services.ServiceLocator.GetService<IPackageManager>().CommandExports(ServiceLocator.GetService<IEnvironment>()); var commandRepository = new CommandRepository(commands.SelectMany(x=>x).Select(x=>x.Descriptor)); Services.ServiceLocator.TryRegisterService<ICommandRepository>(() => commandRepository); Services.ServiceLocator.RegisterService(new RuntimeAssemblyResolver()); return new ConsoleCommandExecutor(ServiceLocator.GetService<ICommandRepository>(), new List<ICommandLocator> { new NounVerbCommandLocator(commandRepository), new VerbNounCommandLocator(commandRepository), new DefaultVerbCommandLocator(commandRepository) }).Execute(env.CommandLine(), env.ShellArgs()); }
public override bool Execute() { ResharperLogger.Debug("Initialize called on " + ProjectFilePath); EnsureWrapRepositoryIsInitialized(); if (!EnableVisualStudioIntegration) return true; ResharperHook.TryRegisterResharper(Environment, WrapDescriptorPath, PackageRepository); SolutionAddIn.Initialize(); if (_commands == null) { lock (this) if (_commands == null) { var repository = new CommandRepository(ReadCommands(Services.ServiceLocator.GetService<IEnvironment>())); _commands = new UICommands(repository); _commands.Initialize(); } } return true; }
public CommandLineProcessor(CommandRepository commands) { _commands = commands; }