コード例 #1
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual void InitializeTaskPriority(TaskEntity task, IVariableScope variableScope)
        {
            var priorityExpression = taskDefinition.PriorityExpression;

            if (priorityExpression != null)
            {
                var priority = priorityExpression.GetValue(variableScope);

                if (priority != null)
                {
                    if (priority is string)
                    {
                        try
                        {
                            task.Priority = Convert.ToInt32((string)priority);
                        }
                        catch (FormatException e)
                        {
                            throw new ProcessEngineException("Priority does not resolve to a number: " + priority, e);
                        }
                    }
                    else if (priority is decimal || priority is int)
                    {
                        task.Priority = Convert.ToInt32(priority);
                    }
                    else
                    {
                        throw new ProcessEngineException("Priority expression does not resolve to a number: " +
                                                         priorityExpression.ExpressionText);
                    }
                }
            }
        }
コード例 #2
0
        public static ProcessDefinitionImpl GetProcessDefinitionToCall(IVariableScope execution,
                                                                       BaseCallableElement callableElement)
        {
            var processDefinitionKey = callableElement.GetDefinitionKey(execution);
            var tenantId             = callableElement.GetDefinitionTenantId(execution);

            DeploymentCache deploymentCache = DeploymentCache;

            ProcessDefinitionImpl processDefinition = null;

            if (callableElement.LatestBinding)
            {
                processDefinition =
                    deploymentCache.FindDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId);
            }
            else if (callableElement.DeploymentBinding)
            {
                var deploymentId = callableElement.DeploymentId;
                processDefinition = deploymentCache.FindDeployedProcessDefinitionByDeploymentAndKey(deploymentId,
                                                                                                    processDefinitionKey);
            }
            else if (callableElement.VersionBinding)
            {
                var version = callableElement.GetVersion(execution);
                processDefinition =
                    deploymentCache.FindDeployedProcessDefinitionByKeyVersionAndTenantId(processDefinitionKey, version,
                                                                                         tenantId);
            }

            return(processDefinition);
        }
コード例 #3
0
        //public static CmmnCaseDefinition getCaseDefinitionToCall(IVariableScope execution, BaseCallableElement callableElement)
        //{
        //    string caseDefinitionKey = callableElement.getDefinitionKey(execution);
        //    string tenantId = callableElement.getDefinitionTenantId(execution);

        //    DeploymentCache deploymentCache = DeploymentCache;

        //    CmmnCaseDefinition caseDefinition = null;
        //    if (callableElement.LatestBinding)
        //    {
        //        caseDefinition = deploymentCache.findDeployedLatestCaseDefinitionByKeyAndTenantId(caseDefinitionKey, tenantId);

        //    }
        //    else if (callableElement.DeploymentBinding)
        //    {
        //        string deploymentId = callableElement.DeploymentId;
        //        caseDefinition = deploymentCache.findDeployedCaseDefinitionByDeploymentAndKey(deploymentId, caseDefinitionKey);

        //    }
        //    else if (callableElement.VersionBinding)
        //    {
        //        int? version = callableElement.getVersion(execution);
        //        caseDefinition = deploymentCache.findDeployedCaseDefinitionByKeyVersionAndTenantId(caseDefinitionKey, version, tenantId);
        //    }

        //    return caseDefinition;
        //}

        public static IDecisionDefinition GetDecisionDefinitionToCall(IVariableScope execution,
                                                                      BaseCallableElement callableElement)
        {
            var decisionDefinitionKey = callableElement.GetDefinitionKey(execution);
            var tenantId = callableElement.GetDefinitionTenantId(execution);

            DeploymentCache deploymentCache = DeploymentCache;

            IDecisionDefinition decisionDefinition = null;

            if (callableElement.LatestBinding)
            {
                decisionDefinition =
                    deploymentCache.FindDeployedLatestDecisionDefinitionByKeyAndTenantId(decisionDefinitionKey, tenantId);
            }
            else if (callableElement.DeploymentBinding)
            {
                var deploymentId = callableElement.DeploymentId;
                decisionDefinition = deploymentCache.FindDeployedDecisionDefinitionByDeploymentAndKey(deploymentId,
                                                                                                      decisionDefinitionKey);
            }
            else if (callableElement.VersionBinding)
            {
                var version = callableElement.GetVersion(execution);
                decisionDefinition =
                    deploymentCache.FindDeployedDecisionDefinitionByKeyVersionAndTenantId(decisionDefinitionKey, version,
                                                                                          tenantId);
            }

            return(decisionDefinition);
        }
コード例 #4
0
ファイル: JuelFormEngine.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual object ExecuteScript(string scriptSrc, IVariableScope scope)
        {
            var processEngineConfiguration = Context.ProcessEngineConfiguration;

            //ScriptFactory scriptFactory = processEngineConfiguration.ScriptFactory;
            //ExecutableScript script = scriptFactory.createScriptFromSource(ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE,
            //    scriptSrc);

            //var invocation = new ScriptInvocation(script, scope);
            try
            {
                //processEngineConfiguration.DelegateInterceptor.handleInvocation(invocation);
            }
            //catch (Exception e)
            //{
            //    throw e;
            //}
            catch (System.Exception e)
            {
                throw new ProcessEngineException(e);
            }

            //return invocation.InvocationResult;
            return(null);
        }
コード例 #5
0
        public virtual object GetValue(IVariableScope variableScope, IBaseDelegateExecution contextExecution)
        {
            var elContext = ExpressionManager.GetElContext(variableScope);

            try
            {
                var invocation = new ExpressionGetInvocation(ValueExpression, elContext, contextExecution);
                Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(invocation);
                return(invocation.InvocationResult);
            }
            catch (PropertyNotFoundException pnfe)
            {
                throw new ProcessEngineException(
                          "Unknown property used in expression: " + ExpressionText + ". Cause: " + pnfe.Message, pnfe);
            }
            catch (MethodNotFoundException mnfe)
            {
                throw new ProcessEngineException(
                          "Unknown method used in expression: " + ExpressionText + ". Cause: " + mnfe.Message, mnfe);
            }
            catch (ELException ele)
            {
                throw new ProcessEngineException(
                          "Error while evaluating expression: " + ExpressionText + ". Cause: " + ele.Message, ele);
            }
            catch (System.Exception e)
            {
                throw new ProcessEngineException(
                          "Error while evaluating expression: " + ExpressionText + ". Cause: " + e.Message, e);
            }
        }
コード例 #6
0
 public SubmitFormVariablesInvocation(IFormHandler formHandler, IVariableMap properties,
                                      IVariableScope variableScope) : base(null, null)
 {
     this.FormHandler   = formHandler;
     this.Properties    = properties;
     this.VariableScope = variableScope;
 }
コード例 #7
0
        public virtual void Notify(IDelegateTask delegateTask)
        {
            // Note: we can't cache the result of the expression, because the
            // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'

            IVariableScope variableScope = delegateTask.Execution;

            if (variableScope == null)
            {
                variableScope = delegateTask.CaseExecution;
            }

            var @delegate = Expression.GetValue(variableScope);

            ClassDelegateUtil.ApplyFieldDeclaration(FieldDeclarations, @delegate);

            if (@delegate is ITaskListener)
            {
                try
                {
                    Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(
                        new TaskListenerInvocation((ITaskListener)@delegate, delegateTask));
                }
                catch (System.Exception e)
                {
                    throw new ProcessEngineException("Exception while invoking TaskListener: " + e.Message, e);
                }
            }
            else
            {
                throw new ProcessEngineException("Delegate expression " + Expression +
                                                 " did not resolve to an implementation of " + typeof(ITaskListener));
            }
        }
コード例 #8
0
        private object GetValue(ELContext context, IVariableScope variableScope)
        {
            string expstr = ExpressionString;

            if ((VariableScopeElResolver.EXECUTION_KEY.Equals(expstr) && variableScope is IExecutionEntity) || (VariableScopeElResolver.TASK_KEY.Equals(expstr) && variableScope is ITaskEntity))
            {
                context.IsPropertyResolved = true;
                return(variableScope);
            }
            else if (VariableScopeElResolver.EXECUTION_KEY.Equals(expstr) && variableScope is ITaskEntity entity)
            {
                context.IsPropertyResolved = true;
                return(entity.Execution);
            }
            else if (VariableScopeElResolver.LOGGED_IN_USER_KEY.Equals(expstr))
            {
                context.IsPropertyResolved = true;
                return(Authentication.AuthenticatedUser.Id);
            }

            IScriptingEnginesProvider scriptingEnginesProvider = ProcessEngineServiceProvider.Resolve <IScriptingEnginesProvider>();
            IScriptingEngines         scriptingEngines         = scriptingEnginesProvider.Create(language);

            var execution = variableScope is ITaskEntity te ? te.Execution : variableScope as IExecutionEntity;

            return(scriptingEngines.Evaluate(expstr, execution));
        }
コード例 #9
0
        public Calculator(IVariableScope variables = null, IFunctionScope functions = null)
        {
            this.variables = variables;
            this.functions = functions;

            this.simplifier = new SimplifyBinary(variables, functions);
        }
コード例 #10
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual void InitializeTaskDueDate(TaskEntity task, IVariableScope variableScope)
        {
            var dueDateExpression = taskDefinition.DueDateExpression;

            if (dueDateExpression != null)
            {
                var dueDate = dueDateExpression.GetValue(variableScope);
                if (dueDate != null)
                {
                    if (dueDate is DateTime)
                    {
                        task.DueDate = (DateTime)dueDate;
                    }
                    else if (dueDate is string)
                    {
                        var businessCalendar = BusinessCalender;
                        task.DueDate = businessCalendar.ResolveDuedate((string)dueDate);
                    }
                    else
                    {
                        throw new ProcessEngineException(
                                  "Due date expression does not resolve to a Date or Date string: " +
                                  dueDateExpression.ExpressionText);
                    }
                }
            }
        }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateContext"/> class
 /// </summary>
 /// <param name="data">The <see cref="IVariableScope"/>.</param>
 /// <param name="hostEnvironment"></param>
 internal TemplateContext(IVariableScope data,
                          IHostEnvironment hostEnvironment)
     : base(hostEnvironment)
 {
     this.TempData  = data;
     this.AllErrors = new List <Exception>();
 }
コード例 #12
0
        public virtual void SubmitFormVariables(IVariableMap properties, IVariableScope variableScope)
        {
            VariableMapImpl propertiesCopy = new VariableMapImpl(properties);

            // support legacy form properties
            foreach (var formPropertyHandler in FormPropertyHandlers)
            {
                formPropertyHandler.SubmitFormProperty(variableScope, propertiesCopy);
            }

            // support form data:
            foreach (var formFieldHandler in FormFieldHandlers)
            {
                formFieldHandler.HandleSubmit(variableScope, propertiesCopy, properties);
            }

            // any variables passed in which are not handled by form-fields or form
            // properties are added to the process as variables
            foreach (var propertyId in propertiesCopy.KeySet())
            {
                variableScope.SetVariable(propertyId, propertiesCopy.GetValueTyped <ITypedValue>(propertyId));
            }

            FireFormPropertyHistoryEvents(properties, variableScope);
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="variableScope"></param>
        /// <returns></returns>
        public virtual object GetValue(IVariableScope variableScope)
        {
            ELContext elContext = Context.ProcessEngineConfiguration.ExpressionManager.GetElContext(variableScope);

            try
            {
                ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext);
                Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(invocation);
                return(invocation.InvocationResult);
            }
            //catch (PropertyNotFoundException pnfe)
            //{
            //    throw new ActivitiException("Unknown property used in expression: " + expressionText, pnfe);
            //}
            //catch (MethodNotFoundException mnfe)
            //{
            //    throw new ActivitiException("Unknown method used in expression: " + expressionText, mnfe);
            //}
            //catch (ELException ele)
            //{
            //    throw new ActivitiException("Error while evaluating expression: " + expressionText, ele);
            //}
            catch (Exception e)
            {
                throw new ActivitiException("Error while evaluating expression: " + expressionText, e);
            }
        }
コード例 #14
0
 public ScriptBindings(IList <IResolver> scriptResolvers, IVariableScope variableScope, IBindings wrappedBindings)
 {
     this.scriptResolvers     = scriptResolvers;
     this.variableScope       = variableScope;
     this.wrappedBindings     = wrappedBindings;
     autoStoreScriptVariables = IsAutoStoreScriptVariablesEnabled();
 }
コード例 #15
0
        public Calculator(IVariableScope variables = null, IFunctionScope functions = null)
        {
            this.variables = variables;
            this.functions = functions;

            this.simplifier = new SimplifyBinary(variables, functions);
        }
コード例 #16
0
        public virtual bool Evaluate(IVariableScope scope, IDelegateExecution execution)
        {
            var result = Expression.GetValue(scope, execution);

            EnsureUtil.EnsureNotNull("condition expression returns null", "result", result);
            EnsureUtil.EnsureInstanceOf("condition expression returns non-Boolean", "result", result, typeof(bool));
            return((bool)result);
        }
コード例 #17
0
 public DefaultFormFieldValidatorContext(IVariableScope variableScope, string configuration,
                                         IVariableMap submittedValues, FormFieldHandler formFieldHandler)
 {
     this.variableScope    = variableScope;
     this.configuration    = configuration;
     this.submittedValues  = submittedValues;
     this.formFieldHandler = formFieldHandler;
 }
コード例 #18
0
 protected override object Evaluate(IScriptEngine engine, IVariableScope variableScope, IBindings bindings)
 {
     if (scriptSource == null)
     {
         LoadScriptSource();
     }
     return(base.Evaluate(engine, variableScope, bindings));
 }
コード例 #19
0
 public IResolver CreateResolver(IVariableScope variableScope)
 {
     if (variableScope != null)
     {
         return(new VariableScopeResolver(variableScope));
     }
     return(null);
 }
コード例 #20
0
        protected internal virtual void InitializeConfiguration(ExecutionEntity context, TimerEntity job)
        {
            var businessCalendar =
                Context.ProcessEngineConfiguration.BusinessCalendarManager.GetBusinessCalendar(Type.GetDescription());

            if (Description == null)
            {
                throw new ProcessEngineException("Timer '" + context.ActivityId +
                                                 "' was not configured with a valid duration/time");
            }

            string dueDateString = null;
            //throw new NotImplementedException();
            DateTime?duedate = null;

            // ACT-1415: timer-declaration on start-event may contain expressions NOT
            // evaluating variables but other context, evaluating should happen nevertheless
            IVariableScope scopeForExpression = context;

            if (scopeForExpression == null)
            {
                scopeForExpression = StartProcessVariableScope.SharedInstance;
            }

            var dueDateValue = Description.GetValue(scopeForExpression);

            if (dueDateValue is string)
            {
                dueDateString = (string)dueDateValue;
            }
            else if (dueDateValue is DateTime)
            {
                duedate = (DateTime)dueDateValue;
            }
            else
            {
                throw new ProcessEngineException("Timer '" + context.ActivityId +
                                                 "' was not configured with a valid duration/time, either hand in a java.Util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
            }
            //throw new NotImplementedException();
            if (duedate == null)
            {
                duedate = businessCalendar.ResolveDuedate(dueDateString);
            }

            job.Duedate = (DateTime)duedate;

            if (Type == TimerDeclarationType.Cycle &&
                !ReferenceEquals(jobHandlerType, TimerCatchIntermediateEventJobHandler.TYPE))
            {
                // See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat itself
                if (!IsInterruptingTimer)
                {
                    var prepared = PrepareRepeat(dueDateString);
                    job.Repeat = prepared;
                }
            }
        }
コード例 #21
0
        public static bool DropVariable(this IVariableScope scope, string variableName)
        {
            if (scope == null || scope.VariableManager == null)
            {
                throw new InvalidOperationException("The scope is invalid or the variable manager has been disposed");
            }

            return(scope.VariableManager.DropVariable(variableName));
        }
コード例 #22
0
 public DelegateInvocationAnonymousInnerClass2(CallableElementActivityBehavior outerInstance,
                                               IActivityExecution execution, IVariableScope subInstance, IDelegateVariableMapping varMapping)
     : base(execution, null)
 {
     this._outerInstance = outerInstance;
     this._execution     = execution;
     this._subInstance   = subInstance;
     this._varMapping    = varMapping;
 }
コード例 #23
0
        public void SubmitFormVariables(IVariableMap properties, IVariableScope variableScope)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = ESS.FW.Bpm.Engine.context.Impl.Context.ProcessEngineConfiguration;
            IIdentityService identityService = processEngineConfiguration.IdentityService;
            IRuntimeService  runtimeService  = processEngineConfiguration.RuntimeService;

            logAuthentication(identityService);
            logInstancesCount(runtimeService);
        }
コード例 #24
0
        protected internal virtual IDictionary <string, object> CreateBindings(IVariableScope variableScope)
        {
            if (variableScope == null)
            {
                return(null);
            }

            return(variableScope.Variables);
        }
コード例 #25
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
 protected internal virtual void InitializeTaskAssignments(TaskEntity task, IVariableScope variableScope)
 {
     // assignee
     InitializeTaskAssignee(task, variableScope);
     // candidateUsers
     InitializeTaskCandidateUsers(task, variableScope);
     // candidateGroups
     InitializeTaskCandidateGroups(task, variableScope);
 }
コード例 #26
0
        public virtual IVariableInstance GetVariableInstance(string variableName, bool fetchAllVariables)
        {
            // Transient variable
            if (transientVariabes != null && transientVariabes.ContainsKey(variableName))
            {
                return(transientVariabes[variableName]);
            }

            // Check the local single-fetch cache
            if (usedVariablesCache.ContainsKey(variableName))
            {
                return(usedVariablesCache[variableName]);
            }

            if (fetchAllVariables == true)
            {
                EnsureVariableInstancesInitialized();
                variableInstances.TryGetValue(variableName, out IVariableInstanceEntity variableInstance);
                if (variableInstance != null)
                {
                    return(variableInstance);
                }

                // Go up the hierarchy
                IVariableScope parentScope = ParentVariableScope;
                if (parentScope != null)
                {
                    return(parentScope.GetVariableInstance(variableName, true));
                }

                return(null);
            }
            else
            {
                if (variableInstances != null && variableInstances.ContainsKey(variableName))
                {
                    return(variableInstances[variableName]);
                }

                IVariableInstanceEntity variable = GetSpecificVariable(variableName);
                if (variable != null)
                {
                    usedVariablesCache[variableName] = variable;
                    return(variable);
                }

                // Go up the hierarchy
                IVariableScope parentScope = ParentVariableScope;
                if (parentScope != null)
                {
                    return(parentScope.GetVariableInstance(variableName, false));
                }

                return(null);
            }
        }
コード例 #27
0
ファイル: ListValueProvider.cs プロジェクト: zf321/ESS.FW.Bpm
        public virtual object GetValue(IVariableScope variableScope)
        {
            IList <object> valueList = new List <object>();

            foreach (var provider in providerList)
            {
                valueList.Add(provider.GetValue(variableScope));
            }
            return(valueList);
        }
コード例 #28
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual void InitializeTaskAssignee(TaskEntity task, IVariableScope variableScope)
        {
            var assigneeExpression = taskDefinition.AssigneeExpression;

            if (assigneeExpression != null)
            {
                //TODO 表达式相关
                task.Assignee = (string)assigneeExpression.GetValue(variableScope);
            }
        }
コード例 #29
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual void InitializeTaskName(TaskEntity task, IVariableScope variableScope)
        {
            var nameExpression = taskDefinition.NameExpression;

            if (nameExpression != null)
            {
                var name = (string)nameExpression.GetValue(variableScope);
                task.Name = name;
            }
        }
コード例 #30
0
ファイル: TaskDecorator.cs プロジェクト: zf321/ESS.FW.Bpm
        protected internal virtual void InitializeTaskDescription(TaskEntity task, IVariableScope variableScope)
        {
            var descriptionExpression = taskDefinition.DescriptionExpression;

            if (descriptionExpression != null)
            {
                var description = (string)descriptionExpression.GetValue(variableScope);
                task.Description = description;
            }
        }
コード例 #31
0
        public virtual object GetValue(IVariableScope variableScope)
        {
            IDictionary <string, object> valueMap = new SortedDictionary <string, object>();

            foreach (var entry in providerMap)
            {
                valueMap[entry.Key] = entry.Value.GetValue(variableScope);
            }
            return(valueMap);
        }
コード例 #32
0
ファイル: Context.cs プロジェクト: richardhopton/Flux
        public Context(IWorkflow workflow, IVariableScope variableScope)
            : this(workflow)
        {
            if (variableScope == null)
                return;

            foreach (var variable in variableScope.Variables)
            {
                Variables.Add(variable);
                _values[variable] = new ValueStore();
            }
        }
コード例 #33
0
ファイル: Context.cs プロジェクト: richardhopton/Flux
        public Context(IContext context, IVariableScope variableScope)
            : this(context.Workflow, variableScope)
        {
            var contextVariableScope = context as Context;
            if (contextVariableScope == null)
                return;

            foreach (var argument in Workflow.Arguments)
            {
                _values[argument] = contextVariableScope._values[argument];
            }

            foreach (var variable in contextVariableScope.Variables)
            {
                Variables.Add(variable);
                _values[variable] = contextVariableScope._values[variable];
            }
        }
コード例 #34
0
        public static Expression Apply(IEnumerable<Type> transformations, Expression expr, IVariableScope variables, IFunctionScope functions)
        {
            Expression result = expr;

            foreach (Type type in transformations)
            {
                result = (new EliminateSubtractions(result)).Result;
                result = (new BinaryToLinear(result)).Result;

                RuleOrientedTransformation transformation = (RuleOrientedTransformation)Activator.CreateInstance(type);

                result = transformation.Transform(result, e => Apply(e, variables, functions));

                result = (new LinearToBinary(result)).Result;
                result = (new SimplifyBinary(result, variables, functions)).Result;
            }

            return result;
        }
コード例 #35
0
 public Calculator(Expression expr, IVariableScope variables = null, IFunctionScope functions = null)
     : this(variables, functions)
 {
     this.result = Calculate(expr);
 }
コード例 #36
0
 public SimplifyBinary(IVariableScope variables = null, IFunctionScope functions = null)
 {
     this.variables = variables;
     this.functions = functions;
 }
コード例 #37
0
ファイル: VariableManager.cs プロジェクト: prepare/deveeldb
        public VariableManager(IVariableScope scope)
        {
            Scope = scope;

            variables = new Dictionary<string, Variable>();
        }
コード例 #38
0
 public static Expression Apply(Expression expr, IVariableScope variables, IFunctionScope functions)
 {
     return Apply(transformations, expr, variables, functions);
 }
コード例 #39
0
 // Note: A local scope can only be defined inside a variable scope
 // (another block or a method body).
 public LocalScope(IVariableScope enclosingScope)
     : base(enclosingScope, true)
 {
 }
コード例 #40
0
 public Expression Differentiate(string var, IVariableScope variables, IFunctionScope functions, IDifferentiationScope derivatives)
 {
     return Differentiate(this, var, variables, functions, derivatives);
 }
コード例 #41
0
 public Expression Evaluate(IVariableScope variables, IFunctionScope functions)
 {
     return Evaluate(this, variables, functions);
 }
コード例 #42
0
        public static Expression Differentiate(Expression expr, string var, IVariableScope variables, IFunctionScope functions, IDifferentiationScope derivatives)
        {
            Expression derivative = (new Differentiation(expr, var, derivatives)).Result;

            return Evaluate(derivative, variables, functions);
        }
コード例 #43
0
 internal static VariableSymbol CreateAndDefineVariable(string name, IType type, IVariableScope scope)
 {
     var sym = new VariableSymbol(name, type, scope);
     scope.Define(sym);
     return sym;
 }
コード例 #44
0
        public static Expression Evaluate(IEnumerable<Type> transformations, Expression expr, IVariableScope variables, IFunctionScope functions)
        {
            Expression result = (new EliminateSubtractions(expr)).Result;
            result = (new SimplifyBinary(result, variables, functions)).Result;

            Expression presult = null;

            int count = 0;

            while (!result.Equals(presult) && count < 10)
            {
                presult = result;
                result = Apply(transformations, result, variables, functions);

                count++;
            }

            return (new ReturnSubtractions(result)).Result;
        }
コード例 #45
0
 public Expression Apply(IEnumerable<Type> transformations, IVariableScope variables, IFunctionScope functions)
 {
     return Apply(transformations, this, variables, functions);
 }
コード例 #46
0
 public SimplifyBinary(Expression expr, IVariableScope variables = null, IFunctionScope functions = null)
     : this(variables, functions)
 {
     this.result = Simplify(expr);
 }