| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
-
- using System;
- using System.Collections.Generic;
- namespace MuchInfo.Chart.Data.Models
- {
- /// <summary>
- /// 公式内容设置
- /// </summary>
- public class ProgramModel
- {
- //用户设置周期参数
- private Dictionary<string, CustomParamModel> _customParams = new Dictionary<string, CustomParamModel>();
- /// <summary>
- /// 用户设置周期参数
- /// </summary>
- public Dictionary<string, CustomParamModel> CustomParams
- {
- get { return _customParams; }
- }
- private Dictionary<string, string> _defaultParams = new Dictionary<string, string>();
- /// <summary>
- /// 默认周期参数
- /// </summary>
- public Dictionary<string, string> DefaultParams
- {
- get { return _defaultParams; }
- }
- /// <summary>
- /// 是否为主图指标
- /// </summary>
- public bool IsMainView { get; set; }
- /// <summary>
- /// 公式名称
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// 转换成可计算的公式
- /// </summary>
- /// <returns></returns>
- public FormulaModel CovertToFormulaModel()
- {
- var formulaModel = new FormulaModel();
- //formulaModel.FormulaName = this.Name;
- string paramsStr = "(";
- foreach (var paramsName in DefaultParams.Keys)
- {
- if (!DefaultParams.ContainsKey(paramsName)) throw new Exception("公式默认参数获取异常!");
- if (string.IsNullOrEmpty(CustomParams[paramsName].Value))
- {
- CustomParams[paramsName].Value = DefaultParams[paramsName];
- }
- paramsStr += CustomParams[paramsName].Value + ",";
- }
- paramsStr = paramsStr.TrimEnd(',') + ")";
- formulaModel.FormulaName = this.Name + (paramsStr.Equals("()") ? string.Empty : paramsStr);
- formulaModel.IsMainIndicator = this.IsMainView;
- formulaModel.EditProgram = this;
- return formulaModel;
- }
- }
- /// <summary>
- /// 处理无法编辑字典值问题
- /// </summary>
- public class CustomParamModel
- {
- private string _value;
- /// <summary>
- /// 用户设置默认值
- /// </summary>
- public string Value
- {
- get { return _value; }
- set { _value = value; }
- }
- }
- }
|