.net动态生成dll文件

using System;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.Reflection;
using System.Text;
using System.CodeDom;
using System.IO;

namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
object i = Calc("38+44*4/2");
Console.WriteLine(i.ToString());
Console.ReadLine();

}

public static object Calc(string expression)
{
string classNamespace = "BS2.Custom"; //命名空间
string className = "MF"+"Job"; //类名或表名


string methodName = "Run";
expression = expression.Replace("/", "*1.0/"); ///

//生成一个可编译的单元,这是最根部的东西
CodeCompileUnit compunit = new CodeCompileUnit();

// 创建编译器实例//设置编译器对象
CSharpCodeProvider csprovider = new CSharpCodeProvider();
ICodeCompiler complier = csprovider.CreateCompiler();
ICodeGenerator gen = csprovider.CreateGenerator(); //生成CS文件
//StreamWriter sw = new StreamWriter("testywm.cs", false);
//StreamWriter writer = new StreamWriter(@"c:\testywm.cs", false);
StreamWriter sw = new StreamWriter(@"c:\testywm.cs",false);
gen.GenerateCodeFromCompileUnit(compunit, sw, new CodeGeneratorOptions());

// 设置编译参数。
CompilerParameters paras = new CompilerParameters();
paras.GenerateExecutable = false; //编译成exe还是dll
paras.GenerateInMemory = false; //是否写入内存,不写入内存就写入磁盘
paras.OutputAssembly = "c:\\test.dll"; //输出路径
paras.IncludeDebugInformation = false; //是否产生pdb调试文件 默认是false

#region 动态添加dll引用
paras.ReferencedAssemblies.Add("System.dll");//添加引用DLL
paras.ReferencedAssemblies.Add("System.Data.dll");//添加引用DLL
paras.ReferencedAssemblies.Add("D:\\BS2\\BSCore\\bin\\Debug\\BS2.Core.dll");//添加引用DLL
paras.ReferencedAssemblies.Add("D:\\BS2\\BSHelp\\bin\\Debug\\BS2.Help.dll");//添加引用DLL
paras.ReferencedAssemblies.Add("D:\\BS2\\csla20cs\\Csla\\bin\\Debug\\Csla.dll");//添加引用DLL
#endregion

StringBuilder classSource = new StringBuilder();
#region 加载引用
classSource.Append("using System;\r\n");
classSource.Append("using System.Collections.Generic;\r\n");
classSource.Append("using System.Text;\r\n");
classSource.Append("using System.Data;\r\n");
classSource.Append("using System.Data.SqlClient;\r\n");
classSource.Append("using Csla;\r\n");
classSource.Append("using Csla.Data;\r\n");
classSource.Append("using BS2.Help;\r\n");
classSource.Append("using BS2.Help.Enum;\r\n");
#endregion

#region 命名空间及类名
classSource.Append("namespace " + classNamespace + " \r\n");
classSource.Append("{ \r\n");
classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// 职务 (可编辑根对象) \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" [Serializable()] \r\n ");
classSource.Append(" public class "+ className +" : BusinessBase<"+ className +"> \r\n");
classSource.Append(" { \r\n");
#endregion

#region 构造函数
classSource.Append(" private "+ className +"() \r\n");
classSource.Append(" { /* require use of factory methods */ } \r\n");
classSource.Append(" private "+ className +"(SafeDataReader dr) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" //Fetch(dr); \r\n");
classSource.Append(" } \r\n");
#endregion

#region 业务属性

classSource.Append(" private int _id; \r\n");
classSource.Append(" private string _jobNo = string.Empty; \r\n");
classSource.Append(" private string _jobName = string.Empty; \r\n");
classSource.Append(" private string _jobNote = string.Empty; \r\n");
classSource.Append(" private byte[] _timestamp = new byte[8]; \r\n");


classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// ID \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" [System.ComponentModel.DataObjectField(true, true)] \r\n");
classSource.Append(" [System.ComponentModel.Browsable(false)] \r\n");
classSource.Append(" public int Id \r\n");
classSource.Append(" { \r\n");
classSource.Append(" get \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanReadProperty(true); \r\n");
classSource.Append(" return _id; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" set \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanWriteProperty(true); \r\n");
classSource.Append(" if (_id != value) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" _id = value; \r\n");
classSource.Append(" PropertyHasChanged(); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// 职务编号 \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" [System.ComponentModel.DisplayName(\"职务编号\")] \r\n");
classSource.Append(" public string JobNo \r\n");
classSource.Append(" { \r\n");
classSource.Append(" get \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanReadProperty(true); \r\n");
classSource.Append(" return _jobNo; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" set \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanWriteProperty(true); \r\n");
classSource.Append(" if (value == null) value = string.Empty; \r\n");
classSource.Append(" if (_jobNo != value) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" _jobNo = value; \r\n");
classSource.Append(" PropertyHasChanged(); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// 职务名称 \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" [System.ComponentModel.DisplayName(\"职务名称\")] \r\n");
classSource.Append(" public string JobName \r\n");
classSource.Append(" { \r\n");
classSource.Append(" get \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanReadProperty(true); \r\n");
classSource.Append(" return _jobName; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" set \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanWriteProperty(true); \r\n");
classSource.Append(" if (value == null) value = string.Empty; \r\n");
classSource.Append(" if (_jobName != value) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" _jobName = value; \r\n");
classSource.Append(" PropertyHasChanged(); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// 职务描述 \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" [System.ComponentModel.DisplayName(\"职务描述\")] \r\n");
classSource.Append(" public string JobNote \r\n");
classSource.Append(" { \r\n");
classSource.Append(" get \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanReadProperty(true); \r\n");
classSource.Append(" return _jobNote; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" set \r\n");
classSource.Append(" { \r\n");
classSource.Append(" CanWriteProperty(true); \r\n");
classSource.Append(" if (value == null) value = string.Empty; \r\n");
classSource.Append(" if (_jobNote != value) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" _jobNote = value; \r\n");
classSource.Append(" PropertyHasChanged(); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");


classSource.Append(" protected override object GetIdValue() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return _id; \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public override string ToString() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return _jobNo + \"[\" + _jobName + \"]\"; \r\n");
classSource.Append(" } \r\n");

#endregion

#region 业务方法

#endregion

#region 约束规则

classSource.Append(" protected override void AddBusinessRules() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" base.AddBusinessRules(); \r\n");
classSource.Append(" ValidationRules.AddRule(BS2.Core.Validation.BSCommonRules.BSStringRequired, \"JobNo\"); \r\n");
classSource.Append(" ValidationRules.AddRule(BS2.Core.Validation.BSCommonRules.BSStringRequired, \"JobName\"); \r\n");
classSource.Append(" } \r\n");

#endregion

#region 权限规则

classSource.Append(" public static bool CanAddObject() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return true; \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static bool CanGetObject() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return true; \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static bool CanDeleteObject() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return true; \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static bool CanEditObject() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return true; \r\n");
classSource.Append(" } \r\n");

#endregion

#region Save方法

classSource.Append(" public override "+ className +" Save() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (IsNew) this.ValidationRules.CheckRules(); \r\n");
classSource.Append(" if ((!IsNew) && (IsDirty) && (!this.IsChild) && (IsValid) && (EditLevel == 0)) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" EnumBussinessObjState state = BS2.Core.Command.BussinessIsChanged.Execute(\"MF_JOB\", _id, _timestamp, EnumDataBase.SecurityDataBase); \r\n");
classSource.Append(" if (state == EnumBussinessObjState.Deleted) throw new BS2.Core.BSUpdateBussinessException(\"当前要保存的对象已经被删除!\"); \r\n");
classSource.Append(" if (state == EnumBussinessObjState.Modifed) \r\n");
classSource.Append(" { \r\n");
//classSource.Append(" if (BS2.Help.ShowMesssage.Confirm(\"当前要保存的对象已经被他人修改过!\n保存操作将覆盖他人修改的内容,是否继续?\") == false) { throw new BS2.Core.BSNormalBussinessException(); } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" if (state == EnumBussinessObjState.UnKnown) { throw new BS2.Core.BSUpdateBussinessException(\"检查当前要保存的对象时发生未知情况!\"); } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" return base.Save(); \r\n");
classSource.Append(" } \r\n");

#endregion

#region 工厂方法(静态)

classSource.Append(" public static "+ className +" NewJob() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (!CanAddObject()) \r\n");
classSource.Append(" throw new System.Security.SecurityException( \r\n");
classSource.Append(" \"User not authorized to add a project\"); \r\n");
classSource.Append(" return DataPortal.Create<"+ className +">(); \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static "+ className +" GetJob(int id) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (!CanGetObject()) \r\n");
classSource.Append(" throw new System.Security.SecurityException( \r\n");
classSource.Append(" \"User not authorized to view a project\"); \r\n");
classSource.Append(" return DataPortal.Fetch<"+ className +">(new Criteria(id)); \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static "+ className +" GetJob(SafeDataReader dr) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" return new "+ className +"(dr); \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public static void DeleteJob(int id) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (!CanDeleteObject()) \r\n");
classSource.Append(" throw new System.Security.SecurityException( \r\n");
classSource.Append(" \"User not authorized to remove a project\"); \r\n");
classSource.Append(" DataPortal.Delete(new Criteria(id)); \r\n");
classSource.Append(" } \r\n");

#endregion

#region 数据访问方法

classSource.Append(" [Serializable()] \r\n");
classSource.Append(" private class Criteria \r\n");
classSource.Append(" { \r\n");
classSource.Append(" private int _id; \r\n");
classSource.Append(" public int Id \r\n");
classSource.Append(" { \r\n");
classSource.Append(" get { return _id; } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" public Criteria(int id) \r\n");
classSource.Append(" { _id = id; } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" [RunLocal()] \r\n");
classSource.Append(" private new void DataPortal_Create() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" ; \r\n");
classSource.Append(" } \r\n");

classSource.Append(" private void DataPortal_Fetch(Criteria criteria) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" using (SqlConnection cn = new SqlConnection(BS2.Help.DataBaseConn.SecurityConnection)) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" cn.Open(); \r\n");
classSource.Append(" using (SqlCommand cm = cn.CreateCommand()) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" string sSQL = \" SELECT MID,PID,JB_NO,JB_NAME,JB_NOTE,LastChanged FROM MF_JOB WHERE MID=\" + criteria.Id.ToString(); \r\n");
classSource.Append(" cm.CommandType = CommandType.Text; \r\n");
classSource.Append(" cm.CommandText = sSQL; \r\n");
classSource.Append(" using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (dr.Read()) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" Fetch(dr); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" [Transactional(TransactionalTypes.TransactionScope)] \r\n");
classSource.Append(" protected override void DataPortal_Insert() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" using (SqlConnection cn = new SqlConnection(BS2.Help.DataBaseConn.SecurityConnection)) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" cn.Open(); \r\n");

classSource.Append(" using (SqlCommand cm = cn.CreateCommand()) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" string sSQL = \"INSERT INTO MF_JOB (JB_NO,JB_NAME,JB_NOTE) VALUES('\" + _jobNo + \"','\" + _jobName + \"','\" + _jobNote + \"')\"; \r\n");
classSource.Append(" cm.CommandType = CommandType.StoredProcedure; \r\n");
classSource.Append(" cm.CommandText = \"addBussiness\"; \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@InsertSQL\", sSQL); \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@TableName\", \"MF_JOB\"); \r\n");
classSource.Append(" SqlParameter param = new SqlParameter(\"@id\", SqlDbType.Int); \r\n");
classSource.Append(" param.Direction = ParameterDirection.Output; \r\n");
classSource.Append(" cm.Parameters.Add(param); \r\n");
classSource.Append(" param = new SqlParameter(\"@newLastChanged\", SqlDbType.Timestamp); \r\n");
classSource.Append(" param.Direction = ParameterDirection.Output; \r\n");
classSource.Append(" cm.Parameters.Add(param); \r\n");

classSource.Append(" cm.ExecuteNonQuery(); \r\n");

classSource.Append(" _id = (int)cm.Parameters[\"@id\"].Value; \r\n");
classSource.Append(" _timestamp = (byte[])cm.Parameters[\"@newLastChanged\"].Value; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

classSource.Append(" [Transactional(TransactionalTypes.TransactionScope)] \r\n");
classSource.Append(" protected override void DataPortal_Update() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" if (base.IsDirty) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" using (SqlConnection cn = new SqlConnection(BS2.Help.DataBaseConn.SecurityConnection)) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" cn.Open(); \r\n");
classSource.Append(" using (SqlCommand cm = cn.CreateCommand()) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" string sSQL = \"UPDATE MF_JOB SET JB_NO = '\" + _jobNo + \"',JB_NAME ='\" + _jobName + \"',JB_NOTE ='\" + _jobNote + \"'\" + \r\n");
classSource.Append(" \" WHERE MID=\" + _id.ToString(); \r\n");
classSource.Append(" cm.CommandType = CommandType.StoredProcedure; \r\n");
classSource.Append(" cm.CommandText = \"updateBussiness\"; \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@UpdateSQL\", sSQL); \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@TableName\", \"MF_JOB\"); \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@id\", _id); \r\n");
classSource.Append(" SqlParameter param = new SqlParameter(\"@newLastChanged\", SqlDbType.Timestamp); \r\n");
classSource.Append(" param.Direction = ParameterDirection.Output; \r\n");
classSource.Append(" cm.Parameters.Add(param); \r\n");
classSource.Append(" cm.ExecuteNonQuery(); \r\n");
classSource.Append(" _timestamp = (byte[])cm.Parameters[\"@newLastChanged\"].Value; \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");


classSource.Append(" [Transactional(TransactionalTypes.TransactionScope)] \r\n");
classSource.Append(" protected override void DataPortal_DeleteSelf() \r\n");
classSource.Append(" { \r\n");
classSource.Append(" DataPortal_Delete(new Criteria(_id)); \r\n");
classSource.Append(" } \r\n");

classSource.Append(" [Transactional(TransactionalTypes.TransactionScope)] \r\n");
classSource.Append(" private void DataPortal_Delete(Criteria criteria) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" using (SqlConnection cn = new SqlConnection(BS2.Help.DataBaseConn.SecurityConnection)) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" cn.Open(); \r\n");
classSource.Append(" using (SqlCommand cm = cn.CreateCommand()) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" cm.CommandType = CommandType.StoredProcedure; \r\n");
classSource.Append(" cm.CommandText = \"deleteJob\"; \r\n");
classSource.Append(" cm.Parameters.AddWithValue(\"@id\", criteria.Id); \r\n");
classSource.Append(" cm.ExecuteNonQuery(); \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");
classSource.Append(" } \r\n");

#endregion

#region 数据访问方法(内存访问器访问)

classSource.Append(" /// <summary> \r\n");
classSource.Append(" /// 从数据访问器获取数据 \r\n");
classSource.Append(" /// </summary> \r\n");
classSource.Append(" /// <param name=\"dr\"></param> \r\n");
classSource.Append(" private void Fetch(SafeDataReader dr) \r\n");
classSource.Append(" { \r\n");
classSource.Append(" _id = dr.GetInt32(\"MID\"); \r\n");
classSource.Append(" _jobNo = dr.GetString(\"JB_NO\"); \r\n");
classSource.Append(" _jobName = dr.GetString(\"JB_NAME\"); \r\n");
classSource.Append(" _jobNote = dr.GetString(\"JB_NOTE\"); \r\n");
classSource.Append(" dr.GetBytes(\"LastChanged\", 0, _timestamp, 0, 8); \r\n");

classSource.Append(" MarkOld(); \r\n");
classSource.Append(" } \r\n");

#endregion

#region 命名空间及类名结尾
classSource.Append(" } \r\n");
classSource.Append("} \r\n");
#endregion

sw.Write(classSource.ToString()); //输出文件
sw.Close(); //关闭文件


//System.Diagnostics.Debug.WriteLine(classSource.ToString()); 调试用。注释掉
// 编译代码。
CompilerResults result = complier.CompileAssemblyFromSource(paras, classSource.ToString());
// 获取编译后的程序集。

Assembly assembly = result.CompiledAssembly;

动态调用方法。
//object eval = assembly.CreateInstance(className);
//MethodInfo method = eval.GetType().GetMethod(methodName);
object reobj = "生成dll成功";// method.Invoke(eval, null);
//GC.Collect();
return reobj;

}


}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值