Esempio n. 1
0
        public static string ApplyChangeOnToken(ChangedToken changedToken, string output, Change change, IList <Change> exceptions)
        {
            string input = output;

            if (exceptions.Count == 0)
            {
                output = change.Apply(input);
                change.Exploitation++;
                changedToken.AppliedChanges.Add(new AppliedChange(input, output, change));
            }
            else
            {
                output = change.Apply(input, exceptions);
            }
            return(output);
        }
Esempio n. 2
0
        public void Apply(ChangedToken changedToken)
        {
            string output = changedToken.Source.Correction ?? changedToken.Source.Text;

            changedToken.AppliedChanges = new Collection <AppliedChange>();

            int numberOfOccurencesChanges = NumberOfOccurences(Changes, output);

            if (Exceptions != null)
            {
                foreach (Change exception in Exceptions)
                {
                    if (exception.IsApplicable(output))
                    {
                        int numberOfOccurences = exception.NumberOfOccurences(output);
                        output            = Changes.ApplyChangeOnToken(changedToken, output, exception);
                        changedToken.Text = output;
                        if (numberOfOccurencesChanges == numberOfOccurences)
                        {
                            return;
                        }
                    }
                }
            }

            IList <IChange> changes = new List <IChange>();

            if (Exceptions != null)
            {
                foreach (Change change in Exceptions)
                {
                    changes.Add(change);
                }
            }
            if (Changes != null)
            {
                foreach (Change change in Changes)
                {
                    while (change.IsApplicable(output, changes))
                    {
                        Changes exceptions = Changes.GetRelevantExceptions(Exceptions, output);
                        output = Changes.ApplyChangeOnToken(changedToken, output, change, exceptions);
                    }
                }
            }
            changedToken.Text = output;
        }
Esempio n. 3
0
        public void Apply(ChangedToken changedToken)
        {
            string output = changedToken.Source.Correction ?? changedToken.Source.Text;

            changedToken.AppliedChanges = new Collection <AppliedChange>();


            foreach (Change change in this)
            {
                while (change.IsApplicable(output))
                {
                    output = ApplyChangeOnToken(changedToken, output, change);
                }
            }

            changedToken.Text = output;
        }
Esempio n. 4
0
 public static string ApplyChangeOnToken(ChangedToken changedToken, string output, Change change)
 {
     return(ApplyChangeOnToken(changedToken, output, change, new Changes()));
 }