Model/AbstractEntity.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace UnitTransform.Model
{
    /// <summary>
    /// 具有比率关系的转换实体的基类
    /// </summary>
    public abstract class AbstractEntity : INotifyPropertyChanged, IClearInput
    {
        protected Dictionary<string, double> dic = new Dictionary<string, double>();
        protected Dictionary<string, bool> dicflag = new Dictionary<string, bool>();

        protected AbstractEntity()
        {
            InitDic();
        }
        // 下载于www.51aspx.com
        public event PropertyChangedEventHandler PropertyChanged;

        protected void PropertyChange(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected abstract void InitDic();

        protected void SetPropertysValue(string pName, string pValue)
        {
            double result = -1;
            if (double.TryParse(pValue, out result))
            {
                SetForDicflag(false);
                PropertyInfo[] ps = this.GetType().GetProperties();
                foreach (var p in ps)
                {
                    if (pName != p.Name)
                    {
                        double s = dic[pName];
                        double d = dic[p.Name];
                        double v = d / s * result;
                        string r = string.Empty;
                        if (v > 1000000000000)
                            r = v.ToString("E");
                        else
                            r = v.ToString();
                        p.SetValue(this, r, null);
                    }
                }
                SetForDicflag(true);
            }
        }

后面还有 19 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。