コード例 #1
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Object Container: Use objectContainer.Get<T>() to retrieve objects from the scope
            var objectContainer = context.GetFromContext <IObjectContainer>(TextApplicationScope.ParentContainerPropertyTag);

            // Inputs
            string inputText = objectContainer.Get <string>();

            // Inputs
            var searchWordsCol = SearchWord.Get(context);
            var replacedWord   = ReplacedWord.Get(context);
            var textOccurrance = TextOccurrance.Get(context);
            var indexOccurence = IndexOccurence.Get(context);
            var displayLog     = DisplayLog;

            //Convert Collection to Array
            string[] searchWords = Utils.ConvertCollectionToArray(searchWordsCol);

            ///////////////////////////
            // Add execution logic HERE
            //Replace word from text
            string OutputString = Utils.ReplaceWordsFromText(inputText, searchWords, replacedWord, textOccurrance, indexOccurence, displayLog);

            ///////////////////////////

            // Outputs
            return((ctx) =>
            {
                AdjustedText.Set(ctx, OutputString);
            });
        }
コード例 #2
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Inputs
            var inputArray    = InputArray.Get(context);
            var searchWordCol = SearchWord.Get(context);
            var displayLog    = DisplayLog;

            //Convert Collection to Array
            string[] searchWord = Utils.ConvertCollectionToArray(searchWordCol);
            ///////////////////////////
            // Add execution logic HERE
            bool bIsFound = Utils.MatchItemInArrayOfStrings(inputArray, searchWord, displayLog);

            ///////////////////////////

            // Outputs
            return((ctx) => {
                IsFound.Set(ctx, bIsFound);
            });
        }