コード例 #1
0
        private TypedValue Invoke(Tree <Cell> procedure, TypedValue target, Tree <Cell> parameterValues)
        {
            var copy       = new DeepCopy(Processor);
            var parameters = new Parameters(procedure.Branches[0], parameterValues, copy);
            var body       = procedure.Branches[1].Branches[0].IsLeaf
                ? new CellTree(copy.Make(procedure,
                                         source => source.Branches.Skip(1),
                                         parameters.Substitute))
                : new CellTree(
                procedure.Branches[1].Branches[0].Branches.Select(branch => copy.Make(branch, parameters.Substitute)));

            body.ValueAt(0).ClearAttribute(CellAttribute.Leader);

            Processor.CallStack.Push();
            var fixture = new DefaultFlowInterpreter(target.Value);

            ExecuteProcedure(fixture, body);
            Processor.TestStatus.LastAction = body.WriteBranches();
            return(Processor.CallStack.PopReturn());
        }
コード例 #2
0
            public Tree <Cell> Substitute(Tree <Cell> source)
            {
                var i = 2;

                foreach (var parameterValue in values.Branches)
                {
                    if (source.Value != null && names.ValueAt(i).Text == source.Value.Text)
                    {
                        return(copy.Make(parameterValue));
                    }
                    i += 2;
                }
                return(null);
            }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditStuffViewModel"/> class.
        /// </summary>
        /// <remarks>
        /// This constructor sets up an Action that will be run when the ShowEditStuffViewEvent is published.
        /// The Action saves the origianal Movie and makes a deep copy of the movie to work with.
        /// We need to do this because all movies are in memory, so any changes we make would be immediately persisted.
        /// By making a deep copy to work with, the user can edit this deep copy, when done pressing the Save button will copy the
        /// changes on the Deep Copy to the origianal and then persite the changes to disk.
        ///
        /// If I was editing many fields, I would have Movie implement IEditableObject.
        /// </remarks>
        public EditStuffViewModel()
        {
            var showEditStuffViewEvent = GetEvent <ShowEditStuffViewEvent>();

            showEditStuffViewEvent.Subscribe((movie) => { _orginalMovie = (Movie)movie; Movie = DeepCopy.Make <Movie>((Movie)movie); });
        }
コード例 #4
0
 public virtual IEnumerable <Option> GetPossibleOptions(IEnumerable <string> args) =>
 DeepCopy.Make(options.Concat(preFunc).Concat(postFunc));