public static class Extension {#region [encode/decode Unified conversion]///<summary>////</summ ary>//<param name= "str" ></param>///<param name= "Isescape" >true for encode; False to decode</param>//<returns></returns> public static string jscodingstring (this Stri ng str, bool Isescape = False) {if (Isescape) return Microsoft.JScript.GlobalObject.esca PE (STR); else return Microsoft.JScript.GlobalObject.unescape (str); }///<summary>//JS codec///</summary>//<param name= "Lsto" ></param& Gt <param name= "Isescape" ></param> public static void Jscodingentitylist<t> (this list<t> l STO, bool Isescape = False) {foreach (Object o in Lsto) {jscodingentity (O, I Sescape); }}//<summary>//JS codec///</summary>//<param name= "O" ></param>//<p Aram Name= "Isescape" ></param> public static void Jscodingentity<t> (this T o, bool Isescape = False) {Object ObjValue; system.reflection.propertyinfo[] Propertys = O.gettype (). GetProperties (); foreach (System.Reflection.PropertyInfo p in propertys) {if (P.propertytype = = typeof (System.st Ring) {ObjValue = P.getvalue (o, null); if (objvalue! = null) {if (objvalue.gettype () = = typeof (System.String)) {if (isescape) P.setvalue (O, Microsoft.JScript. Globalobject.escape (Objvalue.tostring ()), NULL); else P.setvalue (O, Microsoft.JScript.GlobalObject.unescaPE (objvalue.tostring ()), NULL); }}}}}//<summary>//JS codec///< /summary>//<param name= "O" ></param>///<param name= "Isescape" ></param> public static void Jscodingtable (this DataSet o, bool Isescape = False) {foreach (DataTable t in O.tab Les) {jscodingentity (T, Isescape); }}///<summary>//JS codec///</summary>//<param name= "O" ></ param>//<param name= "Isescape" ></param> public static void Jscodingtable (This DataTable o, BOOL Isescape = False) {for (int j = 0; J < O.columns.count; J + +) {if (O . COLUMNS[J]. DataType = = typeof (System.String)) {for (int i = 0; i < O.rows.count; i++) {if (isescape) o.rows[i][j] = Microsoft.JScript.GlobalObject.escape (O.rows[i][j]. ToString ()); else o.rows[i][j] = Microsoft.JScript.GlobalObject.unescape (O.rows[i][j]. ToString ()); }}}} #endregion #region refactoring: Use the original encoding/decoding in a separate functional way. ] public static string tojsencodestring (this string str) {return Microsoft.JScript.GlobalObject. Escape (str); } public static string tojsdecodestring (this string str) {return Microsoft.JScript.GlobalObject. Unescape (str); } public static void Tojsencodeentitylist<t> (this list<t> lsto) {foreach (Object o i N lsto) {tojsencodeentity (o); }} public static void Tojsdecodeentitylist<t> (this list<t> lsto) {foreach (O BJect o in Lsto) {tojsdecodeentity (o); }} public static void Tojsencodeentity<t> (this T o) {object objvalue; system.reflection.propertyinfo[] Propertys = O.gettype (). GetProperties (); foreach (System.Reflection.PropertyInfo p in propertys) {if (P.propertytype = = typeof (System.st Ring) {ObjValue = P.getvalue (o, null); if (objvalue! = null) {if (objvalue.gettype () = = typeof (System.String)) {P.setvalue (O, Microsoft.JScript.GlobalObject.escape (objvalue.tostring ()), NUL L); }}}}} public static void Tojsdecodeentity<t> (This T o ) {Object ObjValue; system.reflection.propertyinfo[] Propertys = O.gettype (). GeTproperties (); foreach (System.Reflection.PropertyInfo p in propertys) {if (P.propertytype = = typeof (System.st Ring) {ObjValue = P.getvalue (o, null); if (objvalue! = null) {if (objvalue.gettype () = = typeof (System.String)) {P.setvalue (O, Microsoft.JScript.GlobalObject.unescape (objvalue.tostring ()), n ULL); }}}}} public static void Tojsencodetable (this DataSet o) {foreach (DataTable T in O.tables) {tojsencodetable (t); }} public static void Tojsdecodetable (this DataSet o) {foreach (DataTable T in O.tables) {tojsdecodetable (t); }} public static void Tojsencodetable (this DataTable o) {for (int j = 0; J < O.columns.count; J + +) {if (O.columns[j]. DataType = = typeof (System.String)) {for (int i = 0; i < O.rows.count; i++) {O.rows[i][j] = Microsoft.JScript.GlobalObject.escape (O.rows[i][j]. ToString ()); }}}} public static void Tojsdecodetable (this DataTable o) {f or (int j = 0; J < O.columns.count; J + +) {if (O.columns[j]. DataType = = typeof (System.String)) {for (int i = 0; i < O.rows.count; i++) {O.rows[i][j] = Microsoft.JScript.GlobalObject.unescape (O.rows[i][j]. ToString ()); }}}} #endregion}