This open-source project uses Text Templating to generate a few of the design patterns. As for the first release it covers only the Singleton and the Provider Model design patterns and for Visual Studio.NET 2008. There are plans to extend it to cover more software design pattern as well as support for Visual Studio.NET 2005. Please note that this is limited to C# and VB.NET only.
To get to the Codeplex project visit: http://www.codeplex.com/4amigoscodegen
How to run the project in Visual Studio 2008
1. Download project code from Codeplex using the above URL.
2. You also need to download the Guidance Automation Extensions. You can get February 2008 release from here. Please make sure you’re always working with the last version.
3. Once you downloaded the project, open the project solution file to Visual Studio 2008.
4. Right-click on the “CodeGenConsole” project and go to its Properties.
5. Select the “Debug” tab from the right-hand navigational menu.
6. For the command line arguments enter the required parameters. For example:
- Namespace=Blog.Joubin.Ca.Providers Classname=MyProvider DesignPattern=ProviderModel OutputDir=C:\Temp\providers Language=CS
7. Save Project.
8. Press F5 (or Ctrl+F5) to run.
Provider Model configuration file
The configuration section elements generated must be copied to your application configuration file.
Abstract methods and their implementations
Let’s say you passed in Classname=Sample.
To get started there are two files that you will need to change. They are SampleDataProvider and FirstDataProvider. You will have declare abstract methods in SampleDataProvider and provide concrete implementations in the FirstDataProvider class.
How to extend your data providers
Note that the sample implementation of the abstract class SampleDataProvider is named FirstDataProvider by design. You can both remove the FirstDataProvider or write another concrete data provider class inheriting from SampleDataProvider. In both cases you need to modify the configuration section to reflect the new/removed data provider classes.
Arguments
- Namespace: This is the namespace given to the generated classes.
- Classname: This is the class name used. In the case of the Singleton design pattern, this class name is used as is, but for the provider model, it is used as a boilerplate class name. For example, if Classname is supplied as “Sample”, then the abstract provider class is going to be name as “SampleProvider.”
- DesignPattern: Supported design patterns (at this time) are: ProviderModel and Singleton
- OutputDir: The folder where the generated files will be stored.
- Language: Supported languages are: CS and VB
How to use the generated files
A sample project is provided to demonstrate the usage of the generated files for the provider model example.
You can download this sample project here. Please note that this project is in C#.
Downloads
- Guidance Automation Extension
- Open-source Codeplex project
- Sample project using generated classes (C#)
References
For explanation of the Provider Model design pattern please visit here.
0 comments:
Post a Comment