CodeDom – An Progress Approach For Code Era at Operate Time
CodeDom, which stands for Code Doc Object Design, is 1 advance strategy offered by Microsoft.Internet Framework to create code at operate-time. At application amount, it presents programmers the functionality to compose a one language-impartial code that can emit source code in a distinct language for afterwards specifications.
Code Doc Item Design lies within the Method.CodeDom namespaces of the.Web Framework. The CodeDom has the subsequent positive aspects:
From a solitary code that makes use of the CodeDom to signify the construction of source code that can create resource 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 provides a language independent object product for representing the structure of supply code in memory.
It acts as a resource code translator among distinct languages.
Typical usages of the CodeDOM contain:
Making template code for emitting code wizards, coding illustrations, XML World wide web services consumer proxies, etc.
Dynamically compiling code in languages supported.
T4 (Textual content Template Transformation Toolkit) is one more powerful generation instrument offered by Microsoft.internet Framework. Not like the CodeDom, T4 utilizes string concatenation to produce textual template to create code. A great deal of the output code will be place into template blocks, in purchase to make the code generator simple to produce and customise. Nonetheless, T4 is a language dependent and will need to have a different code generator for every output language. On the other hand, the CodeDom permits developers use a one resource code to make the same thing in various languages, which naturally give a massive benefit in establishing.Internet Framework equipment.
qr code Most programing constructs, which includes declarations, statements, arrays, casts, iterations, mistake managing and other people, is supported by the CodeDom. For programing constructs that are not presently supported in CodeDom, “snippet” courses such as the CodeSnippetCompileUnit, CodeSnippetExpression, CodeSnippetStatement, and CodeSnippetTypeMember can be utilized as generic illustration. For making code in a distinct language, a corresponding CodeDomProvider course will be needed.
Presently there are Microsoft.CSharp.CSharpCodeProvider and Microsoft.VisualBasic.VBCodeProvider that can be used to generate C Sharp code and VisuaBasic.net code. Other programming languages don’t have CodeDomProvider however, and may possibly not have simple methods to symbolize some CodeDom constructions (delegates, enums, templates, and framework) owing to difference in language requirements. Even so, creating a CodeDomProvider is not a extremely sophisticated activity, if the input CodeDom framework is limited. Programmers can often construct a CodeDomProvider for a specific language by inheriting from CodeDomProvider, and toss exceptions if the development is too hard to signify.