<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Implement INotifyPropertyChanged with dynamic code generation</title>
	<atom:link href="http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/</link>
	<description>Wrecks of code floating in the sea of Internet By Ricci Gian Maria</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:15:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/comment-page-1/#comment-2643</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Mon, 24 Aug 2009 14:13:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/#comment-2643</guid>
		<description>Yeah, you are right, NotifyPropertyChanged must be raised after the property has chantged and not before :) thanks for pointing it out.

alk.</description>
		<content:encoded><![CDATA[<p>Yeah, you are right, NotifyPropertyChanged must be raised after the property has chantged and not before <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  thanks for pointing it out.</p>
<p>alk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niels van der Zanden</title>
		<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/comment-page-1/#comment-2642</link>
		<dc:creator>Niels van der Zanden</dc:creator>
		<pubDate>Mon, 24 Aug 2009 12:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/#comment-2642</guid>
		<description>Quite a late reply, I know. :)

I succesfully used this example in a Silverlight application. There was however one thing that I had to change.

Instead of raising the event and setting the new value, I had to set the new value and _then_ raise the event.

If if for instance editted a field in a datagrid bound to a property of a dynamically created object, it would change the displayed value back to the old value.

If you change
        gen.Emit(OpCodes.Ldarg_0);
        gen.Emit(OpCodes.Ldstr, pinfo.Name);
        gen.Emit(OpCodes.Call, raiseEvent);
        gen.Emit(OpCodes.Ldarg_0);
        gen.Emit(OpCodes.Ldarg_1);
        gen.Emit(OpCodes.Call, pinfo.GetSetMethod());
        gen.Emit(OpCodes.Ret);
to:
        gen.Emit(OpCodes.Ldarg_0);
        gen.Emit(OpCodes.Ldarg_1);
        gen.Emit(OpCodes.Call, pinfo.GetSetMethod());
        gen.Emit(OpCodes.Ldarg_0);
        gen.Emit(OpCodes.Ldstr, pinfo.Name);
        gen.Emit(OpCodes.Call, raiseEvent);
        gen.Emit(OpCodes.Ret);

it works like a charm!</description>
		<content:encoded><![CDATA[<p>Quite a late reply, I know. <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I succesfully used this example in a Silverlight application. There was however one thing that I had to change.</p>
<p>Instead of raising the event and setting the new value, I had to set the new value and _then_ raise the event.</p>
<p>If if for instance editted a field in a datagrid bound to a property of a dynamically created object, it would change the displayed value back to the old value.</p>
<p>If you change<br />
        gen.Emit(OpCodes.Ldarg_0);<br />
        gen.Emit(OpCodes.Ldstr, pinfo.Name);<br />
        gen.Emit(OpCodes.Call, raiseEvent);<br />
        gen.Emit(OpCodes.Ldarg_0);<br />
        gen.Emit(OpCodes.Ldarg_1);<br />
        gen.Emit(OpCodes.Call, pinfo.GetSetMethod());<br />
        gen.Emit(OpCodes.Ret);<br />
to:<br />
        gen.Emit(OpCodes.Ldarg_0);<br />
        gen.Emit(OpCodes.Ldarg_1);<br />
        gen.Emit(OpCodes.Call, pinfo.GetSetMethod());<br />
        gen.Emit(OpCodes.Ldarg_0);<br />
        gen.Emit(OpCodes.Ldstr, pinfo.Name);<br />
        gen.Emit(OpCodes.Call, raiseEvent);<br />
        gen.Emit(OpCodes.Ret);</p>
<p>it works like a charm!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/comment-page-1/#comment-1724</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Wed, 27 Aug 2008 09:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/#comment-1724</guid>
		<description>I do not think that dynamic code generation is the solution to implement interfaces such as INOtiryPropertyChabnged, this post is intendend mainly to show how technically you can do this.

I had little experiences with silverlight. but I setup a simple scenario 
1) a WCF service that exposes all the functions needed to manage the Domain, all the objects are DTO.
2) I create a service reference from silverlight (This in turn creates proxy for the DTO that implements IPRopertyChanges
3) I setup silverlight application to work with dto, the user modify the objects, does operations and whenever he want he can press save.
4) The save button simply takes all the DTO and send them to the appropriate update function in the service.
5) The service does all the logic to update data.

Moreover silverlight runs in browser, and it does not have full trust, so certain operations are not permitted, I think code generation is one of these :(, but I have not tried.

Alk.</description>
		<content:encoded><![CDATA[<p>I do not think that dynamic code generation is the solution to implement interfaces such as INOtiryPropertyChabnged, this post is intendend mainly to show how technically you can do this.</p>
<p>I had little experiences with silverlight. but I setup a simple scenario<br />
1) a WCF service that exposes all the functions needed to manage the Domain, all the objects are DTO.<br />
2) I create a service reference from silverlight (This in turn creates proxy for the DTO that implements IPRopertyChanges<br />
3) I setup silverlight application to work with dto, the user modify the objects, does operations and whenever he want he can press save.<br />
4) The save button simply takes all the DTO and send them to the appropriate update function in the service.<br />
5) The service does all the logic to update data.</p>
<p>Moreover silverlight runs in browser, and it does not have full trust, so certain operations are not permitted, I think code generation is one of these <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> , but I have not tried.</p>
<p>Alk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todd Wilder</title>
		<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/comment-page-1/#comment-1718</link>
		<dc:creator>Todd Wilder</dc:creator>
		<pubDate>Tue, 26 Aug 2008 17:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/#comment-1718</guid>
		<description>I am curious if its possible to port this code to Silverlight. It would be HUGE if you could. I&#039;ve tried a dump port and it doesn&#039;t work, but I don&#039;t really know what you are doing here. If you could try it...HUGE</description>
		<content:encoded><![CDATA[<p>I am curious if its possible to port this code to Silverlight. It would be HUGE if you could. I&#8217;ve tried a dump port and it doesn&#8217;t work, but I don&#8217;t really know what you are doing here. If you could try it&#8230;HUGE</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alkampfer&#8217;s Place &#187; Blog Archives &#187; Implement InotifyPropertyChanged with Castle.DynamicProxy</title>
		<link>http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/comment-page-1/#comment-1665</link>
		<dc:creator>Alkampfer&#8217;s Place &#187; Blog Archives &#187; Implement InotifyPropertyChanged with Castle.DynamicProxy</dc:creator>
		<pubDate>Mon, 04 Aug 2008 16:36:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2008/08/04/implement-inotifypropertychanged-with-dynamic-code-generation/#comment-1665</guid>
		<description>[...] Implement INotifyPropertyChanged with dynamic code generation [...]</description>
		<content:encoded><![CDATA[<p>[...] Implement INotifyPropertyChanged with dynamic code generation [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

