【IT168技术文档】
using System; using System.Collections; using JFrameWork.Common; namespace JFrameWork.CodeBuilder { /// <summary> /// Description of Propety. /// </summary> public class Property { public Property() { } public static string GetPropertyBlock(string prespace, ArrayList name, ArrayList type) { return GetPropertyBlock(prespace,ArrayHelper.ToStringArray(name),ArrayHelper.ToStringArray(type)); } public static string GetPropertyBlock(string prespace, string[] name, string[] type) { System.Text.StringBuilder block = new System.Text.StringBuilder(); for(int i = 0; i < name.Length; i++) { // Gen: // private <TYPE> <_Property>; // public <TYPE> <Property> // { // get // { // return (<_Property>); // } // set // { // <_Property> = value; // } // } block.Append(prespace + " private " + type[i] + " _" + name[i] + ";\r\n"); block.Append(prespace + " \r\n"); block.Append(prespace + " public " + type[i] + " " + name[i] + "\r\n"); block.Append(prespace + " {\r\n"); block.Append(prespace + " \tget\r\n"); block.Append(prespace + " \t{\r\n"); block.Append(prespace + " \t\treturn _" + name[i] + ";\r\n"); block.Append(prespace + " \t}\r\n"); block.Append(prespace + " \tset\r\n"); block.Append(prespace + " \t{\r\n"); block.Append(prespace + " \t\t_" + name[i] + " = value;\r\n"); block.Append(prespace + " \t}\r\n"); block.Append(prespace + " }\r\n"); block.Append(prespace + " \r\n"); ; } return block.ToString(); } } }