Beispiel #1
0
        public async Task <TResult> Execute <TResult>(ICommandParams <TResult> paramModel)
        {
            ICommandResolver resolver = GetCommandResolver(paramModel.GetType());
            var wrapper = GetWrapper <TResult>(typeof(TResult), paramModel.GetType(), resolver);

            return(await wrapper.Execute(paramModel));
        }
Beispiel #2
0
 public void AddCommandResolver(ICommandResolver resolver, List <Type> commandTypes)
 {
     foreach (Type t in commandTypes)
     {
         this._resolvers.Add(t, resolver);
     }
 }
        public NoteEditViewModel(INavigationService navigationService,
                                 IPermissionService permissionService,
                                 IFileSystem fileService,
                                 IMediaService mediaService,
                                 IVideoService videoService,
                                 ICommandResolver commandResolver,
                                 MediaHelper mediaHelper,
                                 TransformHelper transformHelper)
            : base(navigationService)
        {
            _permissionService = permissionService;
            _fileService       = fileService;
            _mediaService      = mediaService;
            _videoService      = videoService;
            _commandResolver   = commandResolver;

            _mediaHelper     = mediaHelper;
            _transformHelper = transformHelper;

            AttachButtonImageSource = ConstantsHelper.AttachmentLightIcon;
            CameraButtonImageSource = ConstantsHelper.CameraIcon;
            VideoButtonImageSource  = ConstantsHelper.VideoIcon;

            GalleryItemModels = new RangeObservableCollection <GalleryItemModel>();

            DescriptionTextChanged   = commandResolver.Command <string>(DescriptionChanged);
            TakePhotoCommand         = commandResolver.AsyncCommand(TakePhoto);
            TakeVideoCommand         = commandResolver.AsyncCommand(TakeVideo);
            PickMultipleMediaCommand = commandResolver.AsyncCommand(PickMultipleMedia);
            SaveNoteCommand          = commandResolver.AsyncCommand <string>(SaveNote);
            DeleteNoteCommand        = commandResolver.AsyncCommand(DeleteNote);
            SelectImageCommand       = commandResolver.AsyncCommand <GalleryItemModel>(SelectImage);
        }
Beispiel #4
0
        public static ObservableCollection <ToDoViewModel> ToToDoViewModels(this IEnumerable <ToDoModel> models,
                                                                            ICommandResolver commandResolver)
        {
            var viewModels = new ObservableCollection <ToDoViewModel>();

            foreach (var model in models)
            {
                var viewModel = new ToDoViewModel(commandResolver)
                {
                    Id          = model.Id,
                    WhenHappens = model.WhenHappens,
                    Description = model.Description
                };
                switch (model.Status)
                {
                case ConstantsHelper.Active:
                    viewModel.Status = ToDoStatus.Active;
                    break;

                case ConstantsHelper.Completed:
                    viewModel.Status = ToDoStatus.Completed;
                    break;

                default:
                    viewModel.Status = ToDoStatus.Active;
                    break;
                }
                viewModels.Add(viewModel);
            }
            return(viewModels);
        }
Beispiel #5
0
 public NewAchievementViewModel(INavigationService navigationService,
                                ICommandResolver commandResolver)
     : base(navigationService)
 {
     CreateAchievementCommand = commandResolver.AsyncCommand(CreateAchievement, () => IsEnabled);
     NavigateBackCommand      = commandResolver.AsyncCommand(NavigateBack);
 }
 public GalleryItemViewModel(INavigationService navigationService,
                             ICommandResolver commandResolver)
     : base(navigationService)
 {
     DeleteCommand       = commandResolver.AsyncCommand(Delete);
     NavigateBackCommand = commandResolver.AsyncCommand(NavigateBack);
 }
 public NewToDoViewModel(INavigationService navigationService,
                         ICommandResolver commandResolver)
     : base(navigationService)
 {
     CreateToDoCommand   = commandResolver.AsyncCommand(CreateToDo, () => IsEnabled);
     NavigateBackCommand = commandResolver.AsyncCommand(NavigateBack);
 }
Beispiel #8
0
        public static ToDoViewModel ToToDoViewModel(this ToDoModel model,
                                                    ICommandResolver commandResolver)
        {
            var viewModel = new ToDoViewModel(commandResolver)
            {
                Id          = model.Id,
                WhenHappens = model.WhenHappens,
                Description = model.Description
            };

            switch (model.Status)
            {
            case ConstantsHelper.Active:
                viewModel.Status = ToDoStatus.Active;
                break;

            case ConstantsHelper.Completed:
                viewModel.Status = ToDoStatus.Completed;
                break;

            default:
                viewModel.Status = ToDoStatus.Active;
                break;
            }
            return(viewModel);
        }
 public ToDoViewModel(INavigationService navigationService,
                      ICommandResolver commandResolver)
     : base(navigationService)
 {
     CreateToDoCommand = commandResolver.Command(CreateToDo);
     UpdateItemCommand = commandResolver.Command(UpdateItem);
     DeleteItemCommand = commandResolver.Command(DeleteItem);
 }
Beispiel #10
0
 public AchievementStepViewModel(
     INavigationService navigationService,
     ICommandResolver commandResolver)
     : base(navigationService)
 {
     SaveStepCommand = commandResolver.AsyncCommand(SaveStep, () => { return IsEnabled; });
     NavigateBackCommand = commandResolver.AsyncCommand(NavigateBack);
 }
Beispiel #11
0
 public CommandFactory(ICommandResolver commandResolver,
                       ICommandArgParser commandArgParser,
                       IEnumerable <ICraneCommand> craneCommands)
 {
     _commandResolver  = commandResolver;
     _craneCommands    = craneCommands;
     _commandArgParser = commandArgParser;
 }
Beispiel #12
0
 public MessageController(ICurrentAuthorService currentAuthorService,
                          IAuthorService authorService,
                          ICommandResolver commandResolver,
                          IMediator mediator)
 {
     _currentAuthorService = currentAuthorService;
     _commandResolver      = commandResolver;
     _mediator             = mediator;
 }
Beispiel #13
0
        public ShellViewModel(ICommandResolver resolver, IEventAggregator eventAggregator)
        {
            _resolver = resolver;
            _eventAggregator = eventAggregator;

            _eventAggregator.ListenOnScheduler<DatabaseChanged>(OnDatabaseChanged);

            Title = "Personal Task Board - (no task board loaded)";
        }
 public HelpCommandsRewriter(
     ApplicationModel appModel,
     ICommandResolver commandResolver,
     CommandLineOptions cliOptions = null)
 {
     _appModel        = appModel ?? throw new ArgumentNullException(nameof(appModel));
     _commandResolver = commandResolver ?? throw new ArgumentNullException(nameof(commandResolver));
     _cliOptions      = cliOptions ?? new CommandLineOptions();
     _cliOptions.Validate();
 }
Beispiel #15
0
        public AchievementsViewModel(INavigationService navigationService,
                                     ICommandResolver commandResolver)
            : base(navigationService)
        {
            Achievements = new ObservableCollection <AchievementViewModel>();

            RefreshListCommand = commandResolver.Command(Refresh);
            NavigateToAchievementEditViewCommand = commandResolver.AsyncCommand <int>(NavigateToAchievementEditView);
            CreateNewAchievementCommand          = commandResolver.Command(CreateNewAchievement);
        }
 public CommandsApplication(
     IServiceProvider services, ICommandResolver commandResolver,
     IArgumentsParser argumentsParser, ICommandExecutor commandExecutor,
     ApplicationModel appModel)
 {
     _services        = services ?? throw new ArgumentNullException(nameof(services));
     _commandResolver = commandResolver ?? throw new ArgumentNullException(nameof(commandResolver));
     _argumentsParser = argumentsParser ?? throw new ArgumentNullException(nameof(argumentsParser));
     _commandExecutor = commandExecutor ?? throw new ArgumentNullException(nameof(commandExecutor));
     _appModel        = appModel ?? throw new ArgumentNullException(nameof(appModel));
 }
        public BirthdaysViewModel(
            INavigationService navigationService,
            ICommandResolver commandResolver)
            : base(navigationService)
        {
            Birthdays = new RangeObservableCollection <BirthdayViewModel>();

            RefreshCommand = commandResolver.Command(Refresh);
            NavigateToEditBirthdayCommand = commandResolver.AsyncCommand <int>(EditBirthday);
            DeleteBirthdayCommand         = commandResolver.AsyncCommand <BirthdayViewModel>(DeleteBirthday);
        }
Beispiel #18
0
        /// <summary>
        /// Constructs a <see cref="ConsoleApplication"/>
        /// </summary>
        /// <param name="commandModuleResolver"></param>
        /// <param name="commandRouteBuilder"></param>
        /// <param name="catalog"></param>
        /// <param name="commandResolver"></param>
        public ConsoleApplication(ICommandModuleResolver commandModuleResolver, ICommandRouteBuilder commandRouteBuilder, ICommandCatalog catalog, ICommandResolver commandResolver)
        {
            CommandModuleResolver = commandModuleResolver;
            CommandRouteBuilder = commandRouteBuilder;
            Catalog = catalog;
            CommandResolver = commandResolver;

            var modules = CommandModuleResolver.GetCommandModules();

            RegisterModules(modules);
        }
Beispiel #19
0
 public MessagesBackgroundService(ISubscriber subscriber, ICommandResolver commandResolver,
                                  IServiceScopeFactory scopeFactory,
                                  IHostEnvironment env,
                                  ILogger <MessagesBackgroundService> logger)
 {
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     _subscriber      = subscriber ?? throw new ArgumentNullException(nameof(subscriber));
     _commandResolver = commandResolver ?? throw new ArgumentNullException(nameof(commandResolver));
     _scopeFactory    = scopeFactory ?? throw new ArgumentNullException(nameof(scopeFactory));
     _env             = env ?? throw new ArgumentNullException(nameof(env));
 }
Beispiel #20
0
        /// <summary>
        /// Constructs a <see cref="ConsoleApplication"/>
        /// </summary>
        /// <param name="commandModuleResolver"></param>
        /// <param name="commandRouteBuilder"></param>
        /// <param name="catalog"></param>
        /// <param name="commandResolver"></param>
        public ConsoleApplication(ICommandModuleResolver commandModuleResolver, ICommandRouteBuilder commandRouteBuilder, ICommandCatalog catalog, ICommandResolver commandResolver)
        {
            CommandModuleResolver = commandModuleResolver;
            CommandRouteBuilder   = commandRouteBuilder;
            Catalog         = catalog;
            CommandResolver = commandResolver;

            var modules = CommandModuleResolver.GetCommandModules();

            RegisterModules(modules);
        }
Beispiel #21
0
        public WebhookService(ICommandResolver commandResolver,
                              ITelegramBot telegramBot,
                              ICommandInvoker commandInvoker,
                              ILogger <WebhookService> logger)
        {
            _commandResolver = commandResolver;
            _telegramBot     = telegramBot;
            _commandInvoker  = commandInvoker;
            _logger          = logger;

            _mapper = new Mapper(new MapperConfiguration(x => x.AddProfile <RequestProfile>()));
        }
Beispiel #22
0
 public TelegramBot(HttpClient client,
                    IDistributedCache cache,
                    ICommandResolver commandResolver,
                    ICommandInvoker commandInvoker,
                    ILogger <TelegramBot> logger)
 {
     _client          = client;
     _cache           = cache;
     _commandResolver = commandResolver;
     _commandInvoker  = commandInvoker;
     _logger          = logger;
 }
        public CalendarViewModel(
            ICommandResolver commandResolver,
            ToDoCalendarViewModel toDoCalendarViewModel)
        {
            _toDoCalendarViewModel = toDoCalendarViewModel;

            Months                  = new RangeObservableCollection <MonthViewModel>();
            SelectDayCommand        = commandResolver.Command <DateTime>(SelectDay);
            SelectCurrentDayCommand = commandResolver.Command(SelectCurrentDay);
            RefreshListCommand      = commandResolver.Command(Refresh);

            InitializeMonths(DateTime.Now);
        }
        public LoginViewModel(INavigationService navigationService,
                              ThemeSwitcher themeSwitcher,
                              ICommandResolver commandResolver)
            : base(navigationService)
        {
            TogglePasswordImageSource = themeSwitcher.CurrentThemeType == ThemeTypes.Dark
                        ? ConstantsHelper.TogglePasswordLightImage
                        : ConstantsHelper.TogglePasswordDarkImage;

            SignInCommand = commandResolver.AsyncCommand(SignIn);
            SwitchPasswordVisibilityCommand        = commandResolver.Command(SwitchPasswordVisibility);
            ToggleRegisterOrLoginViewCommand       = commandResolver.Command(ToggleRegisterOrLoginView);
            SwitchPasswordConfirmVisibilityCommand = commandResolver.Command(SwitchConfirmPasswordVisibility);
        }
Beispiel #25
0
        public UserProfileViewModel(INavigationService navigationService,
                                    IFileSystem fileService,
                                    IMediaService mediaService,
                                    ICommandResolver commandResolver)
            : base(navigationService)
        {
            _fileService  = fileService;
            _mediaService = mediaService;

            ImageContent = new byte[0];

            ChangeUserProfileCommand = commandResolver.Command <PlatformDocument>(ChangeUserProfile);
            UpdateUserCommand        = commandResolver.Command(UpdateUser);
        }
        public PinViewModel(INavigationService navigationService,
                            ThemeSwitcher themeSwitcher,
                            ICommandResolver commandResolver)
            : base(navigationService)
        {
            _pinBuilder    = new StringBuilder();
            _themeSwitcher = themeSwitcher;
            Message        = Resmgr.Value.GetString(ConstantsHelper.EnterPin, CultureInfo.CurrentCulture);

            DeleteNumberCommand = commandResolver.CommandWithoutLock(DeletePinNumber);
            PinCommand          = commandResolver.AsyncCommandWithoutLock <string>(CheckPinAsync);

            InitializeImagesForButtons();
        }
Beispiel #27
0
 public HelpModule(ApplicationModel appModel,
                   ICommandResolver commandResolver,
                   ICommandNameParser commandNameParser,
                   ICollectionConstructorProvider colCtorProvider)
 {
     _appModel          = appModel ?? throw new ArgumentNullException(nameof(appModel));
     _commandResolver   = commandResolver ?? throw new ArgumentNullException(nameof(commandResolver));
     _commandNameParser = commandNameParser ?? throw new ArgumentNullException(nameof(commandNameParser));
     if (colCtorProvider == null)
     {
         throw new ArgumentNullException(nameof(colCtorProvider));
     }
     _helpWriter = new HelpWriter(colCtorProvider);
 }
        public EndToEndPathStrategy(ICommandResolver commandResolver, IQueryResolver queryResolver)
        {
            if (commandResolver == null)
            {
                throw new ArgumentNullException(nameof(commandResolver));
            }

            if (queryResolver == null)
            {
                throw new ArgumentNullException(nameof(queryResolver));
            }

            this.commandResolver = commandResolver;
            this.queryResolver   = queryResolver;
        }
        public AchievementEditViewModel(INavigationService navigationService,
                                        ICommandResolver commandResolver)
            : base(navigationService)
        {
            _stepsToDelete   = new List <AchievementStep>();
            AchievementSteps = new ObservableCollection <AchievementStep>();

            SaveAchievementCommand = commandResolver.AsyncCommand(SaveAchievement);
            NavigateToAchievementStepEditViewCommand = commandResolver.AsyncCommand <AchievementStep>(NavigateToAchievementStepEditView);
            DeleteAchievementCommand = commandResolver.AsyncCommand(DeleteAchievement);
            AddStepCommand           = commandResolver.AsyncCommand(AddStep);
            DeleteStepCommand        = commandResolver.AsyncCommand <AchievementStep>(DeleteStep);
            ChangeEditEnabledCommand = commandResolver.Command(() => IsEditMode = !IsEditMode);

            MessagingCenter.Subscribe <AchievementStepViewModel>(this, ConstantsHelper.AchievementStepEditComplete, vm => UpdateStepsList());
        }
Beispiel #30
0
        public NotesViewModel(INavigationService navigationService,
                              IUploadService uploadService,
                              ICommandResolver commandResolver)
            : base(navigationService)
        {
            _uploadService = uploadService;
            Notes          = new ObservableCollection <Note>();

            SearchText = string.Empty;

            UploadNotesToApiCommand   = commandResolver.AsyncCommand(UploadAllNotes);
            DeleteNoteCommand         = commandResolver.AsyncCommand <Note>(DeleteNote);
            RefreshListCommand        = commandResolver.Command(Refresh);
            SearchCommand             = commandResolver.Command(SearchNotesByDescription);
            NavigateToEditViewCommand = commandResolver.AsyncCommand <int>(NavigateToEditView);
        }
Beispiel #31
0
        public TaskBoardViewModel(IRepositoryProvider repositoryProvider, IEventAggregator bus, ICommandResolver commandResolver)
        {
            _repositoryProvider = repositoryProvider;
            _bus = bus;
            _commandResolver = commandResolver;

            Tasks = new SortableReactiveCollection<TaskViewModel>();

            Tasks.ItemChanged
                .Throttle(TimeSpan.FromSeconds(5))
                .Select(c => c.Sender)
                .Where(c =>  _repository != null)
                .Where(task => !task.IsEditing)
                .SubscribeOn(RxApp.DeferredScheduler)
                .Subscribe(_ => OnSaveAllTasks(null));

            Tasks.ItemChanged
                .Where(c => c.PropertyName == "IsSelected")
                .SubscribeOn(RxApp.DeferredScheduler)
                .Select(c => c.Sender)
                .Subscribe(IsSelectedChanged);

            Tasks.ItemChanged
                .Where(c => c.PropertyName == "State")
                .SubscribeOn(RxApp.DeferredScheduler)
                .Select(c => c.Sender)
                .Subscribe(StateChanged);

            Tasks.ChangeTrackingEnabled = true;

            _bus.ListenOnScheduler<DatabaseChanged>(OnDatabaseChanged);
            _bus.ListenOnScheduler<CreateNewTask>(OnCreateNewTask);
            _bus.ListenOnScheduler<CreateNewSubTask>(OnCreateNewSubTask);
            _bus.ListenOnScheduler<SaveAllTasks>(OnSaveAllTasks);
            _bus.ListenOnScheduler<ReloadAllTasks>(evt => Reload());
            _bus.ListenOnScheduler<ReSort>(evt => Reorder());
            _bus.ListenOnScheduler<CollapseAll>(evt => OnCollapseAll());

            _bus.AddSource(Tasks.PropertyOnAnyChanged(vm => vm.State)
                .Select(_ => new TaskStateChanged()));

            DragCommand = new ReactiveCommand();

            DragCommand.OfType<DragCommandArgs>().Subscribe(OnNext);
        }
Beispiel #32
0
        public ToDoCalendarViewModel(INavigationService navigationService,
                                     ICommandResolver commandResolver)
            : base(navigationService)
        {
            _commandResolver = commandResolver;

            ActiveModels    = new RangeObservableCollection <ToDoViewModel>();
            CompletedModels = new RangeObservableCollection <ToDoViewModel>();
            FailedModels    = new RangeObservableCollection <ToDoViewModel>();

            RefreshListCommand = commandResolver.Command(RefreshCommandExecute);
            SelectItemCommand  = commandResolver.Command <int>(id => SelectItem(id));

            MessagingCenter.Subscribe <App>(this, ConstantsHelper.UpdateUI, _ =>
            {
                LoadModelsFromDatabase();
            });
        }
Beispiel #33
0
        /// <summary>
        /// Creates a new instance of <see cref="Commandr.Commandr"/>.
        /// </summary>
        /// <param name="commands">The commands to register</param>
        public Commandr(
        	ICommandSplitter splitter = null,
        	IOutput output = null,
        	IListener listener = null,
            IShutdownBroker shutdownBroker = null,
            ICommandResolver resolver = null
        )
        {
            this.splitter = splitter ?? new DefaultCommandSplitter();
            this.output = output ?? new ConsoleOutput();
            this.listener = listener ?? new ConsoleListener();
            this.shutdownBroker = shutdownBroker ?? new DefaultShutdownBroker();
            this.resolver = new DefaultCommandResolver(this.output);

            this.shouldExit = false;

            this.RegisterDefaultCommands();
        }
        public BirthdayEditViewModel(
            ICommandResolver commandResolver,
            INavigationService navigationService,
            IFileSystem fileService,
            IMediaService mediaService,
            IPlatformDocumentPicker documentPicker)
            : base(navigationService)
        {
            _fileService             = fileService;
            _mediaService            = mediaService;
            SaveBirthdayCommand      = commandResolver.AsyncCommand(SaveBirthday);
            ChangePersonImageCommand = commandResolver.AsyncCommand(ChangePersonImage);
            SelectMonthCommand       = commandResolver.Command <BirthDateViewModel>(SelectMonth);
            SelectDayCommand         = commandResolver.Command <BirthdayDayViewModel>(SelectDay);
            _documentPicker          = documentPicker;

            BirthDateViewModels = new RangeObservableCollection <BirthDateViewModel>();
            InitializeDays();
            SelectedBirthDateViewModel = BirthDateViewModels.ElementAt(0);
        }
 public void AddCommandResolver(ICommandResolver commandResolver)
 {
     _orderedCommandResolvers.Add(commandResolver);
 }
Beispiel #36
0
 public MenuItem(ICommandResolver resolver, string text)
 {
     _resolver = resolver;
     _text = text;
 }
Beispiel #37
0
 public ToolbarViewModel(ICommandResolver resolver, ISettings settings)
 {
     _resolver = resolver;
     _settings = settings;
 }