public static string Apply(string input, string command)
        {
            switch (command)
            {
            case nameof(DiacriticsCommand):
                return(DiacriticsCommand.DiacriticsLogic(input, ToggleMode.Apply));

            case nameof(DoubleCommand):
                return(DoubleCommand.DoubleLogic(input, ToggleMode.Apply));

            case nameof(InvertCaseCommand):
                return(InvertCaseCommand.InvertCaseLogic(input));

            case nameof(PaddingCommand):
                return(PaddingCommand.PaddingLogic(input, ToggleMode.Apply));

            case nameof(ReverseCommand):
                return(ReverseCommand.ReverseLogic(input));

            case nameof(SurroundCommand):
                return(SurroundCommand.SurroundLogic(input, ToggleMode.Apply));

            default:
                return(input);
            }
        }
Example #2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await SurroundCommand.InitializeAsync(this);

            await ReverseCommand.InitializeAsync(this);

            await PaddingCommand.InitializeAsync(this);

            await InvertCaseCommand.InitializeAsync(this);

            await DiacriticsCommand.InitializeAsync(this);

            await DoubleCommand.InitializeAsync(this);

            await UppercaseCommand.InitializeAsync(this);

            await XxxxxCommand.InitializeAsync(this);

            await L337Command.InitializeAsync(this);

            await AlternateCaseCommand.InitializeAsync(this);

            await SponsorRequestHelper.CheckIfNeedToShowAsync();
        }
 public SpeechesListViewModel()
 {
     SelectedItemCommand = new SyncCommand <int>(SpeakerSelected);
     Speeches            = new ObservableCollection <Speech>();
     ShowSpeakerCommand  = new ReverseCommand <Speaker>();
     LoadSpeeches();
 }
Example #4
0
        /// <summary>
        /// 一个反转的命令
        /// </summary>
        public ReverseCommand ReversalCommand(IPickFilter pf = null)
        {
            var c = new ReverseCommand();

            c.SetPickFilter(pf);
            DrawingControl.SetCommand(c);
            return(c);
        }
Example #5
0
        public void CanAddAndRemoveToggleActionsInDifferentOrder()
        {
            var origin = "Original String";

            var modifiedStep1  = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);
            var modifiedStep2  = DiacriticsCommand.DiacriticsLogic(modifiedStep1, ToggleMode.Apply);
            var modifiedStep3  = DoubleCommand.DoubleLogic(modifiedStep2, ToggleMode.Apply);
            var modifiedStep4  = ReverseCommand.ReverseLogic(modifiedStep3);
            var modifiedStep5  = PaddingCommand.PaddingLogic(modifiedStep4, ToggleMode.Apply);
            var modifiedStep6  = InvertCaseCommand.InvertCaseLogic(modifiedStep5);
            var modifiedStep7  = DiacriticsCommand.DiacriticsLogic(modifiedStep6, ToggleMode.Reverse);
            var modifiedStep8  = SurroundCommand.SurroundLogic(modifiedStep7, ToggleMode.Reverse);
            var modifiedStep9  = DoubleCommand.DoubleLogic(modifiedStep8, ToggleMode.Reverse);
            var modifiedStep10 = ReverseCommand.ReverseLogic(modifiedStep9);
            var modifiedStep11 = InvertCaseCommand.InvertCaseLogic(modifiedStep10);
            var finalResult    = PaddingCommand.PaddingLogic(modifiedStep11, ToggleMode.Reverse);

            Assert.AreEqual(origin, finalResult);
        }
 /// <summary>
 /// ReverseCommandAsync
 /// </summary>
 /// <param name="reverseCommand"></param>
 /// <returns></returns>
 public async Task <CommandResponse> ReverseCommandAsync(ReverseCommand reverseCommand)
 {
     try
     {
         return(await service.CommandResource.ReverseCommandAsync(reverseCommand));
     }
     catch (ApiException ex)
     {
         apiException = new APIExceptions {
             ErrorCode = ex.Code, ErrorDescription = ex.Message, ErrorApi = "ReverseCommandAsync"
         };
         return(null);
     }
     catch (Exception ex)
     {
         logger.WriteLogError("**** LoyaltyEngineServices FAILURE: ReverseCommandAsync Exception Error= " + ex.Message);
         if (ex.InnerException != null)
         {
             logger.WriteLogError("**** InnerException  = " + ex.InnerException.Message);
         }
         return(null);
     }
 }
Example #7
0
        public void Reverse(int index, int count)
        {
            ReverseCommand command = new ReverseCommand(theList, index, count);

            undoManager.Execute(command);
        }
Example #8
0
        public void Reverse()
        {
            ReverseCommand command = new ReverseCommand(theList);

            undoManager.Execute(command);
        }
Example #9
0
        public void ReverseAndSurround()
        {
            var actual = ReverseCommand.ReverseLogic("[! abc !]");

            Assert.AreEqual("[! cba !]", actual);
        }
Example #10
0
        public void WithCyrillic()
        {
            var actual = ReverseCommand.ReverseLogic("матт");

            Assert.AreEqual("ттам", actual);
        }
Example #11
0
        public void WithNonAscii()
        {
            var actual = ReverseCommand.ReverseLogic("mrläcey");

            Assert.AreEqual("yecälrm", actual);
        }
Example #12
0
        public void WithCombiningCharacters()
        {
            var actual = ReverseCommand.ReverseLogic("a\u0346bc");

            Assert.AreEqual("cba\u0346", actual);
        }
Example #13
0
        public void SimpleAscii()
        {
            var actual = ReverseCommand.ReverseLogic("abc");

            Assert.AreEqual("cba", actual);
        }
        public Command ParseCommand(string commandInput)
        {
            var commandArguments = commandInput.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            // first check if it's a valid command

            var length = commandArguments.Length;

            Command command = null;

            var action     = commandArguments[0];
            var parameters = commandArguments.Skip(1).ToList();


            // make it with reflection, if you hate your life
            switch (action)
            {
            case "append":
                ValidateCommandLength(length, Constants.AppendCommandLength);
                command = new AppendCommand(parameters);
                break;

            case "prepend":
                ValidateCommandLength(length, Constants.PrependCommandLength);
                command = new PrependCommand(parameters);
                break;

            case "reverse":
                ValidateCommandLength(length, Constants.ReverseCommandLength);
                command = new ReverseCommand(parameters);
                break;

            case "insert":
                ValidateCommandLength(length, Constants.InsertCommandLength);
                command = new InsertCommand(parameters);
                break;

            case "delete":
                ValidateCommandLength(length, Constants.DeleteCommandLength);
                command = new DeleteCommand(parameters);
                break;

            case "roll":
                ValidateCommandLength(length, Constants.RollCommandLength);
                command = new RollCommand(parameters);
                break;

            case "sort":
                ValidateCommandLength(length, Constants.SortCommandLength);
                command = new SortCommand(parameters);
                break;

            case "count":
                ValidateCommandLength(length, Constants.CountCommandLength);
                command = new CountCommand(parameters);
                break;

            case "end":
                this.logger.Write(Constants.FinishedMessage);
                command = new EndCommand(parameters);
                break;

            default:
                throw new ArgumentException(Constants.InvalidCommand);
            }

            return(command);
        }
Example #15
0
 public LoginViewModel()
 {
     SetUserNameCommand = new SyncCommand <string>(ShowListSpeeches);
     NavigateToListPage = new ReverseCommand <string>();
 }