Permalink
Browse files

Update command 'generate form' to recieve variables pairs of type, na…

…me to tell FormCoder which control the form must have. Updates args[] in main() to test the integration of this feature.
  • Loading branch information...
1 parent 21e6947 commit 96bf467809fe07ad41f16cdcb2a08f6c9460a270 @mbmihura committed May 11, 2012
View
Binary file not shown.
View
@@ -3,6 +3,8 @@
using System.Linq;
using System.Text;
using netRake;
+using netRake.Controls;
+using System.Reflection;
namespace netRake
{
@@ -27,24 +29,34 @@ public void Execute(string[] args)
switch (args[0])
{
case "form":
- List<Control> controls = new List<Control> ();
+ Dictionary<string, Type> types = new Dictionary<string, Type>();
+ List<Control> controls = new List<Control>();
string currentDirectoyName = Environment.CurrentDirectory;
+
+ types.Add("string", typeof(TxtBox));
+ types.Add("int", typeof(NumUD));
+ types.Add("datetime", typeof(DtPicker));
+ types.Add("bool", typeof(ChkBox));
+ types.Add("double", typeof(NumUD));
+ types.Add("decimal", typeof(NumUD));
+
int cropIndex = currentDirectoyName.LastIndexOf('\\') +1;
currentDirectoyName = currentDirectoyName.Substring(cropIndex,currentDirectoyName.Length - cropIndex);
- new FormCoder(currentDirectoyName, args[1], controls).Create(Environment.CurrentDirectory);
+ for (int i = 2; i < args.Length; i += 2)
+ {
+ //Extracts Type from the first argument,
+ Type commandType = types[args[i]];
- Dictionary<string, Type> types = new Dictionary<string, Type>();
- types.Add("string", typeof(string));
- types.Add("int", typeof(int));
- types.Add("dateTime", typeof(DateTime));
- types.Add("bool", typeof(bool));
- types.Add("double", typeof(double));
- types.Add("decimal", typeof(decimal));
- types.Add("", typeof(string));
- types.Add("", typeof(int));
- types.Add("", typeof(DateTime));
+ //Creates an objects from that type
+ ConstructorInfo controlConstructorInfo = commandType.GetConstructor(new Type[] {typeof(string) });
+ object controlObj = controlConstructorInfo.Invoke(new object[] {args[i+1]});
+ dynamic control = Convert.ChangeType(controlObj, commandType);
+
+ controls.Add(control);
+ }
+ new FormCoder(currentDirectoyName, args[1], controls).Create(Environment.CurrentDirectory+"\\");
break;
default:
View
@@ -26,7 +26,7 @@ static void Main(string[] args)
}
//HACK: handy, automatic way to introduce a command during development. Eliminate in production.
- args = new string[] { "generate", "form", "myForm" };
+ args = new string[] { "generate", "form", "myForm", "string","Nombre","bool","Socio","datetime","Fecha_de_Registro"};
//Extracts Type from the first argument,
Type commandType = _comands[args[0]];
Binary file not shown.
Binary file not shown.
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
- <security>
- <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
- <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
-</assembly>
Binary file not shown.
Binary file not shown.

0 comments on commit 96bf467

Please sign in to comment.