public static EntityPro getInstance(DataTable dt, string projName, string entityName) { // if (_instance == null) { _instance = new EntityPro(dt, projName, entityName); } return(_instance); }
public static string CreateMVCModel(DataTable dt, string projName, string entityName) { // return EntityPro.getInstance(dt, projName, entityName).CreatePropertyEntity(); return(EntityPro.getInstance(dt, projName, entityName).CreateMVCModel()); }
/*静态方法 VS 非静态方法 * 1. 静态方法属于类, 非静态方法属于实例 * 2. 静态方法一开始就分配到内存(), 非静态方法需要在创建实例的时候才分配内存; * 3. 静态方法效率高,但不能自动销毁 * 4. 静态方法和静态变量始终使用同一块内存,而实例会创建多个内存; * 5.获取类的名称: * 静态: string className = System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName; * 非静态: string className = this.GetTyoe().FullName; * 6. 静态速度快, 占内存 * * 总结: 实例化方法更多的被使用和稳妥, 静态方法少使用。 * 如果从线程安全、 性能、兼容性上来看, 也是选实例化方法为宜; * **************************************************************************************/ public static string GenerateEntity(DataTable dt, string projName, string entityName) { // return EntityPro.getInstance(dt, projName, entityName).CreatePropertyEntity(); return(EntityPro.getInstance(dt, projName, entityName).CreatePublicEntity()); }