<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Haytham speaks from MS</title><link>http://blogs.msdn.com/haythamalaa/default.aspx</link><description>Technical posts about Sharepoint and/or MS in general</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Invent your own language… using Oslo Part II</title><link>http://blogs.msdn.com/haythamalaa/archive/2009/05/24/invent-your-own-language-using-oslo-part-ii.aspx</link><pubDate>Sun, 24 May 2009 21:54:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9639251</guid><dc:creator>haabu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/9639251.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=9639251</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=9639251</wfw:comment><description>&lt;p&gt;Alsalam alikom wa ra7mat Allah wa barakatoh (Peace Upon You)&lt;/p&gt;  &lt;p align="center"&gt;&lt;strong&gt;&lt;font size="5"&gt;Part II: Consume the Abstract Syntax Tree        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;em&gt;&lt;font size="2"&gt;… Do some action! …&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;If you have not read &lt;a href="http://blogs.msdn.com/haythamalaa/archive/2009/05/14/invent-your-own-language-using-oslo-part-i.aspx" target="_blank"&gt;Part I&lt;/a&gt;, we have created our first grammar to recognize this language:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Send &lt;span style="color: #006080"&gt;&amp;quot;D:\Reports\Templates\Regular.tmpl&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;to&lt;/span&gt; sm1@hotmail.com&lt;br /&gt;Send &lt;span style="color: #006080"&gt;&amp;quot;D:\Reports\Templates\Special.tmpl&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;to&lt;/span&gt; sm2@hotmail.com,sm3@hotmail.com&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="http://blogs.msdn.com/haythamalaa/archive/2009/05/14/invent-your-own-language-using-oslo-part-i.aspx" target="_blank"&gt;here&lt;/a&gt; [Part I link] to find the reporter.mg file listing at the end.&lt;/p&gt;

&lt;p&gt;In this post, we will explore how to compile/parse the generated tree programmatically. And we will dig a little bit one cool way to do .NET code generation works.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a new project (You can pick a console one for simplicity), Add Reference to: 
    &lt;br /&gt;C:\Program Files\Microsoft Oslo SDK 1.0\Bin\Microsoft.M.Grammar.dll and 

    &lt;br /&gt;C:\Program Files\Microsoft Oslo SDK 1.0\Bin\System.Dataflow.dll 

    &lt;br /&gt;

    &lt;br /&gt;Microsoft.M.Grammar.dll contains MGrammarCompiler which we will use to compile our .mg file into .mgx (just as we used mg.exe tool) 

    &lt;br /&gt;

    &lt;br /&gt;System.Dataflow.dll contains DynamicParser class which will be our starting point to parse the generated AST. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;This is the compile function: 
    &lt;div&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Compile()&lt;br /&gt;{&lt;br /&gt;    MGrammarCompiler compiler = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MGrammarCompiler();&lt;br /&gt;    compiler.FileNames = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] { &lt;br /&gt;        &lt;span style="color: #006080"&gt;@&amp;quot;C:\Users\HaythamAlaa\Documents\reporter.mg&amp;quot;&lt;/span&gt; };&lt;br /&gt;    compiler.OutFile = &lt;span style="color: #006080"&gt;&amp;quot;reporter.mgx&amp;quot;&lt;/span&gt;;&lt;br /&gt;    compiler.Execute(ErrorReporter.Standard);&lt;br /&gt;}&lt;/pre&gt;
    &lt;/div&gt;

    &lt;div&gt;
      &lt;br /&gt;Basically, we pass the fileName(s) and output file then just call Execute and you are done. 

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div&gt;Then, we add a Parse method: 
      &lt;br /&gt;&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Parse()&lt;br /&gt;{&lt;br /&gt;    FileStream mgxFile = File.OpenRead(&lt;span style="color: #006080"&gt;&amp;quot;reporter.mgx&amp;quot;&lt;/span&gt;);&lt;br /&gt;    DynamicParser parser = DynamicParser.LoadFromMgx(mgxFile, &lt;br /&gt;                                &lt;span style="color: #006080"&gt;&amp;quot;Basic.Languages.Reporter&amp;quot;&lt;/span&gt;);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; root = parser.Parse&amp;lt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt;(&lt;br /&gt;            &lt;span style="color: #006080"&gt;@&amp;quot;C:\Users\HaythamAlaa\Documents\reportsData.bundle&amp;quot;&lt;/span&gt;, &lt;br /&gt;            &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;, ErrorReporter.Standard);&lt;br /&gt;    IGraphBuilder graphBuilder = parser.GraphBuilder;&lt;br /&gt;&lt;br /&gt;    Traverse(root, graphBuilder);&lt;br /&gt;&lt;/pre&gt;
DynamicParser loads the mgx file we compiled earlier, and then we ask it to parse the bundle file… note that parser.Parse&amp;lt;object&amp;gt; object is obligatory (I believe this will be refactored in the release) 

      &lt;br /&gt;

      &lt;br /&gt;As all nodes returned of type object, parser provides an IGraphBuilder object that helps us traverse and query the AST. 

      &lt;br /&gt;

      &lt;br /&gt;Traverse method should just loop over all nodes (and sub nodes) and output their values. 

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div&gt;Traverse is very straight forward. However, there is a couple of tricks we need to be aware of while traversing the tree… 
      &lt;br /&gt;First, here is the basic Traverse Method:&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Traverse(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; root, IGraphBuilder graphBuilder)&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (root &lt;span style="color: #0000ff"&gt;is&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)&lt;br /&gt;    {&lt;br /&gt;        Console.WriteLine(root.ToString());&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;-&amp;gt;&amp;quot;&lt;/span&gt; + graphBuilder.GetLabel(root));&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; childNode &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; graphBuilder.GetSuccessors(root))&lt;br /&gt;    {&lt;br /&gt;        Traverse(childNode, graphBuilder);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

      &lt;br /&gt;The output should be like this:&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;-&amp;gt;Commands&lt;br /&gt;-&amp;gt;Send&lt;br /&gt;D:\Reports\Templates\Regular.tmpl&lt;br /&gt;-&amp;gt;Emails&lt;br /&gt;sm1@hotmail.com&lt;br /&gt;-&amp;gt;Send&lt;br /&gt;D:\Reports\Templates\Special.tmpl&lt;br /&gt;-&amp;gt;Emails&lt;br /&gt;sm2@hotmail.com&lt;br /&gt;&lt;a href="mailto:sm3@hotmail.com"&gt;sm3@hotmail.com&lt;/a&gt;&lt;/pre&gt;

      &lt;br /&gt;First thing to notice, this is a simple Depth First Search (or Visitor Pattern as architects like to call it). 

      &lt;br /&gt;

      &lt;br /&gt;Second, The leaf nodes of the tree are all strings, the non-leaf ones can be of type SimpleNode or SequenceNode (or something else?) depending on how they were projected in MGrammar. 

      &lt;br /&gt;e.g:&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;=&amp;gt; Send{. . .};&lt;/pre&gt;
Would produce: 

      &lt;br /&gt;&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Send{&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;
That will be parsed as &lt;strong&gt;SimpleNode&lt;/strong&gt; 

      &lt;br /&gt;

      &lt;br /&gt;While,&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;=&amp;gt; Send[. . .];&lt;/pre&gt;
Would produce:&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;Send[&lt;br /&gt;.....&lt;br /&gt;]&lt;/pre&gt;
And will be parsed as &lt;strong&gt;SequenceNode&lt;/strong&gt; 

      &lt;br /&gt;

      &lt;br /&gt;I didn’t read any recommendation on when to use what… but I personally prefer to use {} when you are thinking of a Class and use [] when you are thinking of an Array… more of this will come later when we start generating code. 

      &lt;br /&gt;

      &lt;br /&gt;Third, GetSuccessor: This method can visit any node and iterate over its children. There is also GetSequenceElements and GetEntityMembers… probably what we want to do is something like this: 

      &lt;br /&gt;if (graphBuilder.IsEntity(root)) 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach (… graphBuilder.GetEntityMembers(root)) 

      &lt;br /&gt;else if (graphBuilder.IsSequence(root)) 

      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; foreach (… graphBuilder.GetSequenceElements(root)) 

      &lt;br /&gt;… same thing for IsNode 

      &lt;br /&gt;

      &lt;br /&gt;Note the order of checking is important, (e.g IsSequence before IsNode) because a sequence node is also a “node”… 

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div&gt;Let the fun begin, first, let’s declare a method that accepts a path and a list of emails as parameters,&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Send(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; reportPath, &lt;span style="color: #0000ff"&gt;params&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[] contacts)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine(reportPath);&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; str &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; contacts)&lt;br /&gt;        Console.WriteLine(&lt;span style="color: #006080"&gt;&amp;quot;-&amp;gt;&amp;quot;&lt;/span&gt; + str);&lt;br /&gt;}&lt;/pre&gt;
Now, we want to map every Send node into a method call with the right parameters… 

      &lt;br /&gt;We will use &lt;a href="http://msdn.microsoft.com/en-us/library/system.linq.expressions.aspx" target="_blank"&gt;System.Linq.Expressions&lt;/a&gt; namespace [MSDN Link]. 

      &lt;br /&gt;

      &lt;br /&gt;This namespace contains virtually all types of operations you can perform in .NET, Assignment, MethodCall, Lambda Expression, ArrayIndexing…. etc 

      &lt;br /&gt;

      &lt;br /&gt;2 things we are interested in for now, are MethodCallExpression (to be able to represent our Send method) and Lambda Expression to be able to compile into MSIL and actually run these instructions 

      &lt;br /&gt;

      &lt;br /&gt;Here is an example for this in action&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;MethodCallExpression expression = &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Expression.Call(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Program).GetMethod(&lt;span style="color: #006080"&gt;&amp;quot;Send&amp;quot;&lt;/span&gt;),&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Expression[] { Expression.Constant(path, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)),&lt;br /&gt;                       Expression.Constant(emails, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[])) });&lt;br /&gt;LambdaExpression lambda = Expression.Lambda(expression);&lt;br /&gt;lambda.DynamicInvoke();&lt;br /&gt;&lt;/pre&gt;
Expression is an abstract base class that contains static methods to instantiate all types of expressions.. here we call Expression.Call to create a MethodCallExpression. 

      &lt;br /&gt;It accepts a MethodInfo for the method you want to call… 

      &lt;br /&gt;and a list of parameters. 

      &lt;br /&gt;You can then call lambda.DynamicInvoke() to compile into MSIL and execute whatever expressions are inside… 

      &lt;br /&gt;&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div&gt;Here is the full listing for creating the lambda expressions out of a passed node: &lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; LambdaExpression[] TraverseAndBuildTree(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; root, &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;                                         IGraphBuilder graphBuilder)&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (graphBuilder.GetLabel(root).ToString().ToLower() == &lt;span style="color: #006080"&gt;&amp;quot;send&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;   {&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     IEnumerable&amp;lt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt; childs = graphBuilder.GetSuccessors(root);&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; path = &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         graphBuilder.GetSuccessors(childs.First()).First().ToString(&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     List&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt; emails = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; objContact &lt;span style="color: #0000ff"&gt;in&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         graphBuilder.GetSequenceElements(childs.Last()))&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;       emails.Add(objContact.ToString());&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     MethodCallExpression expression = &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;       Expression.Call(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Program).GetMethod(&lt;span style="color: #006080"&gt;&amp;quot;Send&amp;quot;&lt;/span&gt;),&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;       &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Expression[] { Expression.Constant(path, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;)),&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;           Expression.Constant(emails.ToArray(), &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;[])) })&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     LambdaExpression lambda = Expression.Lambda(expression);&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; LambdaExpression[] { lambda };&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;   }&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;   List&amp;lt;LambdaExpression&amp;gt; expressions = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;LambdaExpression&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (graphBuilder.IsSequence(root))&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; childNode &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;         graphBuilder.GetSequenceElements(root))&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;       expressions.AddRange(&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;           TraverseAndBuildTree(childNode, graphBuilder));&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (graphBuilder.IsNode(root))&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; childNode &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;         graphBuilder.GetSuccessors(root))&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;       expressions.AddRange(&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;           TraverseAndBuildTree(childNode, graphBuilder));&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;   &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; expressions.ToArray();&lt;/pre&gt;
&lt;!--CRLF--&gt;

        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;25 – 40: We just traverse all nodes available and concatenate the lambda expressions into one big list. 
      &lt;br /&gt;6 – 15: We get the values of path and email parameters from AST. 

      &lt;br /&gt;17 – 22: We create the Call Expression. 

      &lt;br /&gt;

      &lt;br /&gt;You can then use this method like this:&lt;/div&gt;

    &lt;div id="codeSnippetWrapper"&gt;
      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;LambdaExpression[] lambdas = TraverseAndBuildTree(root, graphBuilder);&lt;br /&gt;&lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (LambdaExpression lambda &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; lambdas)&lt;br /&gt;    lambda.Compile().DynamicInvoke();&lt;br /&gt;&lt;/pre&gt;
That’s it ! Spend sometime and play around with expressions ;)&lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Congrats&lt;/em&gt;, you’ve reached your 2nd Checkpoint! 

  &lt;br /&gt;

  &lt;br /&gt;The technique described here works well with simple languages, but once your language gets more complicated, you will need a more structured design (and hopefully an automated process) which we will explore in the next part.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div&gt;&lt;/div&gt;
&lt;a href="http://blogs.msdn.com/haythamalaa/archive/2009/05/14/invent-your-own-language-using-oslo-part-i.aspx" target="_blank"&gt;Part I: Create the Grammar (What your users write)&lt;/a&gt;. 

&lt;br /&gt;Part II: Consume the abstract syntax tree (Do some action). [This post] 

&lt;br /&gt;Path III: Compile your language into MSIL. 

&lt;div class="wlWriterHeaderFooter" style="margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9639251" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Oslo/default.aspx">Oslo</category></item><item><title>Static Constructor… saved my day</title><link>http://blogs.msdn.com/haythamalaa/archive/2009/05/21/static-constructor-saved-my-day.aspx</link><pubDate>Thu, 21 May 2009 18:47:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9633910</guid><dc:creator>haabu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/9633910.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=9633910</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=9633910</wfw:comment><description>&lt;p&gt;Alsalam alikom wa ra7mat Allah wa barakatoh (Peace upon you)&lt;/p&gt;  &lt;p&gt;I was designing some classes today and I got stuck with an old problem I used to fix in an ugly way… &lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; A&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitializeMe()&lt;br /&gt;    {&lt;br /&gt;        SomeClassManager.Listeners.Add(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(A));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;It would have been easy if:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You know when exactly to call InitializeMe() so that you get hooked up at the right time (before Listeners start iterating over its elements) &lt;/li&gt;

  &lt;li&gt;You know what classes contain an InitializeMe function.. you can use reflection to get a list of all classes and then check whether they have the method or not.. –you can’t use interfaces as they don’t allow static members- &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What if you are designing a plugin model for an application, and want to call some static initialization code… again you will have to do reflection (which is slow).&lt;/p&gt;

&lt;p&gt;And here comes static constructors!&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; A&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; A()&lt;br /&gt;    {&lt;br /&gt;        InitializeMe();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; InitializeMe()&lt;br /&gt;    {&lt;br /&gt;        SomeClassManager.Listeners.Add(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(A));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;That simple.. &lt;a href="http://msdn.microsoft.com/en-us/library/k9x6w0hc(VS.80).aspx" target="_blank"&gt;Static Constructor&lt;/a&gt; [MSDN Link] will be called once this type is “loaded” which happens in .NET when your assembly first gets loaded into memory.. which is exactly the time I wanted… and it saved my day!&lt;/p&gt;

&lt;p&gt;P.S, Check MEF (Managed Extensibility Framework) if you are interested in supporting plugins in ur apps, &lt;a href="http://www.codeplex.com/MEF"&gt;http://www.codeplex.com/MEF&lt;/a&gt;

  &lt;br /&gt;And here is a getting started guide, &lt;a href="http://code-inside.de/blog-in/2008/11/19/howto-first-steps-with-mef-hello-mef/"&gt;http://code-inside.de/blog-in/2008/11/19/howto-first-steps-with-mef-hello-mef/&lt;/a&gt;&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9633910" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Tips+n+Tricks/default.aspx">Tips n Tricks</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Invent your own language… using Oslo. Part I</title><link>http://blogs.msdn.com/haythamalaa/archive/2009/05/14/invent-your-own-language-using-oslo-part-i.aspx</link><pubDate>Fri, 15 May 2009 04:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9617519</guid><dc:creator>haabu</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/9617519.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=9617519</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=9617519</wfw:comment><description>Alsalam alikom wa ra7mat Allah wa barakatoh (Peace Upon You) Part I: Create the Grammar …What your users will write… If you are writing enterprise software, you probably came across this problem many times when you want to give IT Admins the ability to...(&lt;a href="http://blogs.msdn.com/haythamalaa/archive/2009/05/14/invent-your-own-language-using-oslo-part-i.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9617519" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Oslo/default.aspx">Oslo</category></item><item><title>Friend Assemblies in .NET</title><link>http://blogs.msdn.com/haythamalaa/archive/2009/04/30/friend-assemblies-in-net.aspx</link><pubDate>Fri, 01 May 2009 02:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9581465</guid><dc:creator>haabu</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/9581465.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=9581465</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=9581465</wfw:comment><description>Alsalam alikom wa r7amat Allah wa barakatoh (Peace upon you..) Long story short, you have AssemblyA (with source code) and AssemblyB… you want AssemblyB to be able to access internal members (types, data, methods.. etc) of AssemblyA… You can of course...(&lt;a href="http://blogs.msdn.com/haythamalaa/archive/2009/04/30/friend-assemblies-in-net.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9581465" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Tips+n+Tricks/default.aspx">Tips n Tricks</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Javascript Execution Context</title><link>http://blogs.msdn.com/haythamalaa/archive/2008/07/21/javascript-execution-context.aspx</link><pubDate>Mon, 21 Jul 2008 15:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8760352</guid><dc:creator>haabu</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/8760352.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=8760352</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=8760352</wfw:comment><description>Alsalam alikom wa ra7mat Allah wa barakatoh I've faced a strange javascript exception when running a piece of code on Firefox/Safari, while it works fine on IE. Here is what Firefox 3.0 says: uncaught exception : [ Exception ... "Illegal operation on...(&lt;a href="http://blogs.msdn.com/haythamalaa/archive/2008/07/21/javascript-execution-context.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8760352" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Javascript/default.aspx">Javascript</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Errors/default.aspx">Errors</category><category domain="http://blogs.msdn.com/haythamalaa/archive/tags/Script/default.aspx">Script</category></item><item><title>Hello World!</title><link>http://blogs.msdn.com/haythamalaa/archive/2008/06/19/hello-world.aspx</link><pubDate>Thu, 19 Jun 2008 22:03:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8622751</guid><dc:creator>haabu</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/haythamalaa/comments/8622751.aspx</comments><wfw:commentRss>http://blogs.msdn.com/haythamalaa/commentrss.aspx?PostID=8622751</wfw:commentRss><wfw:comment>http://blogs.msdn.com/haythamalaa/rsscomments.aspx?PostID=8622751</wfw:comment><description>&lt;p&gt;Alsalam alikom wa ra7mat Allah wa barakatoh (aka Peace upon you)&lt;/p&gt; &lt;p&gt;&lt;br&gt;This's my first post on MSDN blogs, I've been blogging since 2005 on blogspot though... a mixture of personal and technical posts you can find on &lt;a href="http://haythamalaa.blogspot.com"&gt;http://haythamalaa.blogspot.com&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I'll keep this blog technical except for this first post &lt;img alt="Smile" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/regular_smile.gif"&gt;.&lt;/p&gt; &lt;p&gt;A brief about me:&lt;/p&gt; &lt;p&gt;Haytham Alaa Abuel-Futuh, Muslim, Egyptian. Graduated from faculty of Computer and Information Sciences, Ain-Shams University, Cairo, Egypt.&lt;br&gt;he was actively joining ACM during school days, and was a part of a team which participated in our regional contest for 2 consecutive years, getting the 9th then 5th positions respectively.&lt;/p&gt; &lt;p&gt;He got a research scholarship in University of Paderborn, Germany in 2007 during which he -along with his teammates- developed RDES (Remote Debugging for Embedded Systems).&lt;/p&gt; &lt;p&gt;He then joined &lt;a href="http://criticalsites.com" target="_blank"&gt;Critical Sites&lt;/a&gt; -the development division of &lt;a href="http://ntpsoftware.com" target="_blank"&gt;NTP Software&lt;/a&gt;-the world leader in managing massive unorganized data- in late 2007 till early May-2008 when he moved to &lt;a href="http://microsoft.com" target="_blank"&gt;Microsoft&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Keep in touch.&lt;/p&gt; &lt;p&gt;Haytham Abuel-Futuh,&lt;br&gt;SDE, WSS, MCDC,&lt;br&gt;&lt;u&gt;&lt;font color="#669966"&gt;&lt;a href="http://haythamalaa.blogspot.com"&gt;http://haythamalaa.blogspot.com&lt;/a&gt;.&lt;/font&gt;&lt;/u&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8622751" width="1" height="1"&gt;</description></item></channel></rss>