WinForm development framework-dynamic DLL reading mode

Source: Internet
Author: User

Several of my friends who used the previous development framework used it in the project also gave me valuable comments. Although there have been no updates recently, I have made some suggestions for my friends, I have carefully reviewed and made many comments.

I have integrated the system and modified the deficiencies. I wanted to handle the report, but I thought about several solutions and the results were gone. A friend once said that he liked my framework for reading DLL files. I used to think it was quite messy and the code was quite messy, sometimes I think it takes a long time to understand what the code means. At that time, I abandoned this framework because I thought the Size of the entire project would grow bigger and bigger, because every form is a class library, then compiled as a DLL file, the program reads and loads these DLL files, so the method of writing them directly in the bamboo program is described in detail here:

 

In this way, there is also a problem. The main program's EXE is getting bigger and bigger. I think this is the case in theory. So I have been busy recently and reorganized the original framework, there are several major changes:

1. Each form is a class library that implements corresponding interfaces.

2. When you Open a form, instead of directly opening the form, you load the DLL file and read the information in the DLL file.

3. The business implemented by each form is still completed in its own class file.

Implement the following services in the newly created Project:

[Csharp] using System;
Using System. Collections. Generic;
Using System. Text;

Using CP. Kernel. Base;

Namespace sysUserGroup
{
[Serializable]
Public class Plugins: IPugins
{
Private FrmUserGroup f;
Public void Activate ()
{
F. Activate ();
}
Public void Dispose ()
{
F. Close ();
GC. Collect ();
GC. SuppressFinalize (this );
}
Public void Hide ()
{
F. Close ();
}

Public string Name
{
Get {return "role Profile Settings ";}
}

Public string GUID
{
Get {return "F2080504B6DC4963BC0963FEFA0E1AAD ";}
}

Public string Version
{
Get {return "1.0.0.0 ";}
}

Public string Manufacturer
{
Get {return "manufacturer ";}
}

Public string Description
{
Get {return "used to set role information ";}
}

Public string TCode
{
Get {return "JSZL ";}
}

Public string FrmUrl
{
Get {return "sysUserGroup. dll ";}
}
}
}

Using System;
Using System. Collections. Generic;
Using System. Text;
 
Using CP. Kernel. Base;
 
Namespace sysUserGroup
{
[Serializable]
Public class Plugins: IPugins
{
Private FrmUserGroup f;
Public void Activate ()
{
F. Activate ();
}
Public void Dispose ()
{
F. Close ();
GC. Collect ();
GC. SuppressFinalize (this );
}
Public void Hide ()
{
F. Close ();
}
 
Public string Name
{
Get {return "role Profile Settings ";}
}
 
Public string GUID
{
Get {return "F2080504B6DC4963BC0963FEFA0E1AAD ";}
}
 
Public string Version
{
Get {return "1.0.0.0 ";}
}
 
Public string Manufacturer
{
Get {return "manufacturer ";}
}
 
Public string Description
{
Get {return "used to set role information ";}
}
 
Public string TCode
{
Get {return "JSZL ";}
}
 
Public string FrmUrl
{
Get {return "sysUserGroup. dll ";}
}
}
}

Enter the imported DLL file here:

[Csharp] public void LoadDLL (string DllName)
{
Try
{
If (DllName. Substring (DllName. Length-4). ToUpper () = ". DLL ")
{
DllName = DllName. Replace (". dll ","");
}

If (string. IsNullOrEmpty (DllName ))
Return;

If (! AllenSingleton. DicLoadDll. ContainsKey (DllName ))
{
IPugins objLoadDll;
If (allenSingleton. DicPugins. ContainsKey (DllName ))
{
ObjLoadDll = allenSingleton. DicPugins [DllName];
}
Else
{
ObjLoadDll = CPUtility. LoadDll (DllName );
}

If (objLoadDll! = Null)
ObjLoadDll. Show (dockPanel, DockState. Document );

AllenSingleton. DicLoadDll. Add (DllName, objLoadDll );
}
Else
{
AllenSingleton. DicLoadDll [DllName]. Activate ();
}
}
Catch (Exception ex)
{
ShowMsg (ex. Message );
}


}

Public void LoadDLL (string DllName)
{
Try
{
If (DllName. Substring (DllName. Length-4). ToUpper () = ". DLL ")
{
DllName = DllName. Replace (". dll ","");
}
 
If (string. IsNullOrEmpty (DllName ))
Return;
 
If (! AllenSingleton. DicLoadDll. ContainsKey (DllName ))
{
IPugins objLoadDll;
If (allenSingleton. DicPugins. ContainsKey (DllName ))
{
ObjLoadDll = allenSingleton. DicPugins [DllName];
}
Else
{
ObjLoadDll = CPUtility. LoadDll (DllName );
}
 
If (objLoadDll! = Null)
ObjLoadDll. Show (dockPanel, DockState. Document );
 
AllenSingleton. DicLoadDll. Add (DllName, objLoadDll );
}
Else
{
AllenSingleton. DicLoadDll [DllName]. Activate ();
}
}
Catch (Exception ex)
{
ShowMsg (ex. Message );
}
 
 
}

Compared with the previous one, this framework does not change data processing and still uses stored procedures to implement business logic. The SQL statements are basically invisible in the program. The layout and style also follow the previous practices, it is still the layout mode of Multi-document, and the overall effect is relatively generous. The main change is the core part. It can be said that the current set of programs is completely different from the previous set of core content, there are also some improvements in coupling. For example, all the loaded forms are DLL:

 

 

Rough:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.