I am working on a WinForms project with some repetitive tasks everyday. So I thought creating code a snippet will help me out, but it works for fixed code only.
I want to dynamically create a code snippet, according to control names and some condition.
I want to add the code once the design part is done. I define the control names like intTextboxAge
. The snippet should add auto validation for all textboxes, using the fuction defined below.
There have to be different controls based on the control's name prefix (int, str, dou, dec). Like such:
public void AutoCode()
{
int i=0;
foreach(On all controls)
{
if(controls is textbox or combobox)
{
if(control.text starts with int)
{
a[i] = Validation.ValidateInt(labelError, control.text, val => acdnt.date = val);
}
}
}
}
I want an auto generated code snippet, libraries will not be able to help me.
My motive is not to generate code for validation only by above example is just how we can do this.
I want to auto generate my all business logic code for master win forms like
- Validation
- Creating new Class for variables
- Datafilling in class after validation
- Auto creation of database function insert and update
Because in all above task only variable name changes rest business task remains same. How we can implement
Auto Creation of class- Class will created with by form name+"Class" and variable types will identified by first 3 char and will named same as control name.
Auto creation of database function insert and update - Will name database table name same as form name and column name same as control name, so that it can dynamically create insert and update query also.
Why i don't want to with class library because in that case it perform all operation at run time which will somewhere eat my performance.
With this we can save lots of time and efforts of coding world.