<?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>Implementing Event Handling, Part Two</title><link>http://blogs.msdn.com/b/ericlippert/archive/2005/09/21/472465.aspx</link><description>It's been an insanely busy month for me, between having multiple out-of-town guests, throwing a party for the people who couldn't make it to the wedding, and oh yeah, getting up to speed on the C# compiler and trying to understand the implications that</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Implementing Event Handling, Part Two</title><link>http://blogs.msdn.com/b/ericlippert/archive/2005/09/21/472465.aspx#8786364</link><pubDate>Tue, 29 Jul 2008 03:13:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8786364</guid><dc:creator>ptrex</dc:creator><description>&lt;p&gt;I was planning on implementing a script-host in my application, and let user scripts to respons to event raised by the application. Most of the code is not COM-code, so I though that I could use code-generation (from XML, for instance) to create files as follows:&lt;/p&gt;
&lt;p&gt;// CClass.h&lt;/p&gt;
&lt;p&gt;class CClass {&lt;/p&gt;
&lt;p&gt;public:&lt;/p&gt;
&lt;p&gt;IDispatch getIDispatch();&lt;/p&gt;
&lt;p&gt;ITypeInfo getITypeInfo();&lt;/p&gt;
&lt;p&gt;// members from XML&lt;/p&gt;
&lt;p&gt;};&lt;/p&gt;
&lt;p&gt;//CClass.cpp&lt;/p&gt;
&lt;p&gt;IDispatch CClass::getIDispatch(&lt;/p&gt;
&lt;p&gt;// CreateDispTypeInfo&lt;/p&gt;
&lt;p&gt;// CreateStdDispatch ...&lt;/p&gt;
&lt;p&gt;);&lt;/p&gt;
&lt;p&gt;ITypeInfo CClass::getITypeInfo() {&lt;/p&gt;
&lt;p&gt;// CreateDispTypeInfo&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;void CClass::memberFromXML() {&lt;/p&gt;
&lt;p&gt;// call CClassImpl::memberFromClass - this would be the class that the user will actually write&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;// rest of members from XML&lt;/p&gt;
&lt;p&gt;But reading this post makes me wonder - what do I need to do so that the scripts could implement event handlers? I hoped for something like:&lt;/p&gt;
&lt;p&gt;// C++&lt;/p&gt;
&lt;p&gt;myScriptEngine.AddNamedItem(&amp;quot;FileMon&amp;quot;, SCRIPTITEM_ISSOURCE)&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;// User-attached script&lt;/p&gt;
&lt;p&gt;Sub FileMon_OnFileCreate(filename)&lt;/p&gt;
&lt;p&gt;MyLog.WriteLine(&amp;quot;OMG~~~ somebody crated a file by the amaz1ng name of: &amp;quot; &amp;amp; filename)&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;How feasible is this and what do I need to do with my C++ classes/interfaces to support this? Note that the rest of the code doesn't use COM in any way, and this is probably the only place in which it is going to be used, so I'd prefer as few changes as possible (if it can be achieved through code-generation however, it's not as bad). Also, registration is highly discouraged. After all, it's practically an internal class.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8786364" width="1" height="1"&gt;</description></item><item><title>re: Implementing Event Handling, Part Two</title><link>http://blogs.msdn.com/b/ericlippert/archive/2005/09/21/472465.aspx#472860</link><pubDate>Thu, 22 Sep 2005 19:56:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:472860</guid><dc:creator>Eric Lippert</dc:creator><description>That preview compiler is a decent demo and research tool, but it is not a production-quality compiler.  We're going to have to do a huge amount of refactoring work in the real compiler to get C# 3.0 features generating more optimal code and working with IDE features such as Intellisense.&lt;br&gt;&lt;br&gt;So there are huge implications for the refactoring and redesign of the current C# 2.0 codebase.  There's plenty of work to keep us going for quite a while here.  The demo compiler is just the first step in a long process.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=472860" width="1" height="1"&gt;</description></item><item><title>re: Implementing Event Handling, Part Two</title><link>http://blogs.msdn.com/b/ericlippert/archive/2005/09/21/472465.aspx#472827</link><pubDate>Thu, 22 Sep 2005 19:05:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:472827</guid><dc:creator>RIchB</dc:creator><description>&amp;gt; trying to understand the implications that LINQ &lt;br&gt;&amp;gt; features are going to have on the current &lt;br&gt;&amp;gt; implementation&lt;br&gt;&lt;br&gt;Surely you already know the implications? The preview compiler contains LINQ support already! The only (announced) planned LINQ stuff that wasn't in the preview were lambda statements - which are probably not capable of being compiled to expression trees and are therefore virtually identical to anonymous methods from C# v2.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=472827" width="1" height="1"&gt;</description></item></channel></rss>