CodeDom, which stands for Code Doc Item Product, is one particular advance method offered by Microsoft.Web Framework to generate code at run-time. At application stage, it presents programmers the capability to publish a single language-unbiased code that can emit supply code in a specific language for afterwards specifications.
Code Doc Item Design lies in the Method.CodeDom namespaces of the.Net Framework. The CodeDom has the pursuing advantages:
From a solitary code that utilizes the CodeDom to signify the framework of supply code that can make source code of any language supports the CodeDom specification.
The CodeDom makes it possible for source code and assemblies to be designed, compiled, and executed dynamically at runtime.
It gives a language independent item product for representing the construction of source code in memory.
It functions as a source code translator amid different languages.
Frequent usages of the CodeDOM consist of:
Creating template code for emitting code wizards, coding illustrations, XML World wide web solutions client proxies, and so on.
Dynamically compiling code in languages supported.
T4 (Textual content Template Transformation Toolkit) is another effective era tool supplied by Microsoft.web Framework. Not like the CodeDom, T4 employs string concatenation to generate textual template to generate code. dynamic qr code A lot of the output code will be put into template blocks, in get to make the code generator easy to generate and customise. Even so, T4 is a language dependent and will need a individual code generator for each and every output language. On the other hand, the CodeDom enables builders use a single source code to make the exact same thing in diverse languages, which certainly give a huge benefit in establishing.Web Framework resources.
Most programing constructs, which includes declarations, statements, arrays, casts, iterations, error handling and other individuals, is supported by the CodeDom. For programing constructs that are not presently supported in CodeDom, “snippet” lessons such as the CodeSnippetCompileUnit, CodeSnippetExpression, CodeSnippetStatement, and CodeSnippetTypeMember can be utilised as generic illustration. For generating code in a particular language, a corresponding CodeDomProvider class will be necessary.
At present there are Microsoft.CSharp.CSharpCodeProvider and Microsoft.VisualBasic.VBCodeProvider that can be utilised to make C Sharp code and VisuaBasic.web code. Other programming languages never have CodeDomProvider however, and may possibly not have simple techniques to symbolize some CodeDom constructions (delegates, enums, templates, and framework) thanks to variation in language specifications. However, making a CodeDomProvider is not a extremely complicated activity, if the enter CodeDom framework is limited. Programmers can usually create a CodeDomProvider for a distinct language by inheriting from CodeDomProvider, and toss exceptions if the construction is way too challenging to represent.