日期:2014-05-19  浏览次数:20849 次

自动生成类定义(随便写的,爱用的用,不爱用的当我散分)
自动生成类定义(随便写的)
用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