https://github.com/june-it/mystack.formula
实现数学公式逻辑运算,支持数据源值计算。
https://github.com/june-it/mystack.formula
farmula
Last synced: about 2 months ago
JSON representation
实现数学公式逻辑运算,支持数据源值计算。
- Host: GitHub
- URL: https://github.com/june-it/mystack.formula
- Owner: june-it
- Created: 2024-08-08T08:32:32.000Z (10 months ago)
- Default Branch: develop
- Last Pushed: 2024-08-12T08:39:57.000Z (10 months ago)
- Last Synced: 2025-02-01T16:10:01.014Z (4 months ago)
- Topics: farmula
- Language: C#
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MyStack.Formula
公式运算## 调用方式
```
// 服务注入
var services = new ServiceCollection();
services.AddFormula(context.Configuration, configure =>
{
// 配置JSON数据源
configure.UseConfigurationIdValue();
});```
## 功能
```
// 调用
var formulaEngine = serviceProvider.GetRequiredService();
```### 运算符 `+`、`-`、`*`、`/`、`^`
```
// 结果:2
var actualValue = formulaEngine.Calculate("1+1");
```### 括号符
```
// 结果:4
var actualValue = formulaEngine.Calculate("(1+1)*2");
```### 复杂公式
```
// 调用
// 结果:9.001953125
var actualValue = formulaEngine.Calculate("3+4*2/(1-5)^2^3+2*(2+1)");
```### 三角函数
```
// 调用
// 结果:1024
var actualValue = formulaEngine.Calculate("COS(900-3*10*30)+123.45+30*30-0.45+TAN(0)");
```### 数据源
#### 值类型计算
```
// 配置Id的值为:<1> = 1
// 结果:4
var actualValue = formulaEngine.Calculate("(1+<1>)*2");```
#### 公式类型计算
```
// 配置Id的值为:<2> = (2+1)*2
// 结果:22
var actualValue = formulaEngine.Calculate("(1+<1>)*2");```