1. Inside Zhou
  2. Inside.Util

Commits

Inside Zhou  committed 19054fd

完善InputPlan元数据生成;改进OracleDataHelper;SqlHelper的默认事务级别更改为Serializable;精简HtmlHelper。

  • Participants
  • Parent commits eb3a87d
  • Branches default

Comments (0)

Files changed (5)

File Inside.Util/Properties/AssemblyInfo.cs

View file
  • Ignore whitespace
  * 第四位数字表示不破坏兼容性的修改,如bugfix,细节优化等,当第三位数字变化时,重置为0。
  * 除非有特殊声明,否则前三位数字变化表示均不保证向后兼容。
  */
-[assembly: AssemblyVersion("2.0.0.0")]
+[assembly: AssemblyVersion("2.0.1.0")]

File Inside.Util/Sql/InputPlan.cs

View file
  • Ignore whitespace
 				dynamic col = (from dynamic column in this._columns where column.name == c.column_name select column).Single();
 
 				col.nullable = 1 == c.nullable;
-				col.has_default = null != c.data_default || !(c.data_default is DBNull);
+				col.has_default = null != c.data_default;
 				col.default_value = c.data_default;
 				col.length = c.data_length;
 			}
 							p.Size = (int)c.length;
 						}
 						else {
-							throw new NotSupportedException(string.Format("暂不支持此类型的默认值 : {0}", c.type));
+							throw new NotSupportedException(string.Format("暂不支持此类型的默认值 : {0} : {1}", c.name, c.type));
 						}
 
 						outParam.Add(p);

File Inside.Util/Sql/OracleDataHelper.cs

View file
  • Ignore whitespace
 			}
 		}
 
+		public virtual void Insert(SqlHelper sql = null, params DyObj[] objects) {
+			sql = sql ?? this.SqlHelper;
+			using(var trans = sql.BeginTrans()) {
+				foreach(var obj in objects) {
+					this.DoSave(false, true, null, sql, obj);
+				}
+				trans.Commit();
+			}
+		}
+
+		public void Insert(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
+			if(string.IsNullOrEmpty(cacheOID)) {
+				this.Insert(sql, objects);
+			}
+			else {
+				this.Insert_Cache(cacheOID, sql, objects);
+			}
+		}
+
+		public void Insert_Cache(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
+			if(string.IsNullOrEmpty(cacheOID)) {
+				throw new ArgumentNullException("cacheOID");
+			}
+
+			sql = sql ?? this.SqlHelper;
+			using(var trans = sql.BeginTrans()) {
+				foreach(var obj in objects) {
+					this.DoSave(true, true, cacheOID, sql, obj);
+				}
+				trans.Commit();
+			}
+		}
+
+		public void Update(SqlHelper sql = null, params DyObj[] objects) {
+			sql = sql ?? this.SqlHelper;
+			using(var trans = sql.BeginTrans()) {
+				foreach(var obj in objects) {
+					this.DoSave(false, false, null, sql, obj);
+				}
+				trans.Commit();
+			}
+		}
+
+		public void Update(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
+			if(string.IsNullOrEmpty(cacheOID)) {
+				this.Update(sql, objects);
+			}
+			else {
+				this.Update_Cache(cacheOID, sql, objects);
+			}
+		}
+
+		public void Update_Cache(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
+			if(string.IsNullOrEmpty(cacheOID)) {
+				throw new ArgumentNullException("cacheOID");
+			}
+
+			sql = sql ?? this.SqlHelper;
+			using(var trans = sql.BeginTrans()) {
+				foreach(var obj in objects) {
+					this.DoSave(true, false, cacheOID, sql, obj);
+				}
+				trans.Commit();
+			}
+		}
+
 		public virtual void Save(SqlHelper sql = null, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 			using(var trans = sql.BeginTrans()) {
-				foreach(var obj in objects) {
-					this.DoSave(null, null, sql, obj);
+				foreach(dynamic obj in objects) {
+					this.DoSave(false, ObjectHelper.IsNil(obj.oid) || null == this.FindByOID(obj.oid, sql, null), null, sql, obj);
 				}
 				trans.Commit();
 			}
 				this.Save(sql, objects);
 			}
 			else {
-				sql = sql ?? this.SqlHelper;
-				using(var trans = sql.BeginTrans()) {
-					foreach(var obj in objects) {
-						this.DoSave("cache", cacheOID, sql, obj);
-					}
-					trans.Commit();
-				}
+				this.Save_Cache(cacheOID, sql, objects);
 			}
 		}
 
 
 			sql = sql ?? this.SqlHelper;
 			using(var trans = sql.BeginTrans()) {
-				foreach(var obj in objects) {
-					this.DoSave("cache", cacheOID, sql, obj);
+				foreach(dynamic obj in objects) {
+					this.DoSave(true, ObjectHelper.IsNil(obj.oid) || 0 == (decimal)sql.Init("select count(*) from {0} where cache_oid = :cache_oid and oid = :oid".Fmt(this.RelationCacheName)).AddParameter("cache_oid", cacheOID).AddParameter("oid", obj.oid as string).ExecuteScalarAuto(), cacheOID, sql, obj);
 				}
 				trans.Commit();
 			}
 		}
 
-		protected virtual void DoSave(string type, string cacheOID, SqlHelper sql, DyObj input) {
+		protected virtual void DoSave(bool trueForCache, bool trueForInsert, string cacheOID, SqlHelper sql, DyObj input) {
 			dynamic obj = input;
 
-			switch(type) {
-				case "cache":
-					var inputPlan = InputPlan.CreateInstance(this.RelationCacheName, sql);
-					if(ObjectHelper.IsNil(obj.oid) || 0 == (decimal)sql.Init("select count(*) from {0} where cache_oid = :cache_oid and oid = :oid".Fmt(inputPlan.RelationName)).AddParameter("cache_oid", cacheOID).AddParameter("oid", obj.oid as string).ExecuteScalarAuto()) {
-						this.Insert_Cache(cacheOID, inputPlan, obj, sql);
-					}
-					else {
-						this.Update_Cache(cacheOID, inputPlan, obj, sql);
-					}
-					break;
-				default:
-					if(ObjectHelper.IsNil(obj.oid) || null == this.FindByOID(obj.oid, sql, null)) {
-						this.Insert(obj, sql);
-					}
-					else {
-						this.Update(obj, sql);
-					}
-					break;
+			if(trueForCache) {
+				var inputPlan = InputPlan.CreateInstance(this.RelationCacheName, sql);
+				if(trueForInsert) {
+					this.Insert_Cache(cacheOID, inputPlan, obj, sql);
+				}
+				else {
+					this.Update_Cache(cacheOID, inputPlan, obj, sql);
+				}
+			}
+			else {
+				if(trueForInsert) {
+					InputPlan.Insert(input, sql);
+				}
+				else {
+					InputPlan.Update(input, sql);
+				}
 			}
 		}
 
 			GenerateArchiveTable(this.RelationArchiveName, this.RelationLogName, this.RelationName, sql);
 		}
 
-		protected virtual void Insert(DyObj input, SqlHelper sql) {
-			InputPlan.Insert(input, sql);
-		}
-
 		protected virtual void Insert_Cache(string cacheOID, InputPlan inputPlan, DyObj input, SqlHelper sql) {
 			if(ObjectHelper.IsNil(input["oid"])) {
 				input["oid"] = sql.Init("select rawtohex(sys_guid()) from dual").ExecuteScalarAuto();
 			sql.Init(sb.ToString()).AddParameters(parameters.ToArray()).AddParameter("cache_oid", cacheOID).AddParameter("oid", input["oid"]).ExecuteNonQueryAuto();
 		}
 
-		protected virtual void Update(DyObj input, SqlHelper sql) {
-			InputPlan.Update(input, sql);
+		public virtual void Lock(SqlHelper sql, params string[] oids) {
+			sql = sql ?? this.SqlHelper;
+
+			var objects = new List<DyObj>();
+			foreach(var oid in oids) {
+				var obj = new DyObj();
+				obj["oid"] = oid;
+				objects.Add(obj);
+			}
+
+			this.SetLockState(objects.ToArray());
+			this.Update(sql, objects.ToArray());
 		}
 
 		public virtual void Lock(SqlHelper sql, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 
-			using(var trans = sql.BeginTrans()) {
-				this.SetLockState(objects);
-				this.Save(sql, objects);
-				trans.Commit();
-			}
+			this.SetLockState(objects);
+			this.Update(sql, objects);
 		}
 
 		public virtual bool IsLocked(DyObj obj) {
 			return !this.HasState(obj, this.CanWriteState);
 		}
 
+		public virtual void Unlock(SqlHelper sql, params string[] oids) {
+			sql = sql ?? this.SqlHelper;
+
+			var objects = new List<DyObj>();
+			foreach(var oid in oids) {
+				var obj = new DyObj();
+				obj["oid"] = oid;
+				objects.Add(obj);
+			}
+
+			this.SetUnlockState(objects.ToArray());
+			this.Update(sql, objects.ToArray());
+		}
+
 		public virtual void Unlock(SqlHelper sql, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 
-			using(var trans = sql.BeginTrans()) {
-				this.SetUnlockState(objects);
-				this.Save(sql, objects);
-				trans.Commit();
+			this.SetUnlockState(objects);
+			this.Update(sql, objects);
+		}
+
+		public virtual void Obsolete(SqlHelper sql, params string[] oids) {
+			sql = sql ?? this.SqlHelper;
+
+			var objects = new List<DyObj>();
+			foreach(var oid in oids) {
+				var obj = new DyObj();
+				obj["oid"] = oid;
+				objects.Add(obj);
 			}
+
+			this.SetObsoleteState(objects.ToArray());
+			this.Update(sql, objects.ToArray());
 		}
 
 		public virtual void Obsolete(SqlHelper sql, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 
-			using(var trans = sql.BeginTrans()) {
-				this.SetObsoleteState(objects);
-				foreach(var obj in objects) {
-					this.SaveStateOnly(this.InputPlan, obj, sql);
-				}
-				trans.Commit();
-			}
-		}
-
-		protected virtual void SaveStateOnly(InputPlan inputPlan, DyObj obj, SqlHelper sql) {
-			dynamic item = new DyObj();
-			item.oid = obj["oid"];
-			item.state = obj["state"];
-			inputPlan.Update(item, sql);
+			this.SetObsoleteState(objects);
+			this.Update(sql, objects);
 		}
 
 		public void SetLockState(params DyObj[] objects) {
-			this.ClearState(this.CanWriteState, objects);
+			this.SetState(this.CanWriteState, objects);
 		}
 
 		public void SetUnlockState(params DyObj[] objects) {
 			this.SetState(this.CanWriteState, objects);
 		}
 
-		public virtual void Delete(SqlHelper sql = null, params DyObj[] objects) {
+		public void Delete(SqlHelper sql = null, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 
 			using(var trans = sql.BeginTrans()) {
 			}
 		}
 
-		public virtual void Delete(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
+		public void Delete(string cacheOID, SqlHelper sql = null, params DyObj[] objects) {
 			sql = sql ?? this.SqlHelper;
 
 			if(string.IsNullOrEmpty(cacheOID)) {
 			}
 		}
 
-		public virtual void ClearState<T>(SqlHelper sql, T state, params DyObj[] objects) {
+		public virtual void ClearState<T>(SqlHelper sql, T state, params string[] oids) {
 			sql = sql ?? this.SqlHelper;
-			ClearState(state, objects);
-			foreach(var obj in objects) {
-				this.SaveStateOnly(this.InputPlan, obj, sql);
+
+			var objects = new List<DyObj>();
+			foreach(var oid in oids) {
+				var obj = new DyObj();
+				obj["oid"] = oid;
+				objects.Add(obj);
 			}
-		}
 
-		public virtual void ClearState<T>(string cacheOID, SqlHelper sql, T state, params DyObj[] objects) {
-			sql = sql ?? this.SqlHelper;
-			if(string.IsNullOrEmpty(cacheOID)) {
-				this.ClearState(sql, state, objects);
-			}
-			else {
-				ClearState(state, objects);
-				var inputPlan = InputPlan.CreateInstance(this.RelationCacheName, sql);
-				foreach(var obj in objects) {
-					this.SaveStateOnly(inputPlan, obj, sql);
-				}
-			}
+			this.ClearState(state, objects.ToArray());
+			this.Update(sql, objects.ToArray());
 		}
 
 		public void SetState<T>(T state, params DyObj[] objects) {
 			}
 		}
 
-		public virtual void SetState<T>(SqlHelper sql, T state, params DyObj[] objects) {
+		public virtual void SetState<T>(SqlHelper sql, T state, params string[] oids) {
 			sql = sql ?? this.SqlHelper;
-			SetState(state, objects);
-			foreach(var obj in objects) {
-				this.SaveStateOnly(this.InputPlan, obj, sql);
+
+			var objects = new List<DyObj>();
+			foreach(var oid in oids) {
+				var obj = new DyObj();
+				obj["oid"] = oid;
+				objects.Add(obj);
 			}
-		}
 
-		public virtual void SetState<T>(string cacheOID, SqlHelper sql, T state, params DyObj[] objects) {
-			sql = sql ?? this.SqlHelper;
-			if(string.IsNullOrEmpty(cacheOID)) {
-				this.SetState(sql, state, objects);
-			}
-			else {
-				var inputPlan = InputPlan.CreateInstance(this.RelationCacheName, sql);
-				SetState(state, objects);
-				foreach(var obj in objects) {
-					this.SaveStateOnly(this.InputPlan, obj, sql);
-				}
-			}
+			this.SetState(state, objects.ToArray());
+			this.Update(sql, objects.ToArray());
 		}
 	}
 

File Inside.Util/Sql/SQLHelper.cs

View file
  • Ignore whitespace
 	/// </summary>
 	public class SqlHelper : IDisposable {
 		#region 静态成员
-		public static int? CommandTimeout { get; set; }
+		public static int DefaultCommandTimeout = 15;
+		public static System.Data.IsolationLevel DefaultIsolationLevel = System.Data.IsolationLevel.Serializable;
 
 		static ConnectionStringSettings _defaultConnSettings;
 		/// <summary>
 		/// <remark>
 		/// 调用者必须负责释放此事务帮助对象。
 		/// </remark>
-		public TransactionHelper BeginTrans(System.Data.IsolationLevel isolation = System.Data.IsolationLevel.ReadCommitted) {
+		public TransactionHelper BeginTrans(System.Data.IsolationLevel? isolation = null) {
 			TransactionHelper th = null;
 
+			var isolationLvl = null == isolation ? DefaultIsolationLevel : (System.Data.IsolationLevel)isolation;
+
 			if(null == Transaction.Current) {
 				if(this.UseDistributedTransaction) {
-					th = new TransactionHelper(new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = DbTransactionIsolationToScopeTransactionIsolation(isolation) }));
+					th = new TransactionHelper(new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = DbTransactionIsolationToScopeTransactionIsolation(isolationLvl) }));
 					th.Disposing += (s, e) => {
 						this.IsInTransaction = false;
 					};
 					switch(this.Conn.State) {
 						case ConnectionState.Open:
 							if(!this.IsInTransaction) {
-								trans = this.Conn.BeginTransaction(isolation);
+								trans = this.Conn.BeginTransaction(isolationLvl);
 							}
 							break;
 						case ConnectionState.Broken:
 						case ConnectionState.Closed:
 						default:
 							this.Conn.Open();
-							trans = this.Conn.BeginTransaction(isolation);
+							trans = this.Conn.BeginTransaction(isolationLvl);
 							break;
 					}
 
 				}
 			}
 			else {
-				th = new TransactionHelper(new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = DbTransactionIsolationToScopeTransactionIsolation(isolation) }));
+				th = new TransactionHelper(new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = DbTransactionIsolationToScopeTransactionIsolation(isolationLvl) }));
 			}
 
 			this.IsInTransaction = true;
 			return this.Init(commText, CommandType.Text, commTimeout);
 		}
 
-		public DbCommand Init(string commText, CommandType commType = CommandType.Text, int commTimeout = 15) {
+		public DbCommand Init(string commText, CommandType commType = CommandType.Text, int? commTimeout = null) {
 			var comm = this.Conn.CreateCommand();
 			comm.CommandText = commText;
 			comm.CommandType = commType;
-			comm.CommandTimeout = null == CommandTimeout ? commTimeout : (int)CommandTimeout;
+			comm.CommandTimeout = null == commTimeout ? DefaultCommandTimeout : (int)commTimeout;
 			return comm;
 		}
 

File Inside.Util/Web/HtmlHelperExtension.cs

View file
  • Ignore whitespace
 
 namespace Inside.Util.Web {
 	public static class HtmlHelperExtension {
-		public static MvcHtmlString TextInput_Limit(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int limit = 120) {
-			var regExp = string.Format(@"^.{{0,{0}}}$", limit);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能超过{0}字".Fmt(limit), regExp);
-		}
-
-		public static MvcHtmlString TextInput_Limit_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int limit = 120) {
-			var regExp = string.Format(@"^.{{1,{0}}}$", limit);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、不能超过{0}字".Fmt(limit), regExp);
-		}
-
-		public static MvcHtmlString TextInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^.+$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空", constraint);
-		}
-
-		public static MvcHtmlString DecimalInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^(-?\d+\.\d+)?$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "必须是带小数部分的数字", constraint);
-		}
-
-		public static MvcHtmlString DecimalInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d+\.\d+$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、必须是带小数部分的数字", constraint);
-		}
-
-		public static MvcHtmlString IntegerInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d*$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "只能包含整数", constraint);
-		}
-
-		public static MvcHtmlString IntegerInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d+$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、只能包含整数", constraint);
-		}
-
-		public static MvcHtmlString NumberInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d*(\.\d+)?$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "必须是有效的数字", constraint);
-		}
-
-		public static MvcHtmlString NumberInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d+(\.\d+)?$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、必须是有效的数字", constraint);
-		}
-
-		public static MvcHtmlString NumberInput_Fraction(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int fraction = 6) {
-			var regExp = string.Format(@"^-?\d*(\.\d{{1,{0}}})?$", fraction);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能超过{0}位小数".Fmt(fraction), regExp);
-		}
-
-		public static MvcHtmlString NumberInput_Fraction_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int fraction = 6) {
-			var regExp = string.Format(@"^-?\d+(\.\d{{1,{0}}})?$", fraction);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、不能超过{0}位小数".Fmt(fraction), regExp);
-		}
-
-		[Obsolete("应使用含义更为明确的NumberInput_Fraction")]
-		public static MvcHtmlString NumberInput_Precise(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int precise = 6) {
-			var regExp = string.Format(@"^-?\d*(\.\d{{1,{0}}})?$", precise);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能超过{0}位小数".Fmt(precise), regExp);
-		}
-
-		[Obsolete("应使用含义更为明确的NumberInput_Fraction_Require")]
-		public static MvcHtmlString NumberInput_Precise_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int precise = 6) {
-			var regExp = string.Format(@"^-?\d+(\.\d{{1,{0}}})?$", precise);
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、不能超过{0}位小数".Fmt(precise), regExp);
-		}
-
-		public static MvcHtmlString CurrencyInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d*(\.\d{1,2})?$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "必须是有效的金额", constraint);
-		}
-
-		public static MvcHtmlString CurrencyInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^-?\d+(\.\d{1,2})?$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、必须是有效的金额", constraint);
-		}
-
-		public static MvcHtmlString IdentificationInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^$|^\d{15}$|^\d{17}[0-9A-Z]$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "只能填写数字及大写字母", constraint);
-		}
-
-		public static MvcHtmlString IdentificationInput_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = @"^\d{15}$|^\d{17}[0-9A-Z]$") {
-			return TextInput(helper, name, value, htmlAttrs, errorMsg ?? "不能为空、只能填写数字及大写字母", constraint);
-		}
-
-		public static MvcHtmlString TextInput(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, string constraint = null) {
-			if(null == htmlAttrs) {
-				return new MvcHtmlString("<input type='text' name='{0}' value='{1}' errormsg='{2}' constraint='{3}'/>".Fmt(name, value, errorMsg, constraint));
-			}
-			else {
-				var dict = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttrs);
-				var sb = new StringBuilder();
-				foreach(var item in dict) {
-					sb.AppendFormat("{0}='{1}' ", item.Key, item.Value);
-				}
-				return new MvcHtmlString("<input type='text' name='{0}' value='{1}' errormsg='{2}' constraint='{3}' {4}/>".Fmt(name, value, errorMsg, constraint, sb.ToString()));
-			}
-		}
-
-		public static MvcHtmlString PasswordInput(this HtmlHelper helper, string name, object htmlAttrs = null, string errorMsg = null, string constraint = @"^.+$") {
-			errorMsg = errorMsg ?? "密码不能为空";
-
-			if(null == htmlAttrs) {
-				return new MvcHtmlString("<input type='password' name='{0}' errormsg='{1}' constraint='{2}'/>".Fmt(name, errorMsg, constraint));
-			}
-			else {
-				var dict = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttrs);
-				var sb = new StringBuilder();
-				foreach(var item in dict) {
-					sb.AppendFormat("{0}='{1}' ", item.Key, item.Value);
-				}
-				return new MvcHtmlString("<input type='password' name='{0}' errormsg='{1}' constraint='{2}' {3}/>".Fmt(name, errorMsg, constraint, sb.ToString()));
-			}
-		}
-
-		public static MvcHtmlString TextAreaInput_Limit(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int limit = 500) {
-			var regExp = string.Format(@"^[\s\S]{{0,{0}}}$", limit);
-			return TextAreaInput(helper, name, ObjectHelper.IsNil(value) ? string.Empty : value.ToString(), htmlAttrs, errorMsg ?? "不能超过{0}字".Fmt(limit), regExp);
-		}
-
-		public static MvcHtmlString TextAreaInput_Limit_Require(this HtmlHelper helper, string name, object value, object htmlAttrs = null, string errorMsg = null, int limit = 500) {
-			var regExp = string.Format(@"^[\s\S]{{1,{0}}}$", limit);
-			return TextAreaInput(helper, name, ObjectHelper.IsNil(value) ? string.Empty : value.ToString(), htmlAttrs, errorMsg ?? "不能为空、不能超过{0}字".Fmt(limit), regExp);
-		}
-
-		public static MvcHtmlString TextAreaInput(this HtmlHelper helper, string name, string value, object htmlAttrs = null, string errorMsg = null, string constraint = null) {
-			if(null == htmlAttrs) {
-				return new MvcHtmlString("<textarea name='{0}' errormsg='{1}' constraint='{2}'>{3}</textarea>".Fmt(name, errorMsg, constraint, value));
-			}
-			else {
-				var dict = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttrs);
-				var sb = new StringBuilder();
-				foreach(var item in dict) {
-					sb.AppendFormat("{0}='{1}' ", item.Key, item.Value);
-				}
-				return new MvcHtmlString("<textarea name='{0}' errormsg='{1}' constraint='{2}' {3}>{4}</textarea>".Fmt(name, errorMsg, constraint, sb.ToString(), value));
-			}
-		}
-
 		public static IHtmlString EncodeEx(this HtmlHelper helper, string str) {
 			return string.IsNullOrEmpty(str) ? null : helper.Raw(helper.Encode(str).Replace(" ", "&nbsp;").Replace("\n", "<br />"));
 		}