This code is a helper class in the written jframework ,:-)
Very simple. Please enjoy it.
Source code:
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 _" + name [I] + "= value; \ r \ n ");
Block. append (prespace + "\ t} \ r \ n ");
Block. append (prespace + "} \ r \ n ");
Block. append (prespace + "\ r \ n ");
;
}
Return block. tostring ();
}
}
}
Reference Method:
/// <Summary>
/// Convert to a string array arrayhelper. Tostringarray
/// </Summary>
/// <Param name = "Coll"> </param>
/// <Returns> </returns>
Public static string [] ToStringArray (ICollection coll)
{
String [] result = new string [coll. Count];
Int I = 0;
Foreach (object obj in coll)
{
Result [I ++] = obj. ToString ();
}
Return result;
}
Test and reference example:
Using System;
Using System. Collections;
Using JFrameWork. CodeBuilder;
Using JFrameWork. PubUtility. File;
Namespace JFrameWork. CodeBuilder. Test
{
Class MainClass
{
Public static void Main (string [] args)
{
// String prespace = "\ t ";
// String [] name = {"ID", "Name", "Value "};
// String [] type = {"string", "string", "string "};
ArrayList alname = new ArrayList ();
ArrayList altype = new ArrayList ();
Console. WriteLine ("Set Prespace :");
String prespace = Console. ReadLine ();
String quit;
Do
{
Console. WriteLine ("Set Name :");
Alname. Add (Console. ReadLine ());
Console. WriteLine ("Set Prespace :");
Altype. Add (Console. ReadLine ());
Console. WriteLine ("Go on? ");
Quit = Console. ReadLine ();
} While (quit! = "N" & quit! = "N ");
String block = Property. GetPropertyBlock (prespace, alname, altype );
Console. WriteLine (block );
FileManager. ToFile (System. Environment. CurrentDirectory + "/Temp.txt", block );
// Console. ReadLine ();
}
}
}
The JFrameWork will be gradually available in the future.
JFrameWork in progress ........