Exemplo n.º 1
0
 public CalcPresenter(ICalcView view = null, ICalcModel model = null)
 {
     this.view        = view;
     this.model       = model;
     this.view.Add   += Add;
     this.view.Reset += Reset;
     this.view.Show();
 }
Exemplo n.º 2
0
        public CalcPresenter(ICalcView view       = null, ICalcModel model = null,
                             ICalcService service = null)
        {
            _model   = model;
            _service = service;
            _view    = view;

            MapMessages();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Given a collection of values, sums them, and sets the
        /// <see
        ///     cref="P:SampleMVP.ICalcModel.Total" />
        /// and
        /// <see
        ///     cref="P:SampleMVP.ICalcModel.RunningTotal" />
        /// properties accordingly.
        /// </summary>
        /// <param name="model">
        /// (Required.) Reference to an instance of an object that implements
        /// the <see cref="T:SampleMVP.ICalcModel" /> interface.
        /// </param>
        /// <param name="numbers">
        /// (Required.) Reference to an instance of a collection of values that
        /// are to be summed.
        /// </param>
        /// <exception cref="T:System.ArgumentNullException">
        /// Thrown if either of the required parameters,
        /// <paramref
        ///     name="numbers" />
        /// or <paramref name="model" /> are passed a
        /// <c>null</c> value.
        /// </exception>
        /// <remarks>
        /// This method does nothing if the <paramref name="numbers" />
        /// collection contains zero elements.
        /// </remarks>
        public void CalculateTotal(ICalcModel model, IList <decimal> numbers)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (numbers.Count == 0)
            {
                return;
            }

            model.Total         = numbers.Sum();
            model.RunningTotal += model.Total;

            OnTotalComputed(new TotalComputedEventArgs(numbers, model.Total));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Associates this presenter with a model object.
        /// </summary>
        /// <returns>
        /// Reference to the same instance of the object that called this
        /// method, for fluent use.
        /// </returns>
        /// <exception cref="T:System.ArgumentNullException">
        /// Thrown if the required parameter, <paramref name="model" />, is
        /// passed a <c>null</c> value.
        /// </exception>
        public ICalcPresenter WithModel(ICalcModel model)
        {
            _model = model ?? throw new ArgumentNullException(nameof(model));

            return(this);
        }
Exemplo n.º 5
0
Arquivo: Form1.cs Projeto: ombt/ombt
 public CalcController( ICalcModel model, ICalcView view)
 {
     this.model = model;
     this.view  = view;
     this.view.AddListener(this);
 }
 public ModelFacade(ICalcModel calcModel, ILogger logger, IAuth auth)
 {
     this.calcModel = calcModel;
     this.logger    = logger;
     this.auth      = auth;
 }