.NET实体类生成器 改
来源:互联网 发布:深圳gis数据下载 编辑:程序博客网 时间:2024/05/20 00:13
将前面的Form1.cs代码改成:
修改了前面的第44行(nameSpace-->namespace)和第53行
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Text.RegularExpressions ;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string ClassName1 = textBox1.Text.Trim(); string classexp1 = txtexp.Text.Trim(); string NameSpace1 = txtNameSapace.Text.Trim(); if (ClassName1.Length == 0) { MessageBox.Show("类名不能为空"); return; } sfdFile.FileName = ClassName1; if (sfdFile.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(sfdFile.FileName, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs, Encoding.Default); if (radyou.Checked && txtNameSapace.Text.Trim() != null) { sw.WriteLine("namespace " + NameSpace1); sw.WriteLine("{"); } sw.WriteLine(" public class " + ClassName1); sw.WriteLine(" {"); foreach (DataGridViewRow Row in fdcontent.Rows) { if (Row.Cells[0].Value != null ) { string propname = Row.Cells[0].Value.ToString(); string type = Row.Cells[1].Value.ToString(); //替换propname前一个或多个下划线,中间下划线不替换 sw.WriteLine(" private " + type + " " + propname + ";"); string propname1 = Regex.Replace(propname, "^_+", ""); //把propname首字母变为大写 string functionname = propname1.Substring(0, 1).ToUpper() + propname1.Substring(1); sw.WriteLine(" public " + type + " " + functionname); sw.WriteLine(" {"); sw.WriteLine(" get { return " + propname + "; }"); sw.WriteLine(" set { " + propname + " = value; }"); sw.WriteLine(" }"); } } sw.WriteLine("}"); if (radyou.Checked && txtNameSapace.Text.Trim() != null) { sw.WriteLine("}"); } sw.Close(); fs.Close(); MessageBox.Show("实体类创建成功!"); } } private void radwu_CheckedChanged(object sender, EventArgs e) { txtNameSapace.Visible = false; } private void radyou_CheckedChanged(object sender, EventArgs e) { txtNameSapace.Visible = true; } } }
- .NET实体类生成器 改
- .NET实体类生成器
- C#实体类生成器
- 自制C#实体类生成器
- 【动软.Net代码生成器】连接MySQL生成C#的POCO实体类(Model)
- asp.net 实体类
- C# .NET 实体类
- ASP.NET:自定义实体类
- EF实体类的增删改查操作
- MyBatis返回类型改如何选择?实体类 or Map。
- Hibernate实体类操作(二)简单增删改操作
- ASP.NET中实体数据库模型的增删改查的用法。
- Android开发中使用fastJSON将json格式的数据快速解析生成实体类并附上实体类生成器
- 利用动软代码生成器 自动生成LINQ需要用的数据实体类
- 牛腩新闻系统(四)——类生成器生成实体代码
- 利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件
- c# .net实体类序列化
- c#.net实体类序列化方法
- C语言和设计模式(迭代器模式)
- 第 2 章 链路层
- 01_brute_force
- 根分区与交换分区
- linux下解压(压缩)命令全解
- .NET实体类生成器 改
- JMS ActiveMQ研究文档
- 自定义上传文件的样式
- c/c++之enum类型详解
- Effective C++学习有感--第六章 继承与面向对象设计(一)
- 企业家要与内心魔鬼抗衡
- 回首跌撞中前行,痛并快乐的2011
- 黑马程序员_12月21日
- JS倒计时