Ejemplo n.º 1
0
 public CalculatorService(INumberFactory numberFactory)
 {
     this.numberFactory = numberFactory;
     currrentMode       = Mode.DEC;
     Expression         = GetExpression("0", "0");
     Expressions        = new List <Expression <INumber> >();
 }
Ejemplo n.º 2
0
 public void SetUp()
 {
     //Arrange
     numberFactory     = new NumberFactory();
     calculatorService = new CalculatorService(numberFactory)
     {
         CurrentMode = Mode.BIN
     };
 }
Ejemplo n.º 3
0
 public ComponentSet(JepInstance j)
 {
     this.numFac    = j.NumFac;
     this.varFac    = j.VarFac;
     this.nodeFac   = j.NodeFac;
     this.varTab    = j.VarTab;
     this.funTab    = j.FunTab;
     this.opTab     = j.OpTab;
     this.parser    = j.Parser;
     this.evaluator = j.Evaluator;
     this.pv        = j.PrintVisitor;
 }
        /// <summary>
        /// Initializes new instance of <see cref="CalculationObjectFactory"/>.
        /// </summary>
        /// <param name="numberFactory">Factory of numbers.</param>
        /// <param name="resourceStore">Store of resources.</param>
        public CalculationObjectFactory(INumberFactory numberFactory, IResourceStore resourceStore)
        {
            _numberFactory = numberFactory;
            _resourceStore = resourceStore;

            _knownUnaryFunctions = new Dictionary <string, Func <IHasValue> >
            {
                { "log2", () => new Log2(_resourceStore, _numberFactory) }
            };

            _knownBinaryFunctions = new Dictionary <string, Func <IHasValue> >
            {
                { "+", () => new Plus(_resourceStore, _numberFactory) },
                { "-", () => new Minus(_resourceStore, _numberFactory) },
                { "*", () => new Multiply(_resourceStore, _numberFactory) },
                { "/", () => new Divide(_resourceStore, _numberFactory) }
            };
        }
Ejemplo n.º 5
0
 public void SetComponents(IJepComponent[] components)
 {
     foreach (IJepComponent component in components)
     {
         if (component is INumberFactory)
         {
             this._numFac = (INumberFactory)component;
         }
         else if (component is VariableFactory)
         {
             this._varFac = (VariableFactory)component;
         }
         else if (component is NodeFactory)
         {
             this._nodeFac = (NodeFactory)component;
         }
         else if (component is VariableTable)
         {
             this._varTab = (VariableTable)component;
         }
         else if (component is FunctionTable)
         {
             this._funTab = (FunctionTable)component;
         }
         else if (component is OperatorTable)
         {
             this._opTab = (OperatorTable)component;
         }
         else if (component is IParser)
         {
             this._parser = (IParser)component;
         }
         else if (component is IEvaluator)
         {
             this._evaluator = (IEvaluator)component;
         }
         else if (component is Colosoft.Text.Jep.PrintVisitor)
         {
             this._pv = (Colosoft.Text.Jep.PrintVisitor)component;
         }
     }
     this.ReinitializeComponents();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes new instance of <see cref="Divide"/>.
 /// </summary>
 /// <param name="resourceStore">Store of resources.</param>
 /// <param name="numberFactory">Number factory.</param>
 public Divide(IResourceStore resourceStore, INumberFactory numberFactory)
     : base(resourceStore)
 {
     _numberFactory = numberFactory;
 }
Ejemplo n.º 7
0
 public void init(JepInstance jep)
 {
     this.nf = jep.NumFac;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes new instance of <see cref="Multiply"/>.
 /// </summary>
 /// <param name="resourceStore">Store of resources.</param>
 /// <param name="numberFactory">Number factory.</param>
 public Multiply(IResourceStore resourceStore, INumberFactory numberFactory)
     : base(resourceStore)
 {
     _numberFactory = numberFactory;
 }
Ejemplo n.º 9
0
 public override void Init(JepInstance jep)
 {
     this.nf = jep.NumFac;
 }
 public void SetUp()
 {
     //Arrange
     numberFactory     = new NumberFactory();
     calculatorService = new CalculatorService(numberFactory);
 }
 public ListWrapper(List<int> numberList, INumberFactory numberFactory)
 {
     _numberList = numberList;
     _numberFactory = numberFactory;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes new instance of <see cref="Plus"/>.
 /// </summary>
 /// <param name="resourceStore">Store of resources.</param>
 /// <param name="numberFactory">Number factory.</param>
 public Minus(IResourceStore resourceStore, INumberFactory numberFactory)
     : base(resourceStore)
 {
     _numberFactory = numberFactory;
 }
Ejemplo n.º 13
0
 public Calculator(INumberFactory numberFactory, IOutputService outputService)
 {
     this.numberFactory = numberFactory;
     this.outputService = outputService;
 }