Can you explain very briefly what CodeDOM is and used for with a simple real life example?

前提是你 提交于 2019-12-01 16:23:48

问题


Can you explain very briefly what CodeDOM is and used for with a simple real life example?

A simple example that covers why would I need it as a developer, in what scenarios?

Thanks


回答1:


CodeDOM stands for Code Document Object Model. Basically, it is your code represented by a hierarchical tree of objects, a model.. Consider a method with some statements in it:

int Foo(int bar)
{
    int i = 0;
    if ( bar == 1 ) i = 1;
    return i;
}

This would result in a DOM as follows:

method foo
    declaration
    if (expression)
        assignment
    return

A model like this that represents your code allows you to perform various manipulations or checks on it.




回答2:


The CodeDOM represents the code in a structured manner. You would want to use it, if you would like to write a program that analyses code like ReSharper or that generates code. For more info, see: http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx



来源:https://stackoverflow.com/questions/5673620/can-you-explain-very-briefly-what-codedom-is-and-used-for-with-a-simple-real-lif

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!