自动生成类定义(随便写的)
用javascript写的,弱弱的说,爱用的拿去用,不爱用的接分吧哈哈,分也不多
<!----By kkun 2007-5-14----->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自动生成类定义</title>
<style type="text/css">
<!--
body,td,th {font-family: Courier New, Courier, monospace;font-size: 12px;}
.key {color: #0000FF}
.red {color: #FF0000}
-->
</style>
</head>
<body>
<p>
  <script language="javascript">
//自动生成类定义
function $()
{
var name=document.getElementById("name").value;
var str=document.getElementById("property").value;
if(str=="" || str.length==0)
{
alert("当!您没有输入任何东东!");
return false;
}
var s=str.split(",");

document.writeln("<pre>"); document.writeln("<font color=#0000FF>using <\/font>System;");
document.writeln("<font color=#0000FF>using <\/font>System.Collections;");
document.writeln("<font color=#0000FF>namespace <\/font>kkun.com.cn");
document.writeln("{");
document.writeln("\t<font color=#CCCCCC>\/\/\/ <<a>summary><\/font>");
document.writeln("\t<font color=#CCCCCC>\/\/\/ "+$ToProperty(name)+"<\/font>");
document.writeln("\t<font color=#CCCCCC>\/\/\/ <\/<a>summary><\/font>");
document.writeln("\t<font color=#0000FF>public class<\/font> "+$ToProperty(name));
document.writeln("\t{");
document.writeln("\t\t<font color=#0000FF>public <\/font>"+$ToProperty(name)+"(){}\n");

//输出字段
for(var i=0;i<s.length;i++)
{
$Field(s[i]);
}
document.writeln("\n");

//输出属性
for(var i=0;i<s.length;i++)
{
$Property(s[i]);
}
document.writeln("\t}\n\n");
$ToCollect(name);
document.writeln("}");

document.writeln("<\/pre>");
}//输出字段
function $Field(p)
{
document.writeln("\t\t<font color=#0000FF>private string <\/font>" + $ToField(p) + ";");
}//输出属性
function $Property(p)
{
document.writeln("\t\t<font color=#CCCCCC>\/\/\/<<summary>summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/" + $ToProperty(p) + "</font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/<<summary>\/summary><\/font>");
document.writeln("\t\t<font color=#0000FF>public string</font> " + $ToProperty(p) + "");
document.writeln("\t\t{");
document.writeln("\t\t<font color=#0000FF>\tget<\/font>{<font color=#0000FF>return this.<\/font>" + $ToField(p) + ";}");
document.writeln("\t\t<font color=#0000FF>\tset<\/font>{<font color=#0000FF>this.<\/font>" + $ToField(p)+ "=<font color=#0000FF>value<\/font>;}");
document.writeln("\t\t}\n");
}//格式化属性
function $ToProperty(p)
{
var f1=p.substring(0,1).toUpperCase();//取一址写
var f2=p.substr(1,p.length-1);//取址
return f1+f2;
}//格式化字段
function $ToField(p)
{
var f1=p.substring(0,1).toLowerCase();//取一址小写
var f2=p.substr(1,p.length-1);//取址
return f1+f2;
}function $ToCollect(p)
{
document.writeln("\t<font color=#CCCCCC>\/\/\/ <<a>summary><\/font>");
document.writeln("\t<font color=#CCCCCC>\/\/\/ "+p+"集合类<\/font>");
document.writeln("\t<font color=#CCCCCC>\/\/\/ <<summary>\/summary><\/font>");
document.writeln("\t<font color=#0000FF>public class<\/font> "+p+"Collect:CollectionBase");
document.writeln("\t{");
document.writeln("\t\tpublic "+p+"Collect(){}");
document.writeln("");
document.writeln("");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<a>summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ 添加 -> "+p+"类<\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>\/summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>param name=\"item\">"+p+"<<summary>\/param><\/font>");
document.writeln("\t\t<font color=#0000FF>public void<\/font> Add("+p+" item)");
document.writeln("\t\t{");
document.writeln("\t\t\tList.Add(item); ");
document.writeln("\t\t}");
document.writeln("");
document.writeln("");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<a>summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ 删除 -> "+p+"类<\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>\/summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>param name=\"item\">"+p+"<<summary>\/param><\/font>");
document.writeln("\t\t<font color=#0000FF>public void<\/font> Remove("+p+" item)");
document.writeln("\t\t{");
document.writeln("\t\t\tList.Remove(item);");
document.writeln("\t\t}");
document.writeln("");
document.writeln("");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>summary><\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ 访问 -> "+p+"类<\/font>");
document.writeln("\t\t<font color=#CCCCCC>\/\/\/ <<summary>\/summary><\/font>");
document.writeln("\t\t<font color=#0000FF>public<\/font> "+p+" this[int index]");
document.writeln("\t\t{");
document.writeln("\t\t\tget{return ("+p+")List[index];}");
document.writeln("\t\t\tset{base.List[index] = value;}");
document.writeln("\t\t}");
document.writeln("\t}");
}
</script> 
  <label> <span class="red">请在下边的文本框中输入类的名称 </span><br>
  <br>
  <input name="name" type="text" id="name" value="HotelInfo" size="60">
  </label>
</p>
<p><span class="red">请在此输入类字段,以&quot;,&quot; 号分隔</span></p>
<p>
  <textarea name="property" id="property" cols="80" rows="5">hotelId,hotelCnName,hotelEnName,hotelLinkMan,hotelTel,hotelFax</textarea>
</p>
<p>
  <input type="button" name="Submit" value=" 自动生成类定义 " onClick="javascript:$()" />
</p>
</body>
</html>