view Tools/DocGen/Content/Doc/Reflection/Emit/HelloWorld.htm @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
line wrap: on
line source

<p>The <b>System.Reflection.Emit</b> namespace provides classes to create dynamic assemblies at runtime.
It allows compilers and tools to emit <b>MSIL</b>, execute it and store it to a disk.
Although <b>Emit</b> is a powerful tool, it is also extremely hard to use.</p>
<p>Let us take a look at the following example, which demonstrates the "normal" way of emit programming:</p>

HelloWorld.cs
<% ..\..\..\Examples\CS\Reflection.Emit\HelloWorldnormal.cs %>

<p>Note that the Emit method takes one parameter as an OpCode and optionally another one,
which does not depend on the current operation context. So, this way is not entirely type safe.</p>

<p>Fortunately, there is an alternative way. BLToolkit provides a helper class, 
<a href='/Source/Reflection/Emit/EmitHelper.cs.htm'>EmitHelper</a>,
which can make your life a little bit easy.
It contains typed wrapper methods for almost all emit commands and allows writing source code
that looks similar to <b>MSIL</b>.</p>
<p>The following examples show how to use the EmitHelper class with C#, VB.NET, and C++/CLI.</p>

HelloWorld.cs
<% ..\..\..\Examples\CS\Reflection.Emit\HelloWorld.cs %>
Cool!!! Isn't it?<br><br>

HelloWorld.vb
<% ..\..\..\Examples\VB\Reflection.Emit\HelloWorld.vb %>

HelloWorld.cpp
<% ..\..\..\Examples\Cpp\HelloWorld.cpp %>