Exemplo n.º 1
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public double CalcNumber(string formula, IVariablesContainer variables)
        {
            var formulaNodes = _formulaCache.GetFormulaNodes(formula);
            var wrapper      = VariablesSource.Create(variables);

            return(OnCalcNumber(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public EvaluatorValue Calc(string formula, IVariablesContainer variables)
        {
            var formulaNodes = _formulaCache.GetFormulaNodes(formula);
            var wrapper      = VariablesSource.Create(variables);

            return(OnCalcAggregated(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public List <string> CalcWordList(string formula, IVariablesContainer variables)
        {
            var formulaNodes = _formulaCache.GetFormulaNodes(formula);
            var wrapper      = VariablesSource.Create(variables);

            return(OnCalcWordList(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 4
0
        public BotWrapper(int botId,
                          string link,
                          string token,
                          /*int ownerID, IMarkupTree tree,*/
                          ITextMessagesManager textManager = null,
                          IFilter filter = null,
                          IVariablesContainer globalVariables = null,
                          BotStatisticsForest botStatistics   = null,
                          StupidBotAntispam antispam          = null

                          ) : base(botId, link, token)
        {
            StatisticsContainer = botStatistics ?? new BotStatisticsForest();
            stupidBotAntispam   = antispam ?? new StupidBotAntispam();
            sessionsDictionary  = new ConcurrentDictionary <int, ISession>();
            TMM = textManager ?? new UntranslatableTextMessagesManager();
            //MarkupTree = tree ?? throw new ArgumentNullException(nameof(tree));
            GlobalFilter = filter ?? new GlobalFilter();
            GlobalVars   = globalVariables ?? new VariablesContainer();
            //BotOwner = new BotOwner(ownerID, this);
        }
Exemplo n.º 5
0
 internal static VariablesSource Create(IVariablesContainer variablesContainer)
 {
     return(new VariablesSource(variablesContainer, variablesDict: null));
 }
Exemplo n.º 6
0
 private VariablesSource(IVariablesContainer variablesContainer, IDictionary <string, EvaluatorValue> variablesDict)
 {
     _variablesContainer = variablesContainer;
     _variablesDict      = variablesDict;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public double CalcNumber(FormulaNodes formulaNodes, IVariablesContainer variables)
        {
            var wrapper = VariablesSource.Create(variables);

            return(OnCalcNumber(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public EvaluatorValue Calc(FormulaNodes formulaNodes, IVariablesContainer variables)
        {
            var wrapper = VariablesSource.Create(variables);

            return(OnCalcAggregated(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public bool CalcBoolean(FormulaNodes formulaNodes, IVariablesContainer variables)
        {
            var wrapper = VariablesSource.Create(variables);

            return(OnCalcBoolean(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public List <string> CalcWordList(FormulaNodes formulaNodes, IVariablesContainer variables)
        {
            var wrapper = VariablesSource.Create(variables);

            return(OnCalcWordList(formulaNodes.Nodes, wrapper));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Calculate formula
        /// </summary>
        /// <exception cref="VariableNotFoundException"></exception>
        /// <exception cref="InvalidCastException"></exception>
        /// <exception cref="ExtraTypeNoFreeIdException"></exception>
        /// <exception cref="ExtraTypeIdNotFoundException"></exception>
        public DateTime CalcDateTime(FormulaNodes formulaNodes, IVariablesContainer variables)
        {
            var wrapper = VariablesSource.Create(variables);

            return(OnCalcDateTime(formulaNodes.Nodes, wrapper));
        }