创建自定义特性
// 规定RemarkAttribute 特性可应用到的项目的类型
[AttributeUsage(AttributeTargets.Method)]
public class RemarkAttribute : Attribute
{
//定义标识用于区分不同方法
string remark;
public string Remark
{
get { return remark; }
}
//构造函数
public RemarkAttribute(string comment)
{
remark = comment;
}
}
定义f(x)曲线,并使用自定义特性描述
//定义f(x)
[RemarkAttribute("CalculateValue")]
public static double Functio(double x)
{
float y;
float z = Mathf.Sin((float)(Mathf.PI * lamudaCalValueStatic * x));
float m = (float)(Mathf.PI * lamudaCalValueStatic * x);
y = isDoubleStatic ? Mathf.Pow(z / m, 2) * (1 + Mathf.Cos((float)(2 * (dStatic * Mathf.PI / (lamudaStatic * D)) * x))) : Mathf.Pow(z / m, 2);
y = (float)Math.Round(y, 3);
return y;
}
完成积分计算