CodeDom, which stands for Code Document Item Product, is one advance approach supplied by Microsoft.Net Framework to generate code at run-time. At application stage, it provides programmers the capacity to create a one language-unbiased code that can emit source code in a specific language for afterwards needs.
Code Document Item Design lies in the System.CodeDom namespaces of the.Internet Framework. The CodeDom has the subsequent benefits:
From a one code that makes use of the CodeDom to symbolize the construction of supply code that can create resource code of any language supports the CodeDom specification.
The CodeDom makes it possible for source code and assemblies to be created, compiled, and executed dynamically at runtime.
It offers a language impartial object model for symbolizing the construction of source code in memory.
It acts as a resource code translator amongst different languages.
Widespread usages of the CodeDOM incorporate:
Creating template code for emitting code wizards, coding illustrations, XML World wide web companies customer proxies, and so on.
Dynamically compiling code in languages supported.
T4 (Text Template Transformation Toolkit) is yet another effective technology resource offered by Microsoft.internet Framework. Not like the CodeDom, T4 utilizes string concatenation to generate textual template to generate code. A lot of the output code will be place into template blocks, in order to make the code generator effortless to produce and personalize. Nonetheless, T4 is a language dependent and will need a different code generator for each output language. qr code generator On the other hand, the CodeDom enables developers use a one supply code to create the identical thing in diverse languages, which naturally give a huge benefit in establishing.Internet Framework tools.
Most programing constructs, including declarations, statements, arrays, casts, iterations, mistake dealing with and other individuals, is supported by the CodeDom. For programing constructs that are not presently supported in CodeDom, “snippet” classes which includes the CodeSnippetCompileUnit, CodeSnippetExpression, CodeSnippetStatement, and CodeSnippetTypeMember can be utilized as generic illustration. For creating code in a certain language, a corresponding CodeDomProvider course will be needed.
Presently there are Microsoft.CSharp.CSharpCodeProvider and Microsoft.VisualBasic.VBCodeProvider that can be used to create C Sharp code and VisuaBasic.web code. Other programming languages never have CodeDomProvider yet, and may not have easy techniques to represent some CodeDom constructions (delegates, enums, templates, and framework) thanks to big difference in language specs. Nonetheless, making a CodeDomProvider is not a really sophisticated task, if the enter CodeDom structure is limited. Programmers can often construct a CodeDomProvider for a certain language by inheriting from CodeDomProvider, and throw exceptions if the construction is too tough to signify.