GithubHelp home page GithubHelp logo

dynamicexpress's Introduction

DynamicExpress/动态表达式计算

作用

根据动态算法以及给定的对象计算并返回计算结果
用法

1.单个对象(single entity)

T MathDynamicExpress.Core.DynamicExpress.Eval<T>(string expression, object entity)
例如(ex):
MathDynamicExpress.Core.DynamicExpress.Eval<double>("({Field1}+{Field2})*{Field3}", new
         {
             Field1=txt_entity1_field1.Text,
             Field2 = txt_entity1_field2.Text,
             Field3 = txt_entity1_field3.Text
         });

2.多个对象(entities)

T MathDynamicExpress.Core.DynamicExpress.Eval<T>(string expression,params object[] entity)
例如(ex):
MathDynamicExpress.Core.DynamicExpress.Eval<double>("({0.Field1}-{1.Field1})+{1.Field2}*{0.Field2}", 
             new
             {
                 Field1=txt_entity1_field1.Text,
                 Field2 = txt_entity1_field2.Text
             }, 
             new
             {
                 Field1 = txt_entity2_field1.Text,
                 Field2 = txt_entity2_field2.Text
             });

3.datatable

T MathDynamicExpress.Core.DynamicExpress.Eval<T>(string expression, object entity)
例如(ex):
MathDynamicExpress.Core.DynamicExpress.Eval<int>("{0:0}+{0:1}-{1:1}", datatable1);

format:"{col-index or col-name:row-index}"


目前项目中提供了JS Provider使用了开源的V8Engine,在项目中使用是需要在webconfig中配置对应的provider

<configSections>
  <section name="dynamicExpressProvider" type="MathDynamicExpress.Core.DynamicExpressProviderSection, MathDynamicExpress.Core"/>
</configSections>
<dynamicExpressProvider defaultProvider="JsExpressBuilder">
  <providers>
    <add name="JsExpressBuilder" type="MathDynamicExpress.JSExpressBuilder,MathDynamicExpress"></add>
  </providers>
</dynamicExpressProvider>

另外需要设置一下兼容性:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>

具体用法可以参考项目中提供的三个demo。

dynamicexpress's People

Contributors

scottshare avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.