DataDictionary.Interpreter.Statement.VariableUpdateStatement.GetChanges C# (CSharp) Méthode

GetChanges() public méthode

Provides the changes performed by this statement
public GetChanges ( InterpretationContext context, DataDictionary.Rules.ChangeList changes, ExplanationPart explanation, bool apply, DataDictionary.Tests.Runner.Runner runner ) : void
context InterpretationContext The context on which the changes should be computed
changes DataDictionary.Rules.ChangeList The list to fill with the changes
explanation ExplanationPart The explanatino to fill, if any
apply bool Indicates that the changes should be applied immediately
runner DataDictionary.Tests.Runner.Runner
Résultat void
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation,
            bool apply, Runner runner)
        {
            IVariable var = VariableIdentification.GetVariable(context);
            if (var != null)
            {
                IValue value = Expression.GetExpressionValue(context, explanation);
                if (value != null)
                {
                    value = value.RightSide(var, true, true);
                }

                Range range = var.Type as Range;
                Collection collection = var.Type as Collection;
                if (range != null && range.convert(value) == null)
                {
                    AddError("Value " + value + " is outside range", RuleChecksEnum.ExecutionFailed);
                }
                else if (collection != null && collection.convert(value) == null)
                {
                    AddError("Value " + value + " cannot be assigned to variable", RuleChecksEnum.ExecutionFailed);
                }
                else
                {
                    Change change = new Change(var, var.Value, value);
                    changes.Add(change, apply, runner);
                    ExplanationPart.CreateSubExplanation(explanation, Root, change);
                }
            }
            else
            {
                AddError("Cannot find variable " + VariableIdentification, RuleChecksEnum.ExecutionFailed);
            }
        }