Exemplo n.º 1
0
        public MainViewModel()
        {
            Mortgage = new MortgageViewModel();
            engine   = new DependencyEngine();

            engine.Assign(() => C).From(() => Add(A, B), e => { });
            engine.Assign(() => E).From(() => Multiply(C, D), e => { });

            A = 2;
            B = 3;
            D = 5;
            engine.LogTransitionsInDotFormat(Path.Combine(Environment.CurrentDirectory, "Transitions.log"));

            mortgageEngine = new DependencyEngine();
            mortgageEngine
            .Assign(() => Mortgage.Payments)
            .From(() => MortgageCalculations.CalculatePayments(
                      Mortgage.Amount,
                      Mortgage.InterestRate,
                      Mortgage.LoanLength,
                      Mortgage.PaymentFrequency),
                  ex => { });

            mortgageEngine
            .Assign(() => Mortgage.LoanLength)
            .From(() => MortgageCalculations.CalculateLength(
                      Mortgage.Amount,
                      Mortgage.Payments,
                      Mortgage.InterestRate,
                      Mortgage.PaymentFrequency),
                  ex => { });

            graphOptionsEngine = new DependencyEngine();
            graphOptionsEngine
            .Assign(() => MortgageGraph)
            .From(() => CreateMortgageGraph(ShowRoots, ShowFormulas), ex => { });
            MortgageGraph = CreateMortgageGraph(ShowRoots, ShowFormulas);
        }
Exemplo n.º 2
0
        public MainViewModel()
        {
            Mortgage = new MortgageViewModel();
            engine = new DependencyEngine();

            engine.Assign(() => C).From(() => Add(A, B), e => { });
            engine.Assign(() => E).From(() => Multiply(C, D), e => { });

            A = 2;
            B = 3;
            D = 5;
            engine.LogTransitionsInDotFormat(Path.Combine(Environment.CurrentDirectory, "Transitions.log"));

            mortgageEngine = new DependencyEngine();
            mortgageEngine
                .Assign(() => Mortgage.Payments)
                .From(() => MortgageCalculations.CalculatePayments(
                        Mortgage.Amount,
                        Mortgage.InterestRate,
                        Mortgage.LoanLength,
                        Mortgage.PaymentFrequency),
                        ex => { });

            mortgageEngine
                .Assign(() => Mortgage.LoanLength)
                .From(() => MortgageCalculations.CalculateLength(
                        Mortgage.Amount,
                        Mortgage.Payments,
                        Mortgage.InterestRate,
                        Mortgage.PaymentFrequency),
                        ex => { });

            graphOptionsEngine = new DependencyEngine();
            graphOptionsEngine
                .Assign(() => MortgageGraph)
                .From(() => CreateMortgageGraph(ShowRoots, ShowFormulas), ex => { });
            MortgageGraph = CreateMortgageGraph(ShowRoots, ShowFormulas);
        }