<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2008534129495378119</id><updated>2025-10-11T14:13:42.760+05:30</updated><category term="JQuery"/><category term="MVC3"/><category term="NCover"/><category term="ASP.Net"/><category term="MSTest"/><category term="Node.js"/><category term="WF4"/><category term="Aja"/><category term="Ajax"/><category term="Algorithm"/><category term="Angularjs"/><category term="AppFabric"/><category term="AutoComplete"/><category term="Basics"/><category term="Client Validation"/><category term="CodeCoverage"/><category term="Commands"/><category term="Customized"/><category term="Distributed Version Controlling"/><category term="Dyanamic"/><category term="Entity-Framework Lazy-Loading"/><category term="Grouped"/><category term="IIS"/><category term="Installing"/><category term="JQuey Post URL MVC"/><category term="JSON"/><category term="Jenkins"/><category term="MVC"/><category term="Mercurial"/><category term="RealTimeWeb"/><category term="Report"/><category term="Socket.io"/><category term="State Machine"/><category term="Validation"/><category term="WCF"/><category term="Windows Server 2008"/><category term="sample"/><title type='text'>Code Tuner</title><subtitle type='html'>Jayantha Lal Sirisena&#xa;&lt;p&gt;&#xa;&#xa;Software Engineer &lt;a href=&quot;http://www.99xtechnology.com/&quot;&gt;@99X Technology&lt;/a&gt;&#xa;&#xa;&lt;a href=&quot;http://lk.linkedin.com/in/jayanthalal&quot;&gt; My Profile&lt;/a&gt;&#xa;&lt;/p&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-8064252005274335352</id><published>2016-06-12T11:14:00.000+05:30</published><updated>2016-06-12T11:18:09.798+05:30</updated><title type='text'>Angular2 for Angular1.x developers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are an angular 1.x developer and trying to migrate in to Angular2 here are some points which you need to keep in mind.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;1. Where are singleton factories and services ,&lt;/h2&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt;Angular1.x&lt;/b&gt;&amp;nbsp; &amp;nbsp; We had lazy singleton &amp;nbsp;instances of services and factories for entire scope of the application. We had one injector for entire app who is responsible creating an instance of a service or a factory when it is requested by some component.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt;Angular2 &amp;nbsp; &amp;nbsp; &lt;/b&gt;Here we have a&amp;nbsp;hierarchical&amp;nbsp;set of&amp;nbsp;interjects , which makes a tree&amp;nbsp;similar&amp;nbsp;to component&amp;nbsp;tree in the application. That makes previous concept of singletons little bit complex. &amp;nbsp;Because we can have different instances of same class in different injectors that means in different levels in the components tree. Here how its done,&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Create Application level singleton (This is discouraged ) ,&lt;/h3&gt;
&amp;nbsp;1. Bootstrap the application with the provide specified&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;span class=&quot;pln&quot; style=&quot;color: #5c707a; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;bootstrap&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #d43669; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;AppComponent&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #d43669; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;YourServiceForEntireApp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;]);&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;2.And then &lt;b&gt;don&#39;t&lt;/b&gt; specify &amp;nbsp;the service name in the metadata for the component ,&lt;br /&gt;
&lt;br /&gt;
&lt;ol class=&quot;linenums&quot; style=&quot;background: rgb(245, 246, 247); color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; line-height: 28px; margin: 0px; opacity: 0.87; overflow: auto; padding: 16px 32px 16px 56px; white-space: pre-wrap;&quot;&gt;
&lt;li class=&quot;L5&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;lit&quot; style=&quot;color: #647f11;&quot;&gt;@Component&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;({&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L6&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  selector&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;&#39;my-component&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L7&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #d43669;&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;`&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L7&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;    Some template &lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L0&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;  `&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L1&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  providers&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #d43669; line-height: 24px;&quot;&gt;YourServiceForEntireApp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;]// Don&#39;t do this&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L3&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
The component level injector will look for the instance of &amp;nbsp;&lt;span style=&quot;color: #d43669; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;YourServiceForEntireApp &lt;/span&gt;in the current component level injector since it is not there it will look upward and get the application level instance.This is discouraged because in most of the time a service will responsible for a part of the application.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Create singleton for part of the application&lt;/h3&gt;
1. Specify service in provider section in the parent component which cover the area of the application which need to keep a singleton instance&lt;br /&gt;
&lt;ol class=&quot;linenums&quot; style=&quot;background: rgb(245, 246, 247); color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; line-height: 28px; margin: 0px; opacity: 0.87; overflow: auto; padding: 16px 32px 16px 56px; white-space: pre-wrap;&quot;&gt;
&lt;li class=&quot;L5&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;lit&quot; style=&quot;color: #647f11;&quot;&gt;@Component&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;({&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L6&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  selector&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;&#39;my-parent-component&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L7&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #d43669;&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;`&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L8&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;  &amp;lt;h2&amp;gt;Parent&amp;lt;/h2&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L9&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;  &amp;lt;router-outlet&amp;gt;&amp;lt;/router-outlet&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L0&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;str&quot; style=&quot;color: #647f11;&quot;&gt;  `&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;,&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L1&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;  providers&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #d43669; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; line-height: 24px;&quot;&gt;YourServiceSingletonUnderthisComponent&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;],&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L3&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 5px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;})&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li class=&quot;L4&quot; style=&quot;background: none; color: #7a8b94; font-size: 12px; line-height: normal; list-style-type: decimal; margin-bottom: 0px;&quot;&gt;&lt;code ng-non-bindable=&quot;&quot; style=&quot;background: none; border-radius: 2px; color: #5c707a; font-family: Monaco, &#39;Lucida Console&#39;, monospace; font-size: 13px; padding: 0px;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #d43669;&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #d43669;&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot; style=&quot;color: #d43669;&quot;&gt;HeroesComponent&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;color: #7a8b94;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&amp;nbsp;2. And make sure you &lt;b&gt;don&#39;t&lt;/b&gt; specify&amp;nbsp;&lt;span style=&quot;background-color: #f5f6f7; color: #d43669; font-family: &amp;quot;monaco&amp;quot; , &amp;quot;lucida console&amp;quot; , monospace; font-size: 13px; line-height: 24px; white-space: pre-wrap;&quot;&gt;YourServiceSingletonUnderthisComponent  &lt;/span&gt;in &amp;nbsp;providers of child components under this.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/8064252005274335352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2016/06/angular2-for-angular-1x-developers.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8064252005274335352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8064252005274335352'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2016/06/angular2-for-angular-1x-developers.html' title='Angular2 for Angular1.x developers'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-1734014152939260630</id><published>2014-07-12T18:33:00.000+05:30</published><updated>2014-07-12T18:33:13.316+05:30</updated><title type='text'>Angularjs- How dirty checking works in angular</title><content type='html'>&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/36903424&quot; width=&quot;427&quot; height=&quot;356&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px; max-width: 100%;&quot; allowfullscreen&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom:5px&quot;&gt; &lt;strong&gt; &lt;a href=&quot;https://www.slideshare.net/jayanthakgjls/angularjs-36903424&quot; title=&quot;AngularJs , How it works&quot; target=&quot;_blank&quot;&gt;AngularJs , How it works&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/jayanthakgjls&quot; target=&quot;_blank&quot;&gt;Jayantha Sirisena&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/1734014152939260630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2014/07/angularjs-how-dirty-checking-works-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1734014152939260630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1734014152939260630'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2014/07/angularjs-how-dirty-checking-works-in.html' title='Angularjs- How dirty checking works in angular'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-8893535198244454755</id><published>2014-07-12T18:30:00.003+05:30</published><updated>2014-07-12T18:30:59.582+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Angularjs"/><category scheme="http://www.blogger.com/atom/ns#" term="Basics"/><title type='text'>Angularjs Basics</title><content type='html'>&lt;iframe src=&quot;//www.slideshare.net/slideshow/embed_code/36903366&quot; width=&quot;427&quot; height=&quot;356&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px; max-width: 100%;&quot; allowfullscreen&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom:5px&quot;&gt; &lt;strong&gt; &lt;a href=&quot;https://www.slideshare.net/jayanthakgjls/angularjs-36903366&quot; title=&quot;Angularjs Basics&quot; target=&quot;_blank&quot;&gt;Angularjs Basics&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/jayanthakgjls&quot; target=&quot;_blank&quot;&gt;Jayantha Sirisena&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/8893535198244454755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2014/07/angularjs-basics_12.html#comment-form' title='146 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8893535198244454755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8893535198244454755'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2014/07/angularjs-basics_12.html' title='Angularjs Basics'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>146</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-2422675217083501517</id><published>2013-12-12T20:37:00.001+05:30</published><updated>2013-12-12T20:37:52.013+05:30</updated><title type='text'>StackNotifier - StackOverflow Extension for chrome , with desktop notifications</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Welcome to my first ever chrome extension. I have prepared a small lightweight extension to display new questions in stackoverflow.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;User can subscribe several tags and the extension will show the desktop notifications whenever new questions available. If you are a stackoverflow fan this will make your life easy. You don&#39;t have to keep open a tab and do refresh to see new questions to answer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;In the settings page currently user can specify set of tags separated by semicolon and a time interval to be used to check new questions .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add it here ,&amp;nbsp;&lt;a href=&quot;https://chrome.google.com/webstore/detail/stacknotifier/dkicpibgdednbmlclkbcehckpfficabn&quot;&gt;https://chrome.google.com/webstore/detail/stacknotifier/dkicpibgdednbmlclkbcehckpfficabn&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;b&gt;Happy StackOverflowing...&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/2422675217083501517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2013/12/stacknotifier-stackoverflow-extension.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2422675217083501517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2422675217083501517'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2013/12/stacknotifier-stackoverflow-extension.html' title='StackNotifier - StackOverflow Extension for chrome , with desktop notifications'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-1683800281769497858</id><published>2013-09-10T08:45:00.002+05:30</published><updated>2013-09-10T08:45:34.902+05:30</updated><title type='text'>StackOverflowing</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;iframe src=&quot;http://www.slideshare.net/slideshow/embed_code/25294953&quot; width=&quot;427&quot; height=&quot;356&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot; style=&quot;border:1px solid #CCC;border-width:1px 1px 0;margin-bottom:5px&quot; allowfullscreen webkitallowfullscreen mozallowfullscreen&gt; &lt;/iframe&gt; &lt;div style=&quot;margin-bottom:5px&quot;&gt; &lt;strong&gt; &lt;a href=&quot;https://www.slideshare.net/jayanthakgjls/so-25294953&quot; title=&quot;So&quot; target=&quot;_blank&quot;&gt;So&lt;/a&gt; &lt;/strong&gt; from &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/jayanthakgjls&quot; target=&quot;_blank&quot;&gt;Jayantha Sirisena&lt;/a&gt;&lt;/strong&gt; &lt;/div&gt;

&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/1683800281769497858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2013/09/stackoverflowing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1683800281769497858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1683800281769497858'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2013/09/stackoverflowing.html' title='StackOverflowing'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-5413531034594283236</id><published>2013-01-29T09:26:00.000+05:30</published><updated>2013-01-29T09:26:32.157+05:30</updated><title type='text'>Version Control For An Agile Team</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Version control for an agile team
A version control system is not just a tool to manage the content of a project, it&#39;s defines how the project team collaborate and interact with each other. And it plays an important part when the team decides how they are going to manage the changes to the code.
Version controlling systems started with lock based version controlling with RCS,  SCCS in 70’s. And the next generation CVSwere CVS in 1986, Perforce (1995), CVSNT (1998), and then we got Subversion (2000); they were commonly referred as centralized version controlling systems which means they have a central repository which keeps all the content and the history.  Individual clients (team members) have their local code which can be sync with the central repository. And also a client can get the historical versions of the files as well.
 
 
 
 
 
 
 
 &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6dTpY4sF-vMHrbkVYSAsVBRm8byyVA8NuYqfSEbDG3qbhzdIveKnKoxccd3WuBZceNgVpV1NK1PWD7uuEuFxB-8fn0tsD4MyAiijs5jLfOG3bZyibQGTZAPP5-PjVhtPBO1AspF6FPpvT/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6dTpY4sF-vMHrbkVYSAsVBRm8byyVA8NuYqfSEbDG3qbhzdIveKnKoxccd3WuBZceNgVpV1NK1PWD7uuEuFxB-8fn0tsD4MyAiijs5jLfOG3bZyibQGTZAPP5-PjVhtPBO1AspF6FPpvT/s320/Capture.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Figure1: Centralized version controlling&lt;/b&gt;&lt;br /&gt;
In this type of version controlling systems every change had to be submitted to the central repository. Let&#39;s say A needs to some change and B need&#39;s to get that change to proceed his work. Then A should check-in or push the change to the central repository and B need&#39;s to get or pull those changes from the central server. These changes will also be visible to C, whether this is desired or not. This model is called a centralized version control systems.

Arch, Monotone and Bitkeeper were the first Distributed version control systems (DVCS). In December 1999 Linus Torvalds, the creator of Linux kernel, chose Bitkeeper in order to manage the mainline kernel sources. At that time Bitkeeper was the only truly distributed version control system which had repositories for every user of the source control system. That means in a DVCS all the clients have a repository which can be called a local repository containing all historical revisions and branches. 










&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73QKPSWvkhejm9r7CSAmF_eiC0eqEia_uuqwK8FwGIqn9NSI_yjLG8qVYqJ_O2R2naeSpRFqVY8PcaGYuC1JtVXwXmPl5rj8H2EqD0PF1J97WavGNH1Ll4V77_J0B2hyphenhyphenOznP11Nt_8cHk/s1600/2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;176&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg73QKPSWvkhejm9r7CSAmF_eiC0eqEia_uuqwK8FwGIqn9NSI_yjLG8qVYqJ_O2R2naeSpRFqVY8PcaGYuC1JtVXwXmPl5rj8H2EqD0PF1J97WavGNH1Ll4V77_J0B2hyphenhyphenOznP11Nt_8cHk/s320/2.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;Figure2: Distributed Version Controlling&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So in this model since each endpoint has the total repository it can be act as a server itself. There is no central point which controls everything but each endpoint can directly push or pull updates from any other endpoint which makes it kind of a peer to peer network.
 







&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLomz6-vHk2RFbrX5-dUJZXzHS3o-TgC-gSAlaLZZBiTZEKTEZ2vDchhku9LZ1V6MlypZZwUo9u2r0m6HJo2dwVk5xmNDp0epkQZq_WEAcCCoje8JhSQkNu_qkMAloY4ma3M-QcmjvOkEf/s1600/3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;146&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLomz6-vHk2RFbrX5-dUJZXzHS3o-TgC-gSAlaLZZBiTZEKTEZ2vDchhku9LZ1V6MlypZZwUo9u2r0m6HJo2dwVk5xmNDp0epkQZq_WEAcCCoje8JhSQkNu_qkMAloY4ma3M-QcmjvOkEf/s320/3.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;Figure3: DVCS in operation&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;One of the advantages of having a local repository for each endpoint is that we can work offline without connecting to a central repository like centralized version control systems. Since all the historical data is in the local repository we can get older versions and even merge them offline. This make developers work easy because developers can work where ever they are. 
And in distributed version control systems branching and merging is an easy task compared to other version control systems because every change acts as a kind of a branch and we need to merge that to the main branch. This is because DVCS&#39;s keep change sets instead of versions of the file. When we do a commit what it stores is the change we have done instead of a new version of older file like most of the centralized version control systems. This makes merge easy since it&#39;s just applying sequence of changes to a file instead of merging two versions of a file.&lt;br /&gt;
&amp;nbsp;By encouraging branching and merging DVCS offers flexibility for the developers to experiment new ideas without affecting the main branch. For agile teams it&#39;s really important to have flexibility to change the code and experiment new requirement in different ways. Let&#39;s say for a new requirement or a feature team needs to do some R&amp;amp;D on several ways of doing it. Then with the DVCS team can create experimental branches to experiment different methods and if one experiment is successful then it&#39;s just a matter of merging that one in to the main development branch.

For agile teams it&#39;s really important to have flexibility to change the code and experiment new requirements in different ways. For example, the team needs to do some R &amp;amp;D to figure out the best approach to implement a new requirement or feature. Then with the DVCS team can create branches to experiment different methods and select the branch having the most successful experiment and then it&#39;s just a matter of merging that branch in to the main development branch.



 









&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoLlF8H53HKNpXdp7KPzwWa_X1egmomhrX-0caqb-KxjV4wu9GXP8qcgJxmO0FJR9lEfdfPOFqcqCL0RjxPy7TUKKWr9ddq_HoRvYESy00lW7wjhR3eqcSqYXjrCQFSJ5WIycmXA1VGe5a/s1600/4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;167&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoLlF8H53HKNpXdp7KPzwWa_X1egmomhrX-0caqb-KxjV4wu9GXP8qcgJxmO0FJR9lEfdfPOFqcqCL0RjxPy7TUKKWr9ddq_HoRvYESy00lW7wjhR3eqcSqYXjrCQFSJ5WIycmXA1VGe5a/s400/4.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Figure 4: Diagram showing experimental branches&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;This allows developers to work freely. It doesn&#39;t really matter that a developer breaks the build in an experimental branch because he can work independently on their branch. And it increases the collaboration of the agile team because it&#39;s really easy to push the changes directly to any other member without affecting any other members in the team. This gives us another important advantage of DVCS for agile teams. 
 













&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHnE8_TEw8c-0DO2G04xZJB50ep_3CAlkWPjlNpYZAs9EatNdnXUbWSJoqofXpDTVvbZ7TXZCuUy695mx8Ql3nhzjxI4ATmuAi1zWT7gIZc7lxzBUaHVwS3hiVazke1pISjKAKEgwbvswD/s1600/5.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHnE8_TEw8c-0DO2G04xZJB50ep_3CAlkWPjlNpYZAs9EatNdnXUbWSJoqofXpDTVvbZ7TXZCuUy695mx8Ql3nhzjxI4ATmuAi1zWT7gIZc7lxzBUaHVwS3hiVazke1pISjKAKEgwbvswD/s320/5.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Figure 5:  peer to peer communication&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
And this increases the collaboration and the effectiveness of agile teams. With the centralized model, if one team member needs to share his version of code with someone else, he needs to push his changes to the central server and then the other one needed to pull changes from the central. But in DVCS there is no central server to control; therefore one user can directly push his changes to any other user because it enables. This increases the effectiveness of an agile team in several ways because sometimes it is really important to work independently for two or three people in the team. And most importantly this enables two people  to to do pair programmingwork  withoutindependently without affecting other team member&#39;s code. And if you want to pair program remotely then the Dropbox will be the ideal tool.&lt;br /&gt;
&amp;nbsp;Figure 5 shows a model with one central repository and several team members. The central repository has the stable version of the code. This is somewhat similar to a centralized model. But the link between A and B is enabled by the DVCS. If A and B needs to some pair programming they can directly push and pull the changes. This is more important, because sometimes they need sync unstable code. Of course you can do it with other centralized version control systems as well .But in that case the changes need to be emailed to the other developer.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Once we have chosen DVCS over centralized version control systems as the best option for our needs, then we need to consider which tool to use. Git and Mercurial are the well-known and widely used DVCS. Both of them are open source and have some similar functionality. Git is more complex to use rather than mercurial because it has more complex and more flexible model. Therefore mercurial is easy for someone coming from a centralized version controlling background to adapt to quickly. You may find links to good articles on git and mercurial at the references section.
 
A version controlling system for an agile team should be agile too. That means the tool should be flexible enough for the team to use as a successful version controlling and a collaboration model. Choosing the right tool for a particular job is really important but it can be difficult task as well. Because we are familiar with one tool and mastered how it can be used, we tend to be bias towards it instead of looking at how a different tool can be more productive. But if we can change our mind set for exploring the different options we have and to choose the best tools that will help us, we can improve efficiency and the effectiveness of the team.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;Reference:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;http://www.infoq.com/articles/dvcs-guide&amp;amp;num=30&lt;/li&gt;
&lt;li&gt;http://en.wikipedia.org/wiki/Comparison_of_revision_control_software&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/5413531034594283236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2013/01/version-control-for-agile-team.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/5413531034594283236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/5413531034594283236'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2013/01/version-control-for-agile-team.html' title='Version Control For An Agile Team'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6dTpY4sF-vMHrbkVYSAsVBRm8byyVA8NuYqfSEbDG3qbhzdIveKnKoxccd3WuBZceNgVpV1NK1PWD7uuEuFxB-8fn0tsD4MyAiijs5jLfOG3bZyibQGTZAPP5-PjVhtPBO1AspF6FPpvT/s72-c/Capture.PNG" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-2980474777551309401</id><published>2012-08-09T09:54:00.001+05:30</published><updated>2012-08-09T09:55:25.198+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Distributed Version Controlling"/><category scheme="http://www.blogger.com/atom/ns#" term="Mercurial"/><title type='text'>Distributed Version Controlling with Murcurial</title><content type='html'>&lt;iframe src=&quot;http://www.slideshare.net/slideshow/embed_code/13918530?hostedIn=slideshare&amp;page=upload&quot; width=&quot;476&quot; height=&quot;400&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/2980474777551309401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/08/distributed-version-controlling-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2980474777551309401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2980474777551309401'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/08/distributed-version-controlling-with.html' title='Distributed Version Controlling with Murcurial'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-3228132432255014424</id><published>2012-04-22T11:38:00.000+05:30</published><updated>2012-04-22T12:10:33.181+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="RealTimeWeb"/><category scheme="http://www.blogger.com/atom/ns#" term="Socket.io"/><title type='text'>Real Time Messaging On  Web  - Sample Using  Socket.IO and Node.Js</title><content type='html'>Socket.io enables real time synchronization across browsers while using different underlying transport methods.It uses different transport mechanisms to support multiple platforms.To understand how it works we need to get some basic principles behind socket.io .First thing is it can use several transport mechanisms like xhr-polling,xhr-multipart,htmlfile,websocket,flashsocket, jsonp-polling.The client will decide what transport method to use .To start the connection it will do a basic http hanshake and then based on client it will decide the transport method. Then it will use a lite weight protocol to communicate.&lt;br /&gt;
&lt;br /&gt;
I&#39;m doing this example on node server on windows. If you are new to Node.js it&#39;s better if you go through my previous article &lt;a href=&quot;http://codetuner.blogspot.com/2012/03/nodejs-sample-application-on-windows.html&quot;&gt;Node.JS Sample Application On Windows.&lt;/a&gt; . Here I&#39;m going to use socket.io on Node server.&lt;br /&gt;
&lt;br /&gt;
First we need to install Socket.io on Node server. For that go to your project folder and use npm command &lt;b&gt;npm install socket.io&lt;/b&gt; . It will install socket.io in to your folder as a node module.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj45NByu5zu92c8WCgwhSb1dbmj6t5HUb7AHZVpdpjBjEkhhzL2s9NSywgfREgXhWF_cXYSrhfvnc1eTH_Q9TlIloyGiFlLsmGW9kUIhXZt3_7jC2IfL2w8NG0FKtTuU8VLEF4rb7fZfsOg/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;344&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj45NByu5zu92c8WCgwhSb1dbmj6t5HUb7AHZVpdpjBjEkhhzL2s9NSywgfREgXhWF_cXYSrhfvnc1eTH_Q9TlIloyGiFlLsmGW9kUIhXZt3_7jC2IfL2w8NG0FKtTuU8VLEF4rb7fZfsOg/s400/1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now you can see a folder has been(node_modules) created in your project folder. 


&lt;br /&gt;
Then we need to have our web page. Create the Index.html page and save it in the project folder ,
&lt;br /&gt;
&lt;pre class=&quot;brush:js&quot;&gt; 
 
  &lt;head&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;h1&gt;Welcome to socket.io .....&lt;/h1&gt;
    &lt;/body&gt;
&lt;/pre&gt;



&lt;br /&gt;
Next step to create the server app to serve the HTML page , Create the Server.js with following code and save it in the project folder.
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;var app = require(&#39;http&#39;).createServer(handler)
  , io = require(&#39;socket.io&#39;).listen(app)
  , fs = require(&#39;fs&#39;)

app.listen(8012);// give a port not used by other apps

function handler(req, res) {

    fs.readFile(&#39;index.html&#39;,
  function (err, data) {
      console.log(err);
      if (err) {
          res.writeHead(500);
          return res.end(&#39;Error loading index.html&#39;);
      }

      res.writeHead(200);
      res.end(data);
  });
}

&lt;/pre&gt;
&lt;br /&gt;
So now we have all required files in project folder,
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL_56zpgwV28DPV92sy1QhyphenhyphenyatWqb4pZpOujzrFcQcxbMZgmtEivcC1OErA0NJmoRWZ3GXkVHTUBEiIwo6gu-Omz-fyxq9M786Fu1Fzm1qkwFt-wfD4CCMShl5ngiaqMf9bG8_UwsVzGi2/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;111&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL_56zpgwV28DPV92sy1QhyphenhyphenyatWqb4pZpOujzrFcQcxbMZgmtEivcC1OErA0NJmoRWZ3GXkVHTUBEiIwo6gu-Omz-fyxq9M786Fu1Fzm1qkwFt-wfD4CCMShl5ngiaqMf9bG8_UwsVzGi2/s400/3.png&quot; width=&quot;259&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Then we can run our server, Go to the folder from comman prompt and exacute command &lt;b&gt;node server.js&lt;/b&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaoUK3rYhAyjajdAdHWGQZTUliQa5b_9pRYRTqzfkARZmA-06v93TstMFufNdKgUhWLKaxx24MvLy25smsjD3PozgVulUd7Wth3EYdBvk9q_Zj5cvDgf6Rcuw2LYOozWs7LFYIyX2QUHy/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;59&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaoUK3rYhAyjajdAdHWGQZTUliQa5b_9pRYRTqzfkARZmA-06v93TstMFufNdKgUhWLKaxx24MvLy25smsjD3PozgVulUd7Wth3EYdBvk9q_Zj5cvDgf6Rcuw2LYOozWs7LFYIyX2QUHy/s400/4.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Then we can use the browser to see our &lt;b&gt;index.html&lt;/b&gt; page user the url &lt;b&gt;http://localhost:8012/&lt;/b&gt;


&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV6q3ITkDS2FH-RRNjxEcpl7PlE0iHmi8oy4v-sE8o5mjVIYf_wdIOXRhSbWVDWhLouFlTMzeGrXiDWodAfFXEeziQak7zaJwWEQZHH5bFFImJ3lpojnRdDqcC12UN99DYSycaMpeAGaxu/s1600/5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV6q3ITkDS2FH-RRNjxEcpl7PlE0iHmi8oy4v-sE8o5mjVIYf_wdIOXRhSbWVDWhLouFlTMzeGrXiDWodAfFXEeziQak7zaJwWEQZHH5bFFImJ3lpojnRdDqcC12UN99DYSycaMpeAGaxu/s400/5.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Then the important part,  integration of socket.io for real time communication, There are several reserved event for the socket.io server,

&#39;&lt;b&gt;connection&lt;/b&gt;&#39; - initial connection from a client. &lt;br /&gt;
&#39;&lt;b&gt;message&lt;/b&gt;&#39; - &quot;message&quot; is emitted when a message sent with socket.send is received. function.&lt;br /&gt;
&#39;&lt;b&gt;disconnect&lt;/b&gt;&#39;- fired when the socket disconnects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For our sample app we can use the &#39;connection&#39; event to send something on any connection , Append this code to the &lt;b&gt;Server.js&lt;/b&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;io.sockets.on(&#39;connection&#39;, function (socket) {
    socket.emit(&#39;Initialdata&#39;, { hello: &#39;world&#39; });
});

&lt;/pre&gt;
&lt;br /&gt;
And then change your client (Index.html) to communicate with socket.io server with flowing code,

&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;script src=&quot;/socket.io/socket.io.js&quot;&gt;
&lt;/script&gt;
&lt;script&gt;
   
    var socket = io.connect(&#39;http://localhost:8012&#39;);

    socket.on(&#39;InitialData&#39;, function (data) {
        alert(data.Message);
    });
  
&lt;/script&gt;



   &lt;h1&gt;
 Welcome to socket.io .....&lt;/h1&gt;
&lt;/pre&gt;
&lt;br /&gt;
Then restart the node server (Again exacute &lt;b&gt;node server.js&lt;/b&gt; command). Now you can see the alert by refreshing the web page,
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAZtd74vrWUwu1pRkyw03d4g_JIRaQi75KdhgOWzzBLRSlDF3CiNBro8WTgl1XsIVz3_CkIll3u9Ymxg1dZPgrseRmEaG_d20X0JxI9vY89_navyF2qY8IICrO44erPZ54i11Y6lD5jHqG/s1600/6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;146&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAZtd74vrWUwu1pRkyw03d4g_JIRaQi75KdhgOWzzBLRSlDF3CiNBro8WTgl1XsIVz3_CkIll3u9Ymxg1dZPgrseRmEaG_d20X0JxI9vY89_navyF2qY8IICrO44erPZ54i11Y6lD5jHqG/s400/6.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So now we have up and running socket. Our next step is to make real time communicating clients. For that we need to add a text box and a button to the client and javascripts to send the message to the server to broadcast for other clients,

&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;    &lt;script src=&quot;/socket.io/socket.io.js&quot;&gt;
&lt;/script&gt;
    &lt;script&gt;
        var socket = io.connect(&#39;http://localhost:8012&#39;);
        socket.on(&#39;InitialData&#39;, function (data) {
            //alert(data.Message);
        });

        socket.on(&#39;messageRecieve&#39;, function (data) {//receive broadcasted message from server
            AppendMessage(data.msg);
        });



        function SendMessage() {// sends the message from client to the server
            var message = document.getElementById(&#39;text&#39;).value;
            socket.emit(&#39;sendMessage&#39;, { msg: message });
            AppendMessage(message);
        }

        function AppendMessage(text) {// Appends messages to the div
            var div = document.getElementById(&#39;Messages&#39;);
            var newcontent = document.createElement(&#39;div&#39;);
            newcontent.innerHTML = text;

            div.appendChild(newcontent);
        }
    
&lt;/script&gt;


    &lt;h1&gt;

        Welcome to socket.io .....&lt;/h1&gt;
&lt;div id=&quot;Messages&quot;&gt;
&lt;/div&gt;
&lt;input id=&quot;text&quot; type=&quot;text&quot; /&gt;
    &lt;input onclick=&quot;SendMessage()&quot; type=&quot;button&quot; value=&quot;send&quot; /&gt;



&lt;/pre&gt;
Now our client is ready for sending and receiving messages. Next step is to change the server to broadcast received message from any clients to all the other clients connected. Change the server with following code,

&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;var app = require(&#39;http&#39;).createServer(handler)
  , io = require(&#39;socket.io&#39;).listen(app)
  , fs = require(&#39;fs&#39;)

app.listen(8012);

function handler(req, res) {

    fs.readFile(&#39;index.html&#39;,
  function (err, data) {
      console.log(err);
      if (err) {
          res.writeHead(500);
          return res.end(&#39;Error loading index.html&#39;);
      }

      res.writeHead(200);
      res.end(data);
  });
}

io.sockets.on(&#39;connection&#39;, function (socket) {
    console.log(&#39;Socket Created...&#39;);

    socket.emit(&#39;InitialData&#39;, { Message: &#39;Hello World !&#39; });

    socket.on(&#39;sendMessage&#39;, function (data) {
        socket.broadcast.emit(&#39;messageRecieve&#39;, data);
    });
});

&lt;/pre&gt;
We are ready with our client and the server. Restart the server again using &lt;b&gt;node server.js&lt;/b&gt; , and open two browser windows( http://localhost:8012/ ) to demonstrate multiple clients scenario ,

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhEJ9PfQYcJMpo5YB8dXwSI5ztT3AYtinyAt-0m5QB5752KI0hI0F0q4pikuWnqcMm2jgPLZbT3qBnJ4y4p_3fo3-rFDx7J_zAkQpoCMRNE2ZLngM5CLZbhcDa07CQZ_HHaIF-uuUlNHtS/s1600/7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhEJ9PfQYcJMpo5YB8dXwSI5ztT3AYtinyAt-0m5QB5752KI0hI0F0q4pikuWnqcMm2jgPLZbT3qBnJ4y4p_3fo3-rFDx7J_zAkQpoCMRNE2ZLngM5CLZbhcDa07CQZ_HHaIF-uuUlNHtS/s640/7.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/3228132432255014424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/04/real-time-web-sample-using-socketio-and.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3228132432255014424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3228132432255014424'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/04/real-time-web-sample-using-socketio-and.html' title='Real Time Messaging On  Web  - Sample Using  Socket.IO and Node.Js'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj45NByu5zu92c8WCgwhSb1dbmj6t5HUb7AHZVpdpjBjEkhhzL2s9NSywgfREgXhWF_cXYSrhfvnc1eTH_Q9TlIloyGiFlLsmGW9kUIhXZt3_7jC2IfL2w8NG0FKtTuU8VLEF4rb7fZfsOg/s72-c/1.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-8615414981950236664</id><published>2012-03-31T21:02:00.000+05:30</published><updated>2012-03-31T21:13:00.541+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="sample"/><title type='text'>Node.JS Sample Application On Windows</title><content type='html'>I am I&#39;m kind of new to&amp;nbsp;
&lt;a href=&quot;http://nodejs.org/&quot;&gt;Node.js&lt;/a&gt;&amp;nbsp;&amp;nbsp; world. I took nearly a week reading tutorials and downloading samples to say &quot;Hello World&quot; to Node.Js and to Socket.io. Finally today I have achieved it :). Let me document what I have done here before I forget all the things. Here I&#39;m going to describe the first step &lt;b&gt;running first Node server on windows&lt;/b&gt;. I will go through step by step starting from the downloading&amp;nbsp;
&lt;a href=&quot;http://nodejs.org/&quot;&gt;Node.js&lt;/a&gt;&amp;nbsp;.
&lt;br /&gt;
&lt;br /&gt;

&lt;b&gt;Download and Install &lt;a href=&quot;http://nodejs.org/&quot;&gt;Node.js&lt;/a&gt;
&lt;/b&gt;&lt;br /&gt;
We can download Node.JS server for windows from &lt;a href=&quot;http://nodejs.org/#download&quot;&gt;here&lt;/a&gt; . Nothing to configure... Just download and install it. You can check whether you have installed it correctly using command prompt. Type &lt;b&gt;node&lt;/b&gt; and press &lt;b&gt;Enter&lt;/b&gt; you will get the node prompt.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJGTfYsjmY86T8PYJE8tQ8b4yxIqMLZcWwgCQciFrJBIR8-A1r0Ia1dD_4hYmgA57i55k0gN05E2_RglBeb002AdgnSKLzeZfGQIfdv3oNeGfKktrgjDyEIB371MWyMXdCmmKd2Nzl7-F/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;134&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJGTfYsjmY86T8PYJE8tQ8b4yxIqMLZcWwgCQciFrJBIR8-A1r0Ia1dD_4hYmgA57i55k0gN05E2_RglBeb002AdgnSKLzeZfGQIfdv3oNeGfKktrgjDyEIB371MWyMXdCmmKd2Nzl7-F/s640/1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/br&gt;
&lt;b&gt;Host the sample script&lt;/b&gt; &lt;br /&gt;This is the sample code for &amp;nbsp;hello world server.&lt;br /&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;var http = require(&#39;http&#39;);
http.createServer(function (req, res) {
  res.writeHead(200, {&#39;Content-Type&#39;: &#39;text/plain&#39;});
  res.end(&#39;Hello World\n&#39;);
}).listen(1337, &#39;127.0.0.1&#39;);
console.log(&#39;Server running at http://127.0.0.1:1337/&#39;);
&lt;/pre&gt;
&lt;br /&gt;
Create new text file and save above code as &lt;b&gt;sample.js&lt;/b&gt;

&lt;/br&gt;&lt;/br&gt;

 &lt;b&gt;Run Sample Server&lt;/b&gt;&lt;br /&gt;

Then go to your folder (using command prompt) which has the &lt;b&gt;sample.js&lt;/b&gt; file and execute it using node by executing command &lt;b&gt;node sample.js&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjrHOAz-mCB1zX0aToYaCy2MfGuNIL-3M1bRohgiQtCKsuvr-r-dyEGrAr7QgeFa2cugDPaYnFkGWAaYeeWGqqOAbFdBqK42XBJS2BNMf7XOqtFaNmhjuv9iqubLqAGhrmvgnEpZOpZfAf/s1600/2png.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;108&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjrHOAz-mCB1zX0aToYaCy2MfGuNIL-3M1bRohgiQtCKsuvr-r-dyEGrAr7QgeFa2cugDPaYnFkGWAaYeeWGqqOAbFdBqK42XBJS2BNMf7XOqtFaNmhjuv9iqubLqAGhrmvgnEpZOpZfAf/s640/2png.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;

&lt;/br&gt;
&lt;b&gt;Access It Using Browser&lt;/b&gt;

&lt;/br&gt;
Open your browser and enter the address we have given in the sample.js file.&lt;br /&gt;

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghmBFOQgx3vcwxbFOTZ1qN0a3mRuj6KqOG5V6mbZz95usHZ1wI8LK70m8jsox2vxqVIRqV3SlvJ8c3s5geqL3M50fABUYfx4iWZlGt79z9xDZi8LyivCO8mfFWnczFMVEsDZu8Yc-qRNFU/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;120&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghmBFOQgx3vcwxbFOTZ1qN0a3mRuj6KqOG5V6mbZz95usHZ1wI8LK70m8jsox2vxqVIRqV3SlvJ8c3s5geqL3M50fABUYfx4iWZlGt79z9xDZi8LyivCO8mfFWnczFMVEsDZu8Yc-qRNFU/s640/3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;

That&#39;s It ! &lt;br /&gt;
I will go more detail in to node.js and socket.io in the next post :).</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/8615414981950236664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/03/nodejs-sample-application-on-windows.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8615414981950236664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8615414981950236664'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/03/nodejs-sample-application-on-windows.html' title='Node.JS Sample Application On Windows'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJGTfYsjmY86T8PYJE8tQ8b4yxIqMLZcWwgCQciFrJBIR8-A1r0Ia1dD_4hYmgA57i55k0gN05E2_RglBeb002AdgnSKLzeZfGQIfdv3oNeGfKktrgjDyEIB371MWyMXdCmmKd2Nzl7-F/s72-c/1.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-1556847374992770283</id><published>2012-03-26T21:27:00.000+05:30</published><updated>2012-03-30T20:54:48.141+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="State Machine"/><category scheme="http://www.blogger.com/atom/ns#" term="WCF"/><category scheme="http://www.blogger.com/atom/ns#" term="WF4"/><title type='text'>Workflow Foundation 4 State Machine  as a WCF Service</title><content type='html'>State machine workflow which we had in WF3.5 was not supported in WF4 (in .Net Framework4). But it released with &lt;a href=&quot;http://www.microsoft.com/download/en/details.aspx?id=11705&quot;&gt;.net framework 4 platform update 1&lt;/a&gt; . State machine is very helpful to model long running workflows with higher external interactions. As an example in a long running order processing system where it needs several user inputs and approvals from external users. &lt;/br&gt;

There are several examples state machines in MSDN which describe the state machine well. But here I&#39;m going to expose the state machine as a service.
My example is a simple order processing system which has some human interaction to approve orders.



&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC8RwcR5RrvIOtpPEBUQzj2oIn1tF8ozpVFdVMv76WgD3maj9mEZFF8Zwm4nYiebMBx3X4PtGSbATVZ-0L_082qACXhhPK1NLwYWg-KAwhkVjc7-tX8u9Gc9MxHFfM-t06LgHL113HBZH-/s1600/11.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;360&quot; width=&quot;550&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC8RwcR5RrvIOtpPEBUQzj2oIn1tF8ozpVFdVMv76WgD3maj9mEZFF8Zwm4nYiebMBx3X4PtGSbATVZ-0L_082qACXhhPK1NLwYWg-KAwhkVjc7-tX8u9Gc9MxHFfM-t06LgHL113HBZH-/s400/11.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;/br&gt;
In this workflow there are three states(OrderRecived, To be Approved , Finished) and three triggers (Pay,IssueWithOrder,Resolve).
We can create new order by giving an orderId and some amount.Then to complete the order we can pay using &lt;b&gt;Pay&lt;/b&gt; trigger. Or else if there any issues with the order we can use another WCF call to workflow to change the state(to restrict pay) using  &lt;b&gt;IssueWithOrder&lt;/b&gt; trigger. The &lt;b&gt;Resolve&lt;/b&gt; trigger is used to resolve the issues when they have any issues.&lt;/br&gt;

&lt;/br&gt;
&lt;h2&gt;&lt;a href=&quot;https://wfstatemachineserv.codeplex.com/releases&quot;&gt;Download Sample Code&lt;/a&gt; &lt;/h2&gt;
&lt;/br&gt;

&lt;/br&gt;To expose the triggers as services what we need to do is to use send receive activities in triggers. 

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAce8_FTfW2k1Itokc_ZEr0ryBLyeHjMxLJ2RUGxJoXVA-bxk3uKTkRM5dAtX710N1Bo3X6Vcxn8LkSx_QG76YFAeJsZt4A2ydssGkkOOhQj_wG6eYQ-g3ZsB4duz0f20GjTZz1W9TDRiI/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;389&quot; width=&quot;500&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAce8_FTfW2k1Itokc_ZEr0ryBLyeHjMxLJ2RUGxJoXVA-bxk3uKTkRM5dAtX710N1Bo3X6Vcxn8LkSx_QG76YFAeJsZt4A2ydssGkkOOhQj_wG6eYQ-g3ZsB4duz0f20GjTZz1W9TDRiI/s400/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;



And the other important thing is correlation handling. Because when we need to call a already instantiated workflow instance we should have some identity to call the correct workflow instance. So in my example the correlation handler is the orderId. Because it is unique for an order which is unique for a workflow instance.   So I have a state machine level correlation handler which uses the order id to correlate and each and every WCF call the workflow instance will use that variable as the correlation handler.&lt;/br&gt;



You can download my sample code &lt;a href=&quot;https://wfstatemachineserv.codeplex.com/releases&quot;&gt; here.&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/1556847374992770283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/03/workflow-foundation-4-state-machine-as.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1556847374992770283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1556847374992770283'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/03/workflow-foundation-4-state-machine-as.html' title='Workflow Foundation 4 State Machine  as a WCF Service'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC8RwcR5RrvIOtpPEBUQzj2oIn1tF8ozpVFdVMv76WgD3maj9mEZFF8Zwm4nYiebMBx3X4PtGSbATVZ-0L_082qACXhhPK1NLwYWg-KAwhkVjc7-tX8u9Gc9MxHFfM-t06LgHL113HBZH-/s72-c/11.png" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-2982831847628988282</id><published>2012-02-19T16:17:00.001+05:30</published><updated>2012-02-19T16:20:17.879+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AppFabric"/><category scheme="http://www.blogger.com/atom/ns#" term="IIS"/><category scheme="http://www.blogger.com/atom/ns#" term="WF4"/><title type='text'>Workflow Foundation 4 App-fabric Tracking Variables</title><content type='html'>&lt;a href=&quot;http://msdn.microsoft.com/en-us/windowsserver/ee695849&quot;&gt;Windows Server AppFabric&lt;/a&gt; provides a great set of tools and options to manage, scale and monitor application hosted in IIS. Especially for windows workflow applications AppFabric is a required tool to monitor , control and to scale the work-flows.
&lt;br/&gt;

&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhW8-rUuKNJIcgYqHzvwTxQQ49vIDZd04-iWwZTO5k2tvNk7teEp74kK8g9qyCqycBSvFq81fBmzn-J_c_CehT9nfPd4cwgC-5rQ_bGhQsJduCdL1nJOgeK6cxaiGjh7HBDkpmD86NtCsM/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;340&quot; width=&quot;650&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhW8-rUuKNJIcgYqHzvwTxQQ49vIDZd04-iWwZTO5k2tvNk7teEp74kK8g9qyCqycBSvFq81fBmzn-J_c_CehT9nfPd4cwgC-5rQ_bGhQsJduCdL1nJOgeK6cxaiGjh7HBDkpmD86NtCsM/s400/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
&lt;a href=&quot;http://channel9.msdn.com/Shows/Workflow-TV/endpointtv-WF4--AppFabric-Contoso-HR-Sample&quot;&gt;AppFabric Contoso HR Sample&lt;/a&gt; is a good tutorial to start with WF with AppFabric. In this post I&#39;m going to describe how to add tracking variables to the Appfabric  event log. This is a huge requirement when we are dealing with WorkFlows. Because in events written by AppFabrric contains a Guid to identify the workflow instance. But it is better if we can write our own id of the workflow in to the tracked events. &lt;br/&gt;&lt;br/&gt;
Let&#39; say as an example in a order processing system. In this case the order we want to track the worrkflow instances by the order id. So here is how I did it,
&lt;br/&gt;&lt;br/&gt;
First we need to define new tracking profile  in the  &lt;b&gt;web config system.serviceModel &lt;/b&gt; section.
&lt;br/&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
&lt;tracking&gt;
      &lt;profiles&gt;
        &lt;trackingProfile name=&quot;My Tracking Profile&quot;&gt;
          
          &lt;workflow activityDefinitionId=&quot;*&quot;&gt;
           
            &lt;workflowInstanceQueries&gt;
              &lt;workflowInstanceQuery&gt;
                &lt;states&gt;
                  &lt;state name=&quot;*&quot; /&gt;
                &lt;/states&gt;
              &lt;/workflowInstanceQuery&gt;
            &lt;/workflowInstanceQueries&gt;
            &lt;activityStateQueries&gt;
             
              &lt;activityStateQuery activityName=&quot;*&quot;&gt;
                &lt;states&gt;
                  &lt;state name=&quot;*&quot; /&gt;
                &lt;/states&gt;
                &lt;variables&gt;
                  &lt;variable name=&quot;OrderId&quot; /&gt;
                &lt;/variables&gt;
              &lt;/activityStateQuery&gt;

              &lt;activityStateQuery activityName=&quot;Process New Order&quot;&gt;
                &lt;states&gt;
                  &lt;state name=&quot;Closed&quot; /&gt;
                &lt;/states&gt;
                &lt;variables&gt;
                  &lt;variable name=&quot;StatusText&quot; /&gt;
                  &lt;variable name=&quot;NewPurchaseOrder&quot; /&gt;
                  &lt;variable name=&quot;PurchaseTotal&quot; /&gt;
                  
                &lt;/variables&gt;
              &lt;/activityStateQuery&gt;

            &lt;/activityStateQueries&gt;
            &lt;faultPropagationQueries&gt;
              &lt;faultPropagationQuery faultSourceActivityName=&quot;*&quot; faultHandlerActivityName=&quot;*&quot; /&gt;
            &lt;/faultPropagationQueries&gt;
            &lt;bookmarkResumptionQueries&gt;
              &lt;bookmarkResumptionQuery name=&quot;*&quot; /&gt;
            &lt;/bookmarkResumptionQueries&gt;
            &lt;customTrackingQueries&gt;
              &lt;customTrackingQuery name=&quot;*&quot; activityName=&quot;*&quot; /&gt;
            &lt;/customTrackingQueries&gt;
          &lt;/workflow&gt;
        &lt;/trackingProfile&gt;

      &lt;/profiles&gt;
    &lt;/tracking&gt;
&lt;/pre&gt;
&lt;br/&gt;
We can create several queries as we want. It may be queries for all activities or some specific activity. The query with   activityName=&quot;*&quot; will write orderid to the event log in all activities of the activity while query with activityName=&quot;Process New Order&quot; will write several other variables in &quot;Process New Order&quot; activity to the events.
&lt;br/&gt;
To enable this tracking profile for the service we need to go to the Appofabric configuration of the relevant service.
Go to AppFabric dashboard of the  &lt;b&gt; service -&gt; Services -&gt;Select the service and click Configure &lt;/b&gt;. 
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvWo47T4sD8nV70myTal8_krbLMt8LhtHzHwoHf6ZePorX8S6FTmTwbC19UpuwXYHQ25b0l4XTMDLxJrtwgZ5Fqo0bnWwK0Jdiiq_Bh6LLRMo6fNJlq8Gu-0zgFKt3CP2eomyuXiJCzLAW/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;250&quot; width=&quot;650&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvWo47T4sD8nV70myTal8_krbLMt8LhtHzHwoHf6ZePorX8S6FTmTwbC19UpuwXYHQ25b0l4XTMDLxJrtwgZ5Fqo0bnWwK0Jdiiq_Bh6LLRMo6fNJlq8Gu-0zgFKt3CP2eomyuXiJCzLAW/s400/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;



And then go to &lt;b&gt;Monitoring -&gt; Configure  &lt;/b&gt;, From the dropdown menu  select our tracking profile (My Tracking Profile)
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9LrUTW1xFuUncSAPUZ0FJFrdcv9akDP7PdBjI1_xbMt3c4B4dq8bmWVfbOhQ0lbwdZnSX3wFkkKY0V6mSmo1vSfKWYyWhFO3I2t_fLulTWPjLsFoZYhhXiMF9JEKQKG5tTeTcGo3Cw2oM/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;350&quot; width=&quot;650&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9LrUTW1xFuUncSAPUZ0FJFrdcv9akDP7PdBjI1_xbMt3c4B4dq8bmWVfbOhQ0lbwdZnSX3wFkkKY0V6mSmo1vSfKWYyWhFO3I2t_fLulTWPjLsFoZYhhXiMF9JEKQKG5tTeTcGo3Cw2oM/s400/3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;




Then when the workflow is running we can see the tracked events with our our variables in tracked variables section.</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/2982831847628988282/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/02/workflow-foundation-4-app-fabric.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2982831847628988282'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2982831847628988282'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/02/workflow-foundation-4-app-fabric.html' title='Workflow Foundation 4 App-fabric Tracking Variables'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhW8-rUuKNJIcgYqHzvwTxQQ49vIDZd04-iWwZTO5k2tvNk7teEp74kK8g9qyCqycBSvFq81fBmzn-J_c_CehT9nfPd4cwgC-5rQ_bGhQsJduCdL1nJOgeK6cxaiGjh7HBDkpmD86NtCsM/s72-c/1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-1271327516727862541</id><published>2012-01-24T21:22:00.000+05:30</published><updated>2012-02-14T00:59:14.714+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="JSON"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC3"/><title type='text'>Converting .Net Object In To JSON Object ASP.Net MVC</title><content type='html'>If you want to convert your .Net object in to a JSON object in the view the first thing you can use is to use System.Web.Script.Serialization.JavaScriptSerializer  object and convert it in to JSON. 

&lt;pre class=&quot;brush: csharp&quot;&gt;@{
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
//....

&amp;lt;script&amp;gt;

var s = @serializer.Serialize(Model);
&amp;lt;/script&amp;gt;

}
&lt;/pre&gt;
&lt;br /&gt;
This is MVC3 Razor syntax. The problem here is in the @ sign it will again HTML encode the JSON object which lead you to flowing error.

&lt;pre class=&quot;brush: csharp&quot;&gt;var s = { &quot;Name&quot;:&quot;a&quot;,&quot;Id&quot;:1};
Create:228Uncaught SyntaxError: Unexpected token &amp;amp;
&lt;/pre&gt;
&lt;br /&gt;
To avoid this we can use HTML.Raw() helper method like below.

&lt;pre class=&quot;brush: csharp&quot;&gt;var s = @HTML.Raw(serializer.Serialize(Model));
&lt;/pre&gt;
&lt;br /&gt;
The easiest and the most reusable way of doing it is to write a helper method link this,

&lt;pre class=&quot;brush: csharp&quot;&gt;public static MvcHtmlString ToJson(this HtmlHelper html, object obj)
{
  JavaScriptSerializer serializer = new JavaScriptSerializer();
  return MvcHtmlString.Create(serializer.Serialize(obj));
}
&lt;/pre&gt;
&lt;br /&gt;
And then in the view we can use this helper method</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/1271327516727862541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2012/01/converting-net-object-in-to-json-object.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1271327516727862541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/1271327516727862541'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2012/01/converting-net-object-in-to-json-object.html' title='Converting .Net Object In To JSON Object ASP.Net MVC'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-7003059913841028094</id><published>2011-11-08T18:10:00.000+05:30</published><updated>2012-02-14T10:44:03.576+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Aja"/><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC3"/><title type='text'>ASP.Net MVC Submit Collection Of Models</title><content type='html'>If you are using ASP.Net MVC for your presentation layer there are situations where you want to submit collection of view models. As an example lets say you have view models like this,&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Person&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Id : int&lt;/li&gt;
&lt;li&gt;Name : string&lt;/li&gt;
&lt;li&gt;Addresses : Ilist&lt;address&gt;
&lt;/address&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;u&gt;Address&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Id : Int&lt;/li&gt;
&lt;li&gt;Line1 : string&lt;/li&gt;
&lt;li&gt;City : string&lt;/li&gt;
&lt;li&gt;Type : string&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
The Person view model has a&amp;nbsp;collection&amp;nbsp;of addresses.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Then you need to have an edit view for the person to edit all the details of the person view model. In the edit view there will be code like this to display current addresses to the user to edit/ add new or delete .&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;
@model YourNameSpace.Models.Person
@using (Html.BeginForm(&quot;Edit&quot;, &quot;Person&quot;, FormMethod.Post, new { enctype = &quot;multipart/form-data&quot;, id = &quot;personEditForm&quot; }))
{
///.................
               @foreach (var address in Model.Addresses)
                   {
                        @Html.HiddenFor(m,address.Id);
                        @Html.EditorForl(m, address.Line1);
                           //............
                   }
//....................................
}
&lt;/pre&gt;

&lt;div&gt;
This will&amp;nbsp;generate HTML for the address Id &amp;nbsp;and address Line1 like this,&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;

&lt;pre class=&quot;brush: xml&quot;&gt;…..
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;1&quot; name=&quot;address.Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;12, 1st lane&quot; name=&quot;address.Line1&quot;&gt;
…..
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;2&quot; name=&quot;address.Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;23, dark street&quot; name=&quot;address.Line1&quot;&gt;
……

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Because there are several inputs with same name we can&#39;t submit all values in the form
For that the names should be like  &quot;Addresses[0].Line1&quot; as below.
&lt;pre class=&quot;brush: csharp&quot;&gt;
…..
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;1&quot; name=&quot;Addresses[0].id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;12, 1st lane&quot; name=&quot;Addresses[0].Line1&quot;&gt;
…..
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;2&quot; name=&quot;Addresses[1].Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;23, dark street&quot; name=&quot;Addresses[1].Line1&quot;&gt;
……

&lt;/pre&gt;
&lt;br /&gt;

&lt;br/&gt;
Of course you can achieve this by creating an editor template for address. But  you will be in  trouble  when you delete some address in the middle of the sequence. And also if you have more properties like address for the person view model it will abuse your template folder.
&lt;br/&gt;
This is the solution which I created with help of jQuery.  I have written a jQuery function to reset all the names of those collection properties . To get the collection name I have added a wrapper div for each address . Before reset the names the HTML is like this,
&lt;br/&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;
…..
&lt;div class=&quot;collection&quot;  propertyName=&quot;Addresses&quot;&gt;
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;1&quot; name=&quot;address.Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;12, 1st lane&quot; name=&quot;address.Line1&quot;&gt;
&lt;/div&gt;
…..
&lt;div class=&quot;collection&quot;  propertyName=&quot;Addresses&quot;&gt;
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;2&quot; name=&quot;address.Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;23, dark street&quot; name=&quot;address.Line1&quot;&gt;
&lt;/div&gt;
……
&lt;/pre&gt;

&lt;br/&gt;

And then I added this  jQuery to onClick event to reset names before submit,

&lt;pre class=&quot;brush: csharp&quot;&gt;
$(&quot;#submitButton&quot;).click(fuction(){
 $(&#39;.collection&#39;).each(function (index, domEle) {
           var property=$(this).attr(&#39;propertyName&#39;);
             $(this).children(&#39;div&#39;).each(function (index, domEle) {
                 $(&#39;input,select&#39;,$(this)).each(function (){
                    var oldName;
                
                    var name= $(this).attr(&#39;name&#39;)+&#39;&#39;;
                    var i=  name.indexOf(&#39;]&#39;);
                    if(i&gt;0){
                         oldName= name.substr(i+2);
                     }else {
                         oldName=  $(this).attr(&#39;name&#39;);
                         
                     }
                     $(this).attr(&#39;name&#39;,property+&#39;[&#39;+index+&#39;].&#39;+  oldName);
                     $(this).next(&#39;span&#39;).attr(&#39;name&#39;,property+&#39;[&#39;+index+&#39;].&#39;+  oldName);// need to change the names of validations messages too.
                     $(this).next(&#39;span&#39;).attr(&#39;data-valmsg-for&#39;,property+&#39;[&#39;+index+&#39;].&#39;+  oldName);
                });
             });
     });   
});

&lt;/pre&gt;



&lt;br/&gt;
&lt;br/&gt;
After reeting the names the HTML will be like this,


&lt;pre class=&quot;brush: xml&quot;&gt;
…..
&lt;div class=&quot;collection&quot;  propertyName=&quot;Addresses&quot;&gt;
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;1&quot; name=&quot;Addresses[0].id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;12, 1st lane&quot; name=&quot;Addresses[0].Line1&quot;&gt;
&lt;/div&gt;
…..
&lt;div class=&quot;collection&quot;  propertyName=&quot;Addresses&quot;&gt;
&lt;input  id=&quot;address_Id&quot; type=&quot;hidden&quot; value=&quot;2&quot; name=&quot;Addresses[1].Id&quot;&gt;
&lt;input  id=&quot;address_Line1&quot;  type=&quot;hidden&quot; value=&quot;23, dark street&quot; name=&quot;Addresses[1].Line1&quot;&gt;
&lt;/div&gt;
……
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/7003059913841028094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/11/aspnet-mvc-submit-collection-of-models.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/7003059913841028094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/7003059913841028094'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/11/aspnet-mvc-submit-collection-of-models.html' title='ASP.Net MVC Submit Collection Of Models'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-5066244342972469565</id><published>2011-10-23T09:24:00.000+05:30</published><updated>2012-02-14T11:31:48.291+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Client Validation"/><category scheme="http://www.blogger.com/atom/ns#" term="Dyanamic"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC3"/><category scheme="http://www.blogger.com/atom/ns#" term="Validation"/><title type='text'>ASP.Net MVC Client Validation For Dynamically Added Form</title><content type='html'>This is how I have  implemented the client side validation with MVC3 client side validation with JQuery validation plugin. The requirement was to create a model dialog with a form which is loaded via an Ajax request to the server.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Enable client validation in web.config&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
We need to enable client side validation in web.config application settings section like thism&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt; 
 &amp;lt;appSettings&amp;gt;
          &amp;lt;add key=&quot;ClientValidationEnabled&quot; value=&quot;true&quot;/&amp;gt;
        &amp;lt;add key=&quot;UnobtrusiveJavaScriptEnabled&quot; value=&quot;true&quot;/&amp;gt;
 &amp;lt;/appSettings&amp;gt;
    
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; 2 The form&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;In your form you need to have a FormContext otherwise it will not&amp;nbsp;generate&amp;nbsp;validation attributes. &amp;nbsp;If the&amp;nbsp;FormContext is null we need to create a new FormContext &amp;nbsp;like this in your view.
&lt;pre class=&quot;brush: csharp&quot;&gt; 
@{using (Html.BeginForm(&quot;Create&quot;, &quot;Person&quot;, FormMethod.Post)
  {
      if (this.ViewContext.FormContext == null)
      {
          this.ViewContext.FormContext = new FormContext();
      }
    // .....
  }
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b&gt;3 Phrase validation attributes&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;Then after the ajax request we need to phrase validation attributes using JQuery like this,&amp;lt;br /&amp;gt;
&lt;pre class=&quot;brush: csharp&quot;&gt; 
$.get(&quot;@Url.Action(&quot;Create&quot;, &quot;Person&quot;)&quot;, null, function (data) {
         $(&#39;#yourDivId&#39;).html(data);
         $(&quot;form&quot;).removeData(&quot;validator&quot;);
         $(&quot;form&quot;).removeData(&quot;unobtrusiveValidation&quot;);
        $.validator.unobtrusive.parse(&quot;form&quot;);          
   });
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/5066244342972469565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/10/aspnet-mvc-client-validation-for.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/5066244342972469565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/5066244342972469565'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/10/aspnet-mvc-client-validation-for.html' title='ASP.Net MVC Client Validation For Dynamically Added Form'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-2251895640072870744</id><published>2011-10-22T19:54:00.000+05:30</published><updated>2011-10-23T09:26:31.479+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AutoComplete"/><category scheme="http://www.blogger.com/atom/ns#" term="Customized"/><category scheme="http://www.blogger.com/atom/ns#" term="Grouped"/><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><title type='text'>Creating Categorized/Grouped Autocomplete Menu with JQuery</title><content type='html'>&lt;a href=&quot;http://jqueryui.com/demos/autocomplete/#default&quot; target=&quot;_blank&quot;&gt;JQuery &lt;/a&gt;has given you a nice extendable library to create auto complete. But what if you want to customize it to have something like Facebook search autocomplete menu. &amp;nbsp;Here I have gathered&amp;nbsp;several&amp;nbsp;features of JQuery to make this customization. Here is my JQuery with ASP.net MVC3 but you can use whatever the backend which you can return a array of Json objects like this,&lt;br /&gt;
Here is my Search action in SearchController&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;textarea cols=&quot;80&quot; disabled=&quot;yes&quot; rows=&quot;25&quot;&gt; 


 public string Search(string term)
  {   
     IList searchResultViewModels = new List();  
// do your search logic here, for now i&#39;m adding some dummy resuts like below,

  searchResultViewModels.Add(new SearchResultViewModel { Id = 1, ImageId = 2, Name = &quot;test&quot;, SearchResultType = SearchResultType.People });
  searchResultViewModels.Add(new SearchResultViewModel { Id = 2, ImageId = 3, Name = &quot;testsdsd&quot;, SearchResultType = SearchResultType.People });
  searchResultViewModels.Add(new SearchResultViewModel { Id = 3, ImageId = 4, Name = &quot;FFaa&quot;, SearchResultType = SearchResultType.Companies });
  searchResultViewModels.Add(new SearchResultViewModel { Id = 4, ImageId = 5, Name = &quot;Teset&quot;, SearchResultType = SearchResultType.Companies });

  return Json(searchResultViewModels);
 }


 &lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is my JQuery code,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;textarea cols=&quot;80&quot; disabled=&quot;yes&quot; rows=&quot;60&quot;&gt; 

 $(document).ready(function () {  
     //To override the functionality of _renderMenu to have a categorized menu
    $.widget( &quot;custom.catcomplete&quot;, $.ui.autocomplete, {
  _renderMenu: function( ul, items ) {
   var self = this,
    currentCategory = &quot;&quot;;
   $.each( items, function( index, item ) {
    if ( item.SearchResultType != currentCategory ) {
     ul.append( &quot;&amp;lt;li class=&#39;title_sr_re&#39;&amp;gt;&quot; + item.SearchResultType + &quot;&amp;lt;/li&amp;gt;&quot; );
     currentCategory = item.SearchResultType;
    }
    self._renderItem( ul, item );
   });
  }
 });

 

$(&#39;#txtSearch&#39;).each(function() {
//this is to implement the  default text in the search textbox
              $.data(this, &#39;default&#39;, this.value);
              $.data(this, &#39;defaultColor&#39;, &quot;black&quot;);
              $(this).css(&quot;color&quot;,&quot;Gray&quot;);
             
        })
        . focus(function() {
             if (!$.data(this, &#39;edited&#39;)) {
                  $(this).css(&quot;color&quot;,  $.data(this, &#39;defaultColor&#39;));
                  this.value = &quot;&quot;;
                  
             }
        })
        .change(function() {//For the default value in search
             $.data(this, &#39;edited&#39;, this.value != &quot;&quot;);
        })
        .blur(function() {//For the default value in search 
           if (!$.data(this, &#39;edited&#39;)) {
                $(this).val(  $.data(this, &#39;default&#39;));
               $(this).css(&quot;color&quot;,&quot;Gray&quot;);          
           }
         
       })
       .catcomplete({
            minLength: 0,
            selectFirst: true,
            source: &quot;@Url.Action(&quot;Search&quot;, &quot;Search&quot;)&quot;,// I am using MVC3 here ,you can give your own URL which returns
                                                                         //Json objects
           
            select: function (event, ui) { // you can handle the select event of the autocomplete (I&#39;m redirecting to another URL here)
                          location.href=&#39;@Url.Action(&quot;ContactProfile&quot;, &quot;Contact&quot;)&#39; +(&#39;?profileId=&#39;)+ui.item.Id;
                return false;
            },
            open: function(event, ui) {
                var autocomplete = $( this ).data( &quot;catcomplete&quot; ),
         menu = autocomplete.menu;
              //to select first item in the autocomplete (then you can press enter to select it)
                menu.activate( $.Event({ type: &quot;mouseenter&quot; }), menu.element.children().first().next());
                return false;
                       
             }
        }).data(&quot;catcomplete&quot;)._renderItem = function (ul, item) {//override renderItem function to customize menu
           var term=$(&#39;#txtSearch&#39;).val();
           var action=&#39;yourImageUrl;
           return $(&quot;&amp;lt;li class=\&quot;listItem\&quot; &amp;gt;&amp;lt;/li&amp;gt;&quot;)
    .data(&quot;item.autocomplete&quot;, item)
    .append(&quot;&amp;lt;a&amp;gt;&quot;+ &quot;&amp;lt;img src=&#39;&quot;+action+&quot;?thumbnailId=&quot;+item.ImageId +&quot;&#39;&amp;gt;&amp;lt;/img&amp;gt;&quot; + item.Name.replace(new RegExp(&#39;(&#39; + item.Term + &#39;)&#39;, &#39;gi&#39;), &quot;&amp;lt;b&amp;gt;$1&amp;lt;/b&amp;gt;&quot;)  + &quot;&amp;lt;/a&amp;gt;&quot;)
                   .appendTo(ul);
  };
       
    });
 &lt;/textarea&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/2251895640072870744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/10/creating-categorizedgrouped.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2251895640072870744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2251895640072870744'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/10/creating-categorizedgrouped.html' title='Creating Categorized/Grouped Autocomplete Menu with JQuery'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-9200127124829628901</id><published>2011-09-19T10:44:00.000+05:30</published><updated>2011-09-19T10:45:47.166+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="CodeCoverage"/><category scheme="http://www.blogger.com/atom/ns#" term="Jenkins"/><category scheme="http://www.blogger.com/atom/ns#" term="MSTest"/><category scheme="http://www.blogger.com/atom/ns#" term="NCover"/><category scheme="http://www.blogger.com/atom/ns#" term="Report"/><title type='text'>Convert MSTest code covarage results in to XML And view through Jenkins</title><content type='html'>If you are using Jenkins as your CI for a Net project it is not easy to publish code coverage results.In Jenkins without tools such as NCover wich is costly. Instead of this you can  do this your own way.&lt;br /&gt;
First you need to convert MSTest results in to XML and then to HTML using xstl  to publish it as an HTML report in Jenkins. &lt;br /&gt;
&lt;b&gt;Step 1&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
GO to your test local.settings file in visual studio and set it to display the code coverage results an add your required targeted dll&#39;s. This is same as configuring visual studio to show the test results and code coverage.&lt;br /&gt;
Make sure you have added the test settings file to your version controlling system then it will be in the working space of the jenkins.&lt;br /&gt;
Then &lt;b&gt;set path to the MSTest.exe&lt;/b&gt;&lt;br /&gt;
it may be in your  &lt;your folder=&quot;&quot; programs=&quot;&quot;&gt;\Microsoft Visual Studio 10.0\Common7\IDE folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 2&lt;/b&gt;&lt;br /&gt;
 Add a windows batch command to run MSTest (after running ms build) and to generate test results file (“reults.trx”) and Coverage report (“data.coverage”) &lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;del results.trx &lt;br /&gt;
mstest   /testcontainer:Example\TestProject1\bin\debug\TestProject1.dll /resultsfile:results.trx /testsettings:Example\local.testsettings  &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This will generate a code coverage result in binary format (data.coverage)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 3&lt;/b&gt;&lt;br /&gt;
write a console app to convert binary data.coverage file in to a XML and then it to HTML by xslt  and run it after adding windows batch command in jenkins. Here is the example code for console app. Make sure you have add reference to&lt;b&gt; Microsoft.VisualStudio.Coverage.Analysis.dll&lt;/b&gt;  which you can find in the  &lt;your folder=&quot;&quot; programs=&quot;&quot;&gt;\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies folder. And copy &lt;b&gt;Microsoft.VisualStudio.Coverage.Symbols.dll &lt;/b&gt;to your bin directory which is also in same folder.&lt;br /&gt;
&lt;/your&gt;&lt;/your&gt;&lt;br /&gt;
&lt;textarea cols=&quot;70&quot; disabled=&quot;yes&quot; rows=&quot;30&quot;&gt; 

static void Main(string[] args)
        {
          
           string wspath= Environment.CurrentDirectory.ToString();

           Regex isString = new Regex(&quot;([&#39;\&quot;]?)[a-zA-Z]*\\1$&quot;);
           CoverageInfo coverage = CoverageInfo.CreateFromFile(wspath+@&quot;\&quot;+args[0]+@&quot;\in\&quot;+Environment.MachineName+@&quot;\&quot; + &quot;data.coverage&quot;);

            DataSet data = coverage.BuildDataSet(null);


            string xml = data.GetXml();


            XmlDocument xmlDocument=new XmlDocument();
            xmlDocument.LoadXml(xml);

           
            XslTransform myXslTransform = new XslTransform();
            XmlTextWriter writer = new XmlTextWriter(wspath + @&quot;\Report\coverage.htm&quot;, null);
            myXslTransform.Load(wspath + @&quot;\style.xslt&quot;);
            myXslTransform.Transform(xmlDocument, null, writer);
    
            writer.Flush();
            writer.Close();
         
        

        }
&lt;/textarea&gt;
&lt;your folder=&quot;&quot; programs=&quot;&quot;&gt;&lt;your folder=&quot;&quot; programs=&quot;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code of the style.xslt file&lt;/your&gt;&lt;/your&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea cols=&quot;70&quot; disabled=&quot;yes&quot; rows=&quot;70&quot;&gt; 
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&amp;gt;
   &amp;lt;xsl:output method=&quot;html&quot; indent=&quot;yes&quot;/&amp;gt; 
   &amp;lt;xsl:template match=&quot;/&quot; &amp;gt;
      &amp;lt;html&amp;gt;
         &amp;lt;head&amp;gt;
            &amp;lt;style type=&quot;text/css&quot;&amp;gt;
               th {
               background-color:#dcdcdc;
               border:solid 1px #a9a9a9;
               text-indent:2pt;
               font-weight:bolder;
               }
               #data {
               text-align: center;
               }
            &amp;lt;/style&amp;gt;
			 
            &amp;lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;  &amp;gt;
        
		  function CreateJavescript(){
		  
		  var fileref=document.createElement(&#39;script&#39;);
          fileref.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);
          fileref.setAttribute(&quot;src&quot;, &quot;script1.js&quot;);
		   document.getElementsByTagName(&quot;head&quot;)[0].appendChild(fileref);
		  }

		  
            &amp;lt;/script&amp;gt;
		
            &amp;lt;title&amp;gt;Code Coverage Report&amp;lt;/title&amp;gt;
         &amp;lt;/head&amp;gt;
         &amp;lt;body onload=&#39;CreateJavescript()&#39; &amp;gt;
            &amp;lt;h1&amp;gt;Code Coverage Report&amp;lt;/h1&amp;gt;
            &amp;lt;table border=&quot;1&quot;&amp;gt;
               &amp;lt;tr&amp;gt;
                  &amp;lt;th colspan=&quot;3&quot;&amp;gt;&amp;lt;/th&amp;gt;
                  &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                  &amp;lt;th&amp;gt;Blocks Covered&amp;lt;/th&amp;gt;
                  &amp;lt;th&amp;gt;Blocks Not Covered&amp;lt;/th&amp;gt;
                  &amp;lt;th&amp;gt;Coverage&amp;lt;/th&amp;gt;
               &amp;lt;/tr&amp;gt;
               &amp;lt;xsl:apply-templates select=&quot;//CoverageDSPriv/Module&quot; /&amp;gt;
            &amp;lt;/table&amp;gt;
         &amp;lt;/body&amp;gt;
      &amp;lt;/html&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
 
   &amp;lt;xsl:template match=&quot;Module&quot;&amp;gt;
      &amp;lt;xsl:variable name=&quot;parentId&quot; select=&quot;generate-id(./..)&quot; /&amp;gt;
      &amp;lt;xsl:variable name=&quot;currentId&quot; select=&quot;generate-id(.)&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$parentId}&quot;&amp;gt;
         &amp;lt;td id=&quot;{$currentId}&quot;      colspan=&quot;3&quot;               onClick=&quot;toggleDetail(this)&quot;        onMouseOver=&quot;this.style.cursor= &#39;pointer&#39; &quot;&amp;gt;[+]&amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select=&quot;ModuleName&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksNotCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;xsl:call-template name=&quot;CoverageColumn&quot;&amp;gt;
            &amp;lt;xsl:with-param name=&quot;covered&quot; select=&quot;BlocksCovered&quot; /&amp;gt;
            &amp;lt;xsl:with-param name=&quot;uncovered&quot; select=&quot;BlocksNotCovered&quot; /&amp;gt;
         &amp;lt;/xsl:call-template&amp;gt;
      &amp;lt;/tr&amp;gt;
      &amp;lt;xsl:apply-templates select=&quot;NamespaceTable&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$currentId}-end&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td colspan=&quot;5&quot;&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
 
   &amp;lt;xsl:template match=&quot;NamespaceTable&quot;&amp;gt;
      &amp;lt;xsl:variable name=&quot;parentId&quot; select=&quot;generate-id(./..)&quot; /&amp;gt;
      &amp;lt;xsl:variable name=&quot;currentId&quot; select=&quot;generate-id(.)&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$parentId}&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;{$currentId}&quot;
               colspan=&quot;2&quot;
               onClick=&quot;toggleDetail(this)&quot;
               onMouseOver=&quot;this.style.cursor= &#39;pointer&#39; &quot;&amp;gt;[+]&amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select=&quot;NamespaceName&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksNotCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;xsl:call-template name=&quot;CoverageColumn&quot;&amp;gt;
            &amp;lt;xsl:with-param name=&quot;covered&quot; select=&quot;BlocksCovered&quot; /&amp;gt;
            &amp;lt;xsl:with-param name=&quot;uncovered&quot; select=&quot;BlocksNotCovered&quot; /&amp;gt;
         &amp;lt;/xsl:call-template&amp;gt;
      &amp;lt;/tr&amp;gt;
      &amp;lt;xsl:apply-templates select=&quot;Class&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$currentId}-end&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td colspan=&quot;5&quot;&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
 
   &amp;lt;xsl:template match=&quot;Class&quot;&amp;gt;
      &amp;lt;xsl:variable name=&quot;parentId&quot; select=&quot;generate-id(./..)&quot; /&amp;gt;
      &amp;lt;xsl:variable name=&quot;currentId&quot; select=&quot;generate-id(.)&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$parentId}&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;{$currentId}&quot;
               onClick=&quot;toggleDetail(this)&quot;
               onMouseOver=&quot;this.style.cursor=&#39;pointer&#39; &quot;&amp;gt;[+]&amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select=&quot;ClassName&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksNotCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;xsl:call-template name=&quot;CoverageColumn&quot;&amp;gt;
            &amp;lt;xsl:with-param name=&quot;covered&quot; select=&quot;BlocksCovered&quot; /&amp;gt;
            &amp;lt;xsl:with-param name=&quot;uncovered&quot; select=&quot;BlocksNotCovered&quot; /&amp;gt;
         &amp;lt;/xsl:call-template&amp;gt;
      &amp;lt;/tr&amp;gt;
      &amp;lt;xsl:apply-templates select=&quot;Method&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$currentId}-end&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td colspan=&quot;5&quot;&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;/tr&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
 
   &amp;lt;xsl:template match=&quot;Method&quot;&amp;gt;
      &amp;lt;xsl:variable name=&quot;parentId&quot; select=&quot;generate-id(./..)&quot; /&amp;gt;
      &amp;lt;tr id=&quot;{$parentId}&quot; style=&quot;display: none;&quot;&amp;gt;
         &amp;lt;td&amp;gt; -&amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;
         &amp;lt;td&amp;gt;&amp;lt;xsl:value-of select=&quot;MethodName&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;td id=&quot;data&quot;&amp;gt;&amp;lt;xsl:value-of select=&quot;BlocksNotCovered&quot; /&amp;gt;&amp;lt;/td&amp;gt;
         &amp;lt;xsl:call-template name=&quot;CoverageColumn&quot;&amp;gt;
            &amp;lt;xsl:with-param name=&quot;covered&quot; select=&quot;BlocksCovered&quot; /&amp;gt;
            &amp;lt;xsl:with-param name=&quot;uncovered&quot; select=&quot;BlocksNotCovered&quot; /&amp;gt;
         &amp;lt;/xsl:call-template&amp;gt;
      &amp;lt;/tr&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
 
   &amp;lt;xsl:template name=&quot;CoverageColumn&quot;&amp;gt;
      &amp;lt;xsl:param name=&quot;covered&quot; select=&quot;0&quot; /&amp;gt;
      &amp;lt;xsl:param name=&quot;uncovered&quot; select=&quot;0&quot; /&amp;gt;
      &amp;lt;td id=&quot;data&quot;&amp;gt;
         &amp;lt;xsl:variable name=&quot;percent&quot;
                              select=&quot;($covered div ($covered + $uncovered)) * 100&quot; /&amp;gt;
         &amp;lt;xsl:attribute name=&quot;style&quot;&amp;gt;
            background-color:
            &amp;lt;xsl:choose&amp;gt;
               &amp;lt;xsl:when test=&quot;number($percent &amp;gt;= 90)&quot;&amp;gt;#86ed60;&amp;lt;/xsl:when&amp;gt;
               &amp;lt;xsl:when test=&quot;number($percent &amp;gt;= 70)&quot;&amp;gt;#ffff99;&amp;lt;/xsl:when&amp;gt;
               &amp;lt;xsl:otherwise&amp;gt;#FF7979;&amp;lt;/xsl:otherwise&amp;gt;
            &amp;lt;/xsl:choose&amp;gt;
         &amp;lt;/xsl:attribute&amp;gt;
         &amp;lt;xsl:if test=&quot;$percent &amp;gt; 0&quot;&amp;gt;
            &amp;lt;xsl:value-of select=&quot;format-number($percent, &#39;###.##&#39; )&quot; /&amp;gt;%
         &amp;lt;/xsl:if&amp;gt;
         &amp;lt;xsl:if test=&quot;$percent = 0&quot;&amp;gt;
            &amp;lt;xsl:text&amp;gt;0.00%&amp;lt;/xsl:text&amp;gt;
         &amp;lt;/xsl:if&amp;gt;
      &amp;lt;/td&amp;gt;
   &amp;lt;/xsl:template&amp;gt;
&amp;lt;/xsl:stylesheet&amp;gt;

&lt;/textarea&gt;


</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/9200127124829628901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/09/convert-mstest-code-covarage-results-in.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/9200127124829628901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/9200127124829628901'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/09/convert-mstest-code-covarage-results-in.html' title='Convert MSTest code covarage results in to XML And view through Jenkins'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-6030460006454509423</id><published>2011-07-14T18:18:00.000+05:30</published><updated>2012-07-20T09:17:22.027+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Entity-Framework Lazy-Loading"/><title type='text'>Entity-Framework Differed loading (Lazy Loading) and immediate (Eager ) loading</title><content type='html'>You can use entity framework with lazy loading enabled to do everything . But when you try to do the performance testing you will find some crazy things going on inside. You can use SQL Server Profiler or a tool such as Entity Framework Profiler to see whats happening inside. By looking at SQL queries exacuting to ther server you can understand where to use Lazy loading or Immediate loading.&lt;br /&gt;
&lt;b&gt;1.Lazy loading&lt;/b&gt;&lt;br /&gt;
Related entities are automatically loaded from the data source when you access a navigation property. With this type of loading, be aware that each navigation property that you access results in a separate query executing against the data source if the entity is not already in the ObjectContext. Here is a lazy loading enabled example&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;db.Configuration.LazyLoadingEnabled = true;// enable lazy loading&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;var student = db.Students.FirstOrDefault(st =&amp;gt; st.PersonID == 1);// first queri will execute here &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;int i=student.Enrollments.Count;// Second query will execute here to load selected students enrolments&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
It will execute two separate queries to the server. First is to get student&#39;s sealer properties and second query is to load his enrollments.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.Immediate/Eager Loading&lt;/b&gt;&lt;br /&gt;
In this type only one single request will go to the database. It will return all entities defined by the path in a single result set. You can specify the related data that you want to load with the query by specifying paths.&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;db.Configuration.LazyLoadingEnabled = false;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;var student = db.Students.Include(&quot;Enrollments&quot;).FirstOrDefault(st =&amp;gt; st.PersonID == 1);&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #444444;&quot;&gt;int i=student.Enrollments.Count;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
this will execute one query to load student&#39;s scaler properties and his navigational property(Collection of Enrollments).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt; How to choose the best method &lt;/b&gt;&lt;br /&gt;
You need to consider three things,&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;How many connections that you are going to make with the database.&amp;nbsp;If you are using lazy loading there will be a database call for all the reference points of a navigation properties if referred navigation property is not in the context.&lt;/li&gt;
&lt;li&gt;How much data that you are going to retrieve from databaseIf you choose to load all the data in initial query with differed loading it will be too slow when you have huge amount of data to retrieve.&lt;/li&gt;
&lt;li&gt;Complexity of the query .&amp;nbsp;When you are using lazy loading the queries will be simple because all the data is not loaded in the initial query.  If you use immediate loading it will make quires will be more complex with query paths&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/6030460006454509423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/07/entity-framework-differed-loading-lazy.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/6030460006454509423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/6030460006454509423'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/07/entity-framework-differed-loading-lazy.html' title='Entity-Framework Differed loading (Lazy Loading) and immediate (Eager ) loading'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-8165005519298732823</id><published>2011-07-09T11:36:00.001+05:30</published><updated>2011-07-09T11:39:00.412+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="JQuey Post URL MVC"/><title type='text'>Jquery Post URL problems in IIS hosted Eenvironments</title><content type='html'>If you have used JQuery post with ASP.Net MVC the URL in the post will be something like &lt;br /&gt;
&lt;blockquote&gt;&quot;YourControllerName/ActionName&quot;&lt;/blockquote&gt;Example:-&lt;br /&gt;
&lt;blockquote&gt;$.post(&quot;Home/CreatePerson&quot;, { name: &quot;John&quot;, time: &quot;2pm&quot; },&lt;br /&gt;
&amp;nbsp; &amp;nbsp; function(data) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; alert(data);&lt;br /&gt;
});&lt;/blockquote&gt;This will work great until you deploy your project in IIS with an alias to your web application. Let say the give alias is &quot;MyWeb&quot;. The the URL will be &lt;b&gt;-your-iis-server-ip/MyWeb&lt;/b&gt;.  But the Jquery post in above will post its data to a URL something like &lt;b&gt;-your-iis-server-ip/Home/CreatePerson&lt;/your&gt;&lt;/b&gt;&lt;/your&gt;&lt;br /&gt;
&lt;br /&gt;
To avoid this you need to create post URL dynamically using @Url.Action() helper. Here is the corrected JQuery post.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;$.post(&quot;@Url.Action(&quot;CreatePerson&quot;, &quot;Home&quot;)&quot;, { name: &quot;John&quot;, time: &quot;2pm&quot; },&lt;br /&gt;
&amp;nbsp; &amp;nbsp; function(data) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; alert(data);&lt;br /&gt;
});&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/8165005519298732823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/07/jquery-post-url-problems-in-iis-hosted.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8165005519298732823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/8165005519298732823'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/07/jquery-post-url-problems-in-iis-hosted.html' title='Jquery Post URL problems in IIS hosted Eenvironments'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-3669357353010649603</id><published>2011-06-26T08:23:00.004+05:30</published><updated>2011-06-27T13:11:32.272+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Installing"/><category scheme="http://www.blogger.com/atom/ns#" term="NCover"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Server 2008"/><title type='text'>Ncover Installation in windows server 2008</title><content type='html'>Recently I was trying to install &lt;a href=&quot;http:\\www.ncover.com/&quot;&gt;Ncover &lt;/a&gt;in Windows Server 2008. Even though  I had installed .Net framework 4.0 &lt;a href=&quot;http:\\www.ncover.com/&quot;&gt;Ncover &lt;/a&gt; setup threw an error saying that &quot;you need to have .Net 3.5 or above to install NCover&quot;.I had re installed .Net Framework 4.0 several times ad restarted the server but no effect.&lt;br /&gt;
Then I went to the server manger panel and I saw a section called feature summery. In add features section you can add .Net framework 3.5 features. After a restart everything worked fine.</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/3669357353010649603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/06/ncover-installation-in-windows-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3669357353010649603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3669357353010649603'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/06/ncover-installation-in-windows-server.html' title='Ncover Installation in windows server 2008'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-3525907346868934797</id><published>2011-06-21T10:36:00.002+05:30</published><updated>2011-06-26T08:08:10.376+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Commands"/><category scheme="http://www.blogger.com/atom/ns#" term="MSTest"/><category scheme="http://www.blogger.com/atom/ns#" term="NCover"/><title type='text'>Ncover Command Line For MSTest</title><content type='html'>If you are using MSTest here is the command windows batch command to generate test results&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe&quot;      /testcontainer: \yourTestProjectPath\YourTests.dll      /testcontainer: \yourTestProjectPath2\YourTests2.dll  /resultsfile:results.trx /testsettings:YourTestSettingsPath \local.testsettings  &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can add several test projects using /testcontainer: argument. Here I have used two test projects. To use NCover we need to change this command by adding NCover commands . NCover arguments are started with “//” and for MSTest they started with “/”. Here Is the Ncover command to generate coverage.nccov and coverage.trend files.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&quot;C:\Program files (x86)\NCover\NCover.Console.exe&quot;    &quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe&quot;    //x mstest_coverage.nccov     //at &quot;coverage.trend&quot;    /testcontainer: \yourTestProjectPath\YourTests.dll      /testcontainer: \yourTestProjectPath2\YourTests2.dll  /resultsfile:results.trx /testsettings:YourTestSettingsPath \local.testsettings  &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
There are more options with NCover you can find those here &lt;a href=&quot;http://docs.ncover.com/ref/3-0/ncover-console/command-line&quot; &gt;Ncover command line&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now we have coverage.nccov and coverage.trend files we need to generate a HTML report from these two. For that we can use Ncover Reportng tool. Here is the Command to generate NCover HTML reports.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
ncover.reporting mstest_coverage.nccov //lt coverage.trend //or FullCoverageReport:Html:output &lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
Here we are generating full Coverage report in the directory called output</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/3525907346868934797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2011/06/ncover-command-line-for-mstest.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3525907346868934797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/3525907346868934797'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2011/06/ncover-command-line-for-mstest.html' title='Ncover Command Line For MSTest'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-277495853868981071</id><published>2010-12-14T13:17:00.000+05:30</published><updated>2012-01-27T13:05:20.749+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="JQuery"/><title type='text'>Sort UL element by the customized sorting funtion by JQuery</title><content type='html'>&lt;div&gt;
We can customize javascript sort() function for any requirement as given below. In this example&lt;/div&gt;
&lt;div&gt;
it sorts the List items  according to text of the fist child. &lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
function SortList() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;        var listToSort = $(&#39;#tabmenu&#39;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;        var listitems = listToSort.children(&#39;li&#39;).get();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;      &lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;        listitems.sort(function (a, b) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;           &lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;            var contentA = $(a).first().text().toUpperCase();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;            var contentB = $(b).first().text().toUpperCase();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;            return (contentA != contentB) ? 1 : 0;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;        })&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;        $.each(listitems, function (idx, itm) { listToSort.append(itm); });&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
You can customize this functionality as you want by changing these two lines of code&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;           var contentA = $(a).first().text().toUpperCase();&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;            var contentB = $(b).first().text().toUpperCase();&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
As an example,&lt;/div&gt;
&lt;div&gt;
If you want to sort list items according to the id of the first element you can change like this&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;b&gt;  &lt;/b&gt; &lt;/span&gt;    var contentA = $(a).first().attr(&#39;id&#39;).toUpperCase();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;            var contentB = $(b).first().&lt;span class=&quot;Apple-style-span&quot;&gt;attr(&#39;id&#39;)&lt;/span&gt;.toUpperCase();&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/277495853868981071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2010/12/sort-ul-element-by-customized-sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/277495853868981071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/277495853868981071'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2010/12/sort-ul-element-by-customized-sorting.html' title='Sort UL element by the customized sorting funtion by JQuery'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2008534129495378119.post-2615920320518554593</id><published>2010-03-25T15:29:00.000+05:30</published><updated>2011-10-01T11:59:48.199+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><title type='text'>Simulated annealing approach to pagination problem</title><content type='html'>Currently i am involved in my the final year project which is for the &lt;a href=&quot;http://www.lakehouse.lk&quot;&gt;ANCL &lt;/a&gt;(&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: rgb(152, 124, 101); line-height: 12px; &quot;&gt;The Associated Newspapers of Ceylon Ltd.&lt;/span&gt;) . The main research area of that project is to give a solution to the pagination problem. We have four member in our team. My main contribution to the project is implementing the simulated annealing algorithm.&lt;div&gt;Here is my approach to do it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;My algorithm&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkUg-6tzmQyQgcHGNaxb51Fuc0i59fhDoz1NoxJl-ggMMKDEr5GxX2sELh0fNi_pXoV9dzOtrfMlGFkFoRMRL-VyyAqfRTvFbrC7bmjzZWpElBb7OyDfy6ZAb7AwZ_4HVhxW4xYamQb3Y/s1600/SA.JPG&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkUg-6tzmQyQgcHGNaxb51Fuc0i59fhDoz1NoxJl-ggMMKDEr5GxX2sELh0fNi_pXoV9dzOtrfMlGFkFoRMRL-VyyAqfRTvFbrC7bmjzZWpElBb7OyDfy6ZAb7AwZ_4HVhxW4xYamQb3Y/s320/SA.JPG&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5452497682927186306&quot; style=&quot;float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 320px; height: 188px; &quot; /&gt;&lt;/a&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;This is a simplified version of the simulated annealing approach to the pagination problem. At first we place one large advertisement for each page in a section. This is for the regulations we have to follow in our implementation.(Largest advertisement should be in the bottom right corner in odd page ,bottom left corner in the even page).&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;Based on previous step result initial solution can be generated by placing the remaining ads.&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;when we placing the ads to the dummy we use three steps.&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;&lt;ol&gt;&lt;li&gt;width and height fit ad&lt;/li&gt;&lt;li&gt;width or height fit ad&lt;/li&gt;&lt;li&gt;random ad which reduces the energy&lt;/li&gt;&lt;/ol&gt;After creating the initial solutions we remove some random ads and the ads near to the empty spaces to a new array ads we place these ads according to the given three steps. Then we calculate the energy of the newly created solution and if it is less than what we have for the previous one we take it as the current solution.&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codetuner.blogspot.com/feeds/2615920320518554593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codetuner.blogspot.com/2010/03/simulated-annealing-approach-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2615920320518554593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2008534129495378119/posts/default/2615920320518554593'/><link rel='alternate' type='text/html' href='http://codetuner.blogspot.com/2010/03/simulated-annealing-approach-to.html' title='Simulated annealing approach to pagination problem'/><author><name>Jayantha</name><uri>http://www.blogger.com/profile/12177396079622237790</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkUg-6tzmQyQgcHGNaxb51Fuc0i59fhDoz1NoxJl-ggMMKDEr5GxX2sELh0fNi_pXoV9dzOtrfMlGFkFoRMRL-VyyAqfRTvFbrC7bmjzZWpElBb7OyDfy6ZAb7AwZ_4HVhxW4xYamQb3Y/s72-c/SA.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>