反射操作輔助類ReflectionUtil

2021-05-23 07:35:38 字數 1305 閱讀 2957

///

/// 反射操作輔助類

///

public sealed class reflectionutil

private static bindingflags bindingflags = bindingflags.declaredonly | bindingflags.public |

bindingflags.nonpublic | bindingflags.instance | bindingflags.static;

/**

/// 執行某個方法

///

/// 指定的物件

/// 物件方法名稱

/// 引數

///

public static object invokemethod(object obj, string methodname, object args)

/**

/// 設定物件欄位的值

///

public static void setfield(object obj, string name, object value)

/**

/// 獲取物件欄位的值

///

public static object getfield(object obj, string name)

/**

/// 設定物件屬性的值

///

public static void setproperty(object obj, string name, object value)

/**

/// 獲取物件屬性的值

///

public static object getproperty(object obj, string name)

/**

/// 獲取物件屬性資訊(組裝成字串輸出)

///

public static string getproperties(object obj)

}反射操作輔助類reflectionutil測試**:

public class testreflectionutil

catch (exception ex)

!/r/n /r/n", ex.message);

}return result;

}public static string decriptperson(person person)

) + "/r/n";

result += "操作完成!/r/n /r/n";

return result;}}

基於XML操作輔助類

在實際的專案應用中,很多地方需要用的xml,程式的配置,一些客戶配置的資料,但是主要用在配置檔案,web services,跨系統的資訊傳遞。分析用過jaxb,不過,schema改變之後,還有就是電子商務中的xml,比如ebxml,ariba的cxml,commerceone自己有一套,sap也支援...

JavaSE反射操作類

1 獲取乙個class物件 class classas class.forname 需要載入獲取的類的路徑 例如 class classas class.forname club.kang.blog.web.test.testclassmy.student 2 將這個類物件建立出來 object o...

字串操作輔助類

字串操作輔助類 public class stringutil 移除空格並首字母小寫的camel樣式 public static string tocamel string name char.tolower clone 0 clone.substring 1,clone.length 1 移除空格...