CodeDom – An Progress Strategy For Code Generation at…
CodeDom, which stands for Code Doc Object Product, is a single progress technique offered by Microsoft.Web Framework to make code at operate-time. At application level, it presents programmers the capability to write a single language-independent code that can emit source code in a specific language for later needs.
Code Doc Object Design lies inside of the Program.CodeDom namespaces of the.Net Framework. The CodeDom has the subsequent advantages:
From a one code that makes use of the CodeDom to symbolize the structure of source code that can generate source code of any language supports the CodeDom specification.
The CodeDom allows source code and assemblies to be developed, compiled, and executed dynamically at runtime.
It offers a language unbiased object product for symbolizing the composition of supply code in memory.
It acts as a source code translator amid diverse languages.
Common usages of the CodeDOM consist of:
Creating template code for emitting code wizards, coding examples, XML World wide web companies client proxies, and so on.
Dynamically compiling code in languages supported.
T4 (Textual content Template Transformation Toolkit) is another powerful generation instrument offered by Microsoft.net Framework. Unlike the CodeDom, T4 utilizes string concatenation to create textual template to make code. A lot of the output code will be place into template blocks, in purchase to make the code generator easy to produce and customise. Even so, T4 is a language dependent and will need a separate code generator for each and every output language. On the other hand, the CodeDom allows builders use a solitary supply code to create the very same point in distinct languages, which obviously give a huge benefit in developing.Web Framework resources.
Most programing constructs, such as declarations, statements, arrays, casts, iterations, error managing and other folks, is supported by the CodeDom. For programing constructs that are not presently supported in CodeDom, “snippet” lessons like the CodeSnippetCompileUnit, CodeSnippetExpression, CodeSnippetStatement, and CodeSnippetTypeMember can be utilized as generic representation. qr code generator For making code in a distinct language, a corresponding CodeDomProvider course will be necessary.
Currently there are Microsoft.CSharp.CSharpCodeProvider and Microsoft.VisualBasic.VBCodeProvider that can be used to generate C Sharp code and VisuaBasic.internet code. Other programming languages never have CodeDomProvider yet, and may not have easy ways to represent some CodeDom constructions (delegates, enums, templates, and framework) because of to big difference in language specifications. Nevertheless, producing a CodeDomProvider is not a really sophisticated process, if the enter CodeDom structure is limited. Programmers can usually build a CodeDomProvider for a specific language by inheriting from CodeDomProvider, and toss exceptions if the construction is too difficult to depict.