<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Cosa importa se....</title>
	
	<link>http://pythonyan.wordpress.com</link>
	<description>i pensieri ti sfiorano come piccole gocce di pioggia.</description>
	<lastBuildDate>Thu, 02 Jul 2009 10:52:11 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>it</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/223a528984d240306cc2e08bb1838e94?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Cosa importa se....</title>
		<link>http://pythonyan.wordpress.com</link>
	</image>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/pythonyan" type="application/rss+xml" /><item>
		<title>T4: Text Template Transformation Toolkit</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/N6mwGqWdiec/</link>
		<comments>http://pythonyan.wordpress.com/2009/07/02/t4-text-template-transformation-toolkit/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:52:11 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[T4]]></category>
		<category><![CDATA[Tecnologie]]></category>
		<category><![CDATA[code ge]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=354</guid>
		<description><![CDATA[


T4:  Text Template Transformation Toolkit

Posted by Oleg Sych
December 22, 2007


Text  Template Transformation Toolkit (T4) is a template-based code generation  engine. It is included with Visual Studio 2008 and available as a download for  Visual Studio 2005 in DSL and GAT toolkits. You can use T4 templates to generate Visual Basic, C#, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=354&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div><!-- Header End --><!-- Content Start --></p>
<div id="loop_single">
<div id="post_4">
<h3><a href="http://www.olegsych.com/2007/12/text-template-transformation-toolkit/"><span>T4:  Text Template Transformation Toolkit</span></a></h3>
<ul>
<li>Posted by <a title="Posts by Oleg Sych" href="http://www.olegsych.com/author/olegsych/">Oleg Sych</a></li>
<li>December 22, 2007</li>
</ul>
<div>
<p><a href="http://msdn2.microsoft.com/en-us/library/bb126445.aspx">Text  Template Transformation Toolkit</a> (T4) is a template-based code generation  engine. It is included with Visual Studio 2008 and available as a download for  Visual Studio 2005 in <a href="http://msdn.microsoft.com/vstudio/DSLTools/">DSL</a> and <a href="http://msdn.microsoft.com/vstudio/teamsystem/workshop/gat">GAT</a> toolkits. You can use T4 templates to generate Visual Basic, C#, T-SQL, XML or  any other text files.</p>
<h4>Syntax</h4>
<p>T4 templates have ASP.NET-like syntax and consist of processing directives,  text blocks and code blocks.</p>
<pre><span style="background:gold none repeat scroll 0 0;">&lt;#@</span><span style="color:red;"> </span><span style="color:brown;">template </span><span style="color:red;">language=</span>“<span style="color:blue;">C#</span>” <span style="background:gold none repeat scroll 0 0;">#&gt;
</span><span style="color:gray;">Hello
</span><span style="background:gold none repeat scroll 0 0;">&lt;#</span><span style="background:#f0f8ff none repeat scroll 0 0;color:#191970;"> Write(”World!”) </span><span style="background:gold none repeat scroll 0 0;">#&gt;</span></pre>
<p>Processing directives provide template compilation and processing options. In  the example above, &lt;#@ template #&gt; directive specifies that code blocks of  this template are written in C#.</p>
<p>Text blocks are copied to the output “as is”. In the example above, Hello is  a text block.</p>
<p>Code blocks contain Visual Basic or C# code that can manipulate text blocks  or generate template output directly. In the example above, the code block calls  Write method which writes “World!” to the output file. Code blocks can use any  available .NET APIs. For example, a template can use <a href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.aspx">SMO</a> to generate CRUD stored procedures for a table in a SQL Server database.</p>
<h4>How it works</h4>
<p>T4 engine performs two steps to generate output from a template.</p>
<p><a href="http://www.olegsych.com/wp-content/uploads/2008/05/t4-template-transformation-process.png" target="_blank"><img style="border-width:0;" src="http://www.olegsych.com/wp-content/uploads/2008/05/t4-template-transformation-process-thumb.png" border="0" alt="T4 Template Transformation Process" width="580" height="314" /></a></p>
<p>During the first step, T4 engine “compiles” the template: it parses the  processing instructions, text and code blocks, generates a concrete <a href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.texttemplating.texttransformation.texttransformation.aspx" target="_blank">TextTransformation</a> class, and compiles it into a .NET  assembly. During the second step, T4 engine creates an instance of the  <em>GeneratedTextTransformation</em> class, calls its <em>TransformText </em>method and saves the string it returns to the output file.</p>
<h4>Tutorial</h4>
<p>This series of articles introduces code generation with C# and Text Templates  in Visual Studio; explains how to create reusable templates and combine them in  complex code generators.</p>
<ul>
<li><a href="http://www.olegsych.com/2008/09/t4-tutorial-creatating-your-first-code-generator/">Creating  your first code generator</a></li>
<li><a href="http://www.olegsych.com/2008/09/t4-tutorial-troubleshooting-code-generation-errors/">Troubleshooting  code generation errors</a></li>
<li><a href="http://www.olegsych.com/2008/09/t4-tutorial-debugging-code-generation-files/">Debugging  code generation files</a></li>
<li><a href="http://www.olegsych.com/2008/09/t4-tutorial-creating-reusable-code-generation-templates/">Creating  reusable code generation templates</a></li>
<li><a href="http://www.olegsych.com/2008/09/t4-tutorial-creating-complex-code-generators/">Creating  complex code generators</a></li>
<li><a href="http://www.olegsych.com/2008/10/t4-tutorial-reusing-code-generators-on-multiple-projects/">Reusing  code generators on multiple projects</a></li>
<li><a href="http://www.olegsych.com/2008/11/t4-tutorial-handling-errors-in-code-generators/">Handling  errors in code generators</a></li>
<li><a href="http://www.olegsych.com/2008/11/t4-tutorial-unit-testing-code-generators/">Unit  testing code generators</a></li>
<li><a href="http://www.olegsych.com/2009/02/t4-tutorial-making-code-generators-extensible/">Making  code generators extensible</a></li>
</ul>
<h4>Tools</h4>
<p>Here are the tools you will be using when working with T4 text templates.</p>
<h5>Visual Studio Custom Tool</h5>
<p>T4 engine is integrated as a custom tool into Visual Studio 2008. When you  add a text file with .tt extension to your project, Visual Studio assigns  TextTemplatingFileGenerator as a custom tool and automatically generates output  file from the template. This is similar to how Visual Studio generates  strongly-typed datasets from .xsd files.</p>
<h5>Command Line Utility</h5>
<p>T4 also includes a command line utility, <a href="http://msdn2.microsoft.com/en-us/library/bb126461.aspx">TextTransform.exe</a>,  which you can use to process templates outside of Visual Studio (similar to <a href="http://msdn2.microsoft.com/en-us/library/x6c1kb0s.aspx">xsd.exe</a> for  strongly-typed datasets).</p>
<h5>Editor</h5>
<p>Text editing and debugging support for T4 templates is currently rather  limited. I use <a href="http://www.olegsych.com/2009/04/t4-editor-by-tangible-engineering">T4  Editor from Tangible Engineering</a>, which extends Visual Studio to provide  IntelliSense and syntax highlighting for .tt files. Another option is the <a href="http://www.t4editor.net/">T4 Editor from Clarius Consulting</a>, however  functionality of its free edition is more limited.</p>
<h5>Debugger</h5>
<p>Debugging requires placing calls to <a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx">Debugger.Break</a> method in code blocks to set breakpoints. Check out this <a href="http://blogs.msdn.com/garethj/archive/2006/01/09/t4debugging.aspx">post</a> by Gareth Jones for more details. Hopefully, future versions of Visual Studio  will provide a better debugging experience for T4 templates.</p>
<h5>Visual Studio Templates</h5>
<p>Unfortunately, Visual Studio itself does not provide a specific item for T4  templates in the Add New Project Item dialog. This makes it difficult for  developers to discover this code generation tool even exists. You can download  <a href="http://www.olegsych.com/2008/08/t4-toolbox/">T4 Toolbox</a> from  CodePlex, which adds several items to the Code Generation folder of the Add New  Project Item dialog.</p>
<h4>Details</h4>
<p>Here are some articles that will help you understand how template  transformation works by showing how specific blocks and processing directives  are “compiled”. Examples in these articles include the original template text,  compiled template code and output file it produces.</p>
<ul>
<li><a href="http://www.olegsych.com/2008/02/t4-text-blocks/">Text Blocks</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-statement-blocks/">Statement  Blocks</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-expression-blocks/">Expression  Blocks</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-class-feature-blocks/">Class  Feature Blocks</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-template-directive/">&lt;#@  template #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-output-directive/">&lt;#@ output  #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-import-directive/">&lt;#@ import  #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-assembly-directive/">&lt;#@  assembly #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/02/t4-include-directive/">&lt;#@  include #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/04/t4-property-directive/">&lt;#@  property #&gt; directive</a></li>
<li><a href="http://www.olegsych.com/2008/08/t4-xsd-directive">&lt;#@ xsd #&gt;  directive</a></li>
</ul>
<p>The following articles cover advanced topics of code generation with T4.</p>
<ul>
<li><a href="http://www.olegsych.com/2008/05/t4-architecture/">T4  Architecture</a></li>
<li><a href="http://www.olegsych.com/2008/04/t4-template-design/">T4 Template  Design</a></li>
<li><a href="http://www.olegsych.com/2008/06/test-runner-for-t4-unit-tests/">Test  runner for T4 unit tests</a></li>
<li><a href="http://www.olegsych.com/2009/01/pros-and-cons-of-t4-in-visual-studio-2008/">Pros  and Cons of T4 in Visual Studio 2008</a></li>
</ul>
<h5>Videos</h5>
<ul>There is a growing number of videos about T4 published on <a href="http://msdn2.microsoft.com/en-us/bb629407.aspx#extend">MSDN</a>.</p>
<li><a href="http://msdn2.microsoft.com/en-us/vstudio/cc308634.aspx">How Do I:  Create and Use T4 Templates</a> (by <a href="http://hilton.giesenow.com/">Hilton  Giesenow</a>)</li>
<li><a href="http://www.olegsych.com/2008/10/advanced-code-generation-patterns-with-t4-and-dsl-tools/">Advanced  code generation patterns with T4 &amp; DSL Tools</a> (by <a href="http://blogs.msdn.com/garethj/">Gareth Jones</a> and <a href="http://blogs.msdn.com/jmprieur">Jean-Marc Prieur</a>)</li>
<li><a href="http://channel9.msdn.com/posts/MichaelLehman/Authoring-Blueprints-Using-T4-Templates/">Authoring  Blueprints &#8211; Using T4 Templates</a> (by <a href="http://blogs.msdn.com/mglehman">Michael Legman</a>)</li>
<li><a href="http://www.pnpguidance.net/Screencast/T4TemplatesVisualStudioCodeGenerationScreencast.aspx">Code  Generation in Visual Studio Using T4 Templates</a> (by <a href="http://www.davidhayden.com/">David Hayden</a>)</li>
</ul>
<h4>Examples</h4>
<p>You can find some T4 examples on <a href="http://msdn2.microsoft.com/en-us/library/bb126445.aspx">MSDN</a>. You will  notice that it has very limited information about use of T4 outside of DSL and  Guidance packages. Here are some examples of standalone templates you can start  using without having to build your own Software Factory.</p>
<ul>
<li><a href="http://www.olegsych.com/2007/12/how-to-create-a-simple-t4-template/">How  to create a simple T4 template</a></li>
<li><a href="http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/">How  to use T4 to generate .config files</a></li>
<li><a href="http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-decorator/">How  to use T4 to generate Decorator classes</a></li>
<li><a href="http://www.olegsych.com/2008/01/how-to-use-t4-to-generate-crud-stored-procedures/">How  to use T4 to generate CRUD stored procedures</a></li>
<li><a href="http://www.olegsych.com/2008/02/how-to-use-t4-to-generate-strongly-typed-navigation-class-in-aspnet/">How  to use T4 to generate strongly-typed navigation class in ASP.NET</a> (by Kirill  Chilingarashvili)</li>
<li><a href="http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/">How  to generate multiple outputs from single T4 template</a></li>
<li><a href="http://www.olegsych.com/2008/05/t4-template-for-generating-adonet-entity-framework-stored-procedures/">T4  template for generating ADO.NET Entity Framework Stored Procedures</a> (by <a href="http://blogs.rev-net.com/ddewinter">David DeWinter</a>)</li>
<li><a href="http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx">T4  script for generating ADO.NET Entity Framework Views </a>(by ADO.NET team)</li>
<li><a href="http://damieng.com/blog/2008/07/23/linq-to-sql-t4-template-reloaded">T4  template for generating LINQ to SQL Data Context</a> (by Damien Guard)</li>
<li><a href="http://blog.newagesolution.net/2008/06/how-to-use-msbuild-and-wix-to-msi.html">T4  template for generating WiX source files</a> (by New Age Solutions)</li>
<li><a href="http://www.olegsych.com/2008/07/t4-template-for-generating-sql-view-from-csharp-enumeration/">T4  Toolbox: Template for generating SQL view from C# enumeration</a></li>
<li><a href="http://geekswithblogs.net/EltonStoneman/archive/2008/07/25/an-msbuild-task-to-execute-t4-templates.aspx">MSBuild  task for transforming T4 templates</a> (by Elton Stoneman)</li>
<li><a href="http://aabs.wordpress.com/2008/06/26/state-machines-in-c-30-using-t4-templates/">T4  template for generating state machines in C#</a> (by Andrew Matthews)</li>
<li><a href="http://www.olegsych.com/2008/12/t4-toolbox-strongly-typed-azman-wrapper-generator/">T4  Toolbox: Strongly-typed AzMan wrapper generator</a></li>
<li><a href="http://www.olegsych.com/2009/01/t4-toolbox-linq-to-sql-classes-generator/">T4  Toolbox: LINQ to SQL classes generator</a></li>
<li><a href="http://blog.wekeroad.com/blog/make-visual-studio-generate-your-repository/">Make  Visual Studio Generate Your (SubSonic) Repository</a> (by Rob Conery)</li>
<li><a href="http://gcapnias.spaces.live.com/blog/cns%211A746C4E01342B70%21499.entry">SubSonic  v3’s T4 Templates</a> (by George Capnias)</li>
<li><a href="http://melgrubb.spaces.live.com/blog/cns%21a44bb98a805c8996%21256.entry">Generating  DataContext Proxy Classes With T4 Templates</a> (by Mel Grubb)</li>
<li><a href="http://staxmanade.blogspot.com/2008/12/t4-text-templating-in-silverlight.html">T4  Text Templating in Silverlight</a> (by Jason Jarrett)</li>
<li><a href="http://www.thecodejunkie.com/2008/11/generate-enums-from-database-using-text.html">Generate  enums from a database using T4</a> (by Code Junkie)</li>
<li><a href="http://blogs.msdn.com/dsimmons/archive/2008/10/27/using-t4-templates-to-generate-ef-classes.aspx">T4  template for generating Entity Framework classes</a> (by Danny Simmons, ADO.NET  team)</li>
<li><a href="http://blogs.msdn.com/davidebb/archive/2008/11/26/fun-with-t4-templates-and-dynamic-data.aspx">T4  templates for generating Dynamic Data views</a> (by David Ebbo, ASP.NET team)</li>
<li><a href="http://broloco.blogspot.com/2008/11/using-t4-command-line-parameters.html">Using  T4 Command-Line Parameters &#8211; Generating NHibernate Magic Strings</a> (by Richard  Brown)</li>
<li><a href="http://blog.devarchive.net/2008/11/generating-code-using-ms-codename-t4.html">Using  T4 to generate code based on M language in Oslo</a> (by Kirill Chilingarashvili)</li>
<li><a href="http://www.worldolio.com/derek/wordpress/?p=132">SQLite foreign key  constraint generator using T4</a> (by Derek Wilson)</li>
<li><a href="http://www.agilification.com/post/T4-Templates-For-The-NET-Compact-Framework.aspx">T4  templates for the .NET Compact Framework</a> (by Jeff Doolittle)</li>
<li><a href="http://www.olegsych.com/2009/05/t4-toolbox-linq-to-sql-schema-generator/">T4  Toolbox: LINQ to SQL schema generator</a></li>
</ul>
<h4>Alternatives</h4>
<p>As a code generation tool, T4’s purpose is similar to that of <a href="http://msdn2.microsoft.com/en-us/library/650ax5cx.aspx">CodeDom</a> (Code  Document Object Model). CodeDom provides an API you can use to generate code in  any .NET language from the same program. CodeDom API is low-level, complex, and  has a steep learning curve. It is typically used for code generation in  frameworks that need to to support multiple .NET languages. For example, T4  engine itself uses CodeDom; you have to use CodeDom to extend T4 with custom  directives. Compared to CodeDom, T4 is easier to learn and use. However, T4  templates are language-specific. In other words, if you want to generate the  same code code in C# and Visual Basic, you will need to create 2 separate T4  templates. Unlike CodeDom, T4 can generate any text files (XML, HTML, etc) and  not just .cs or .vb files. This makes T4 a better fit for code generation in  application development then CodeDom.</p>
<p>T4 engine is similar to <a href="http://www.codesmithtools.com/">CodeSmith</a>, which has been around a lot  longer, provides an excellent set of ready-to-use templates, better template  editing and debugging experience for a reasonable price. Unlike CodeSmith, which  was was designed to be a template-based code generation tool, T4 engine was  designed as a supporting tool for <a href="http://msdn2.microsoft.com/en-us/architecture/aa699360.aspx">Software  Factories</a>. T4 does not offer any reusable templates out of the box and  provides rather limited documentation focused on use of T4 templates in DSL and  Guidance packages. However, with inclusion in Visual Studio 2008, I think we  will see more and more teams adopting T4 engine as a free alternative to  CodeSmith.</p>
<p>T4 engine is also similar to <a href="http://nvelocity.sourceforge.net/">NVelocity</a>, an open-source template  transformation engine. NVelocity was ported from Java and intends to stay as  close to Jakarta Velocity as possible. This makes its template syntax different  from ASP.NET and I would think that more people will prefer T4. I don’t know if  a significant number of NVelocity templates are available at this  time.</div>
</div>
</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/354/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=354&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/07/02/t4-text-template-transformation-toolkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="http://www.olegsych.com/wp-content/uploads/2008/05/t4-template-transformation-process-thumb.png" medium="image">
			<media:title type="html">T4 Template Transformation Process</media:title>
		</media:content>
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/07/02/t4-text-template-transformation-toolkit/</feedburner:origLink></item>
		<item>
		<title>T4 Editor plus UML-Style modeling tools for Visual Studio 2008/2010</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/rdxjYnGlnGo/</link>
		<comments>http://pythonyan.wordpress.com/2009/07/02/t4-editor-plus-uml-style-modeling-tools-for-visual-studio-20082010/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:49:05 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[code generator]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=352</guid>
		<description><![CDATA[T4 Editor plus UML-Style modeling tools
for Visual Studio 2008/2010 
With tangible T4 Editor you can author your own Code Generator via  Text-Templates (TT-Files) with Intelli-Sense &#38;  Syntax-Highlighting. T4 is a Microsoft Language for writing Code  Generators which is similar to ASP.NET and is  used by the Microsoft internally to build software [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=352&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h1><span><span style="color:#cc6600;"><strong><span lang="en-us">T4 Editor plus UML-Style modeling tools<br />
</span></strong><span lang="en-us"><span><strong>for Visual Studio 2008/2010</strong></span> </span></span></span></h1>
<p><span lang="en-us"><span>With </span><span><strong>tangible T4 Editor</strong></span></span> <span lang="en-us"><span>you can </span>author your <span>own</span><span> </span><strong>Code Generator </strong>via  Text-Templates (TT-Files) with<strong> </strong><strong>Intelli-Sense</strong><strong> &amp;  Syntax-Highlighting. T4 is a Microsoft Language </strong><strong>for writing Code  Generators</strong></span> <span lang="en-us">which is similar to ASP.NET and is  used by the Microsoft internally to build software and new features for .NET  4.0. The T4 Code Generation Engine is already built into Visual Studio &#8211; so </span><span><span lang="en-us">the only thing that was missing was  a great <strong>T4 Editor and some free UML-style modeling tools</strong> &#8211; so  we shipped it.</span></span><span lang="en-us"><br />
<span>Now it is up to you to accelerate your projects and start saving  your company money by adopting T4 today and generate the code you need directly  from diagrams, database schemas or xml files.</span></span></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><img style="height:600px;" src="PreviewT4Editor.png" alt="" /></span><br />
</span><span><span lang="en-us"> </span><strong>(<span lang="en-us">Screenshot of features available in FREE  EDITION)</span></strong></span></p>
<p><em><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span><span lang="en-us">In addition, with the free build-in tangible  modeling tools you can directly <strong>create</strong></span></span><span lang="en-us"> Software Diagrams </span><span><span lang="en-us">like <strong>Use Case  Diagrams</strong>, <strong>Component Diagrams</strong>, <strong>State Charts</strong>, <strong>Class  Diagrams</strong>,</span></span><span lang="en-us"><span><strong> Activity  Diagrams and Persistent Object Models from within Visual Studio</strong>. (see below) </span></span></span></em></p>
<p><span lang="en-us"><span style="color:#cc6600;"><strong>T4 Editor Features &#8211; T4 Code  Generation simplified</strong></span><strong> </strong></span></p>
<p><span lang="en-us">The T4 Editor for Syntax Highlighting and Intelli-Sense  allows you to author your own code generators in Visual Studio that read from  diagrams, xml or any other data source. </span></p>
<ul>
<li><span lang="en-us"><span><strong>T4 Syntax Highlighting </strong></span>for <strong>C#, VB.NET, Java, PHP, SQL, MSIL, Python, Batch  Files, PASCAL, PowerShell, IL, JSCRIPT, VBSCRIPT, CSS</strong> in output text  code <span>and</span> T4 Code Sections in C# or VB.NET<span><br />
</span></span> <span lang="en-us"><br />
</span></li>
<li><span lang="en-us"><span><strong>T4 Intelli-Sense, Intelli-Prompt  and Statement Completition</strong></span> for T4 Code Sections. Intelli-Sense  will look at all assemblies and namespaces indicated by the import and include  pragma. *Limited support for namespaces in the FREE EDITION.
<p></span></li>
<li><span lang="en-us"><span><strong>Syntax Error  Reporting</strong></span> in ErrorList and via Text-Highlighting for errors  inside the T4 text template
<p></span></li>
<li><span lang="en-us"><strong><span>Template Gallery &#8211; </span></strong>Access &amp; Share T4 Templates in our Gallery or in your  Workgroup
<p></span></li>
<li><span lang="en-us"><span><strong>Support for #Include </strong></span>Directive, this makes types visible to importing template&#8217;s  Intelli-Sense
<p></span></li>
<li><span lang="en-us">Support <a href="http://www.codeplex.com/t4toolbox">T4  Toolbox</a> which includes <span><strong>XSD  Directive</strong></span>, <span><strong>Multiple</strong></span><span><strong> </strong></span><span><strong>output files</strong></span><span> </span>and more.</span><span><span lang="en-us">
<p></span></span></li>
<li><span lang="en-us"><span><strong>Drag and Drop</strong></span> XML Files and Diagrams onto T4 Editor get T4 Code to generate from them.</span></li>
</ul>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span lang="en-us"><br />
<span style="color:#cc6600;"><strong>A Tour around T4  Editor</strong></span></p>
<p></span><span><span lang="en-us">Double-click video for fullscreen.</p>
<p></span></span></span></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;color:#cc6600;"><strong>Supported diagram  types</strong></span></span></p>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span lang="en-us"><span>With tangible modeling tools you  can directly create Use Case Diagrams, Component Diagrams, State Charts, Class  Diagrams, Activity Diagrams and Persistent Object Models. Which can also be used  for code-generation by a T4 Template.</span></span></p>
<p></span></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><img style="width:448px;height:322px;" src="Preview1.png" alt="" /></span></span></p>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span lang="en-us"><span style="color:#cc6600;"><img style="width:448px;height:322px;" src="Preview2.png" alt="" /></span></span></p>
<p><em><span lang="en-us"><br />
<img style="width:448px;height:322px;" src="Preview3.png" alt="" /></span></em></p>
<p><span lang="en-us"><em><img style="width:448px;height:322px;" src="Preview4.png" alt="" /></em></span></p>
<p><span lang="en-us"><em><img style="width:448px;height:322px;" src="Preview5.png" alt="" /></em></span></p>
<p><span lang="en-us"><em><img style="width:448px;height:322px;" src="Preview6.png" alt="" /></em></span></p>
<p><span lang="en-us"><span style="color:#cc6600;"><strong>FREE EDITION  Download </strong></span></span></p>
<p><strong><span style="color:#cc6600;"><span lang="en-us"><a href="http://www.tangible.de/modellingtools_teaser.aspx"><span>FREE EDITION DOWNLOAD is here.</span></a></span><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"> </span></span></strong></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;color:#cc6600;"><strong>Ongoing feedback-driven  development</strong></span></span></span></p>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span><span lang="en-us">tangible modeling tools plus T4 Editor is an initiative  we take to better support the .NET Community with precise modeling tools and  code generation. It uses the same components we have built into our high-end  code generator <a href="http://www.tangiblearchitect.com/">tangible  architect</a>. We are in the process of collecting your feature requests. Please  provide us your feedback at <a href="mailto:info@tangible.de">info@tangible.de</a>. </span></span></span></span></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;color:#cc6600;"><strong>FAQs</strong></span></span></span></p>
<p><span lang="en-us"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;">Q: Will tangible modeling tools  also be free in future? A: Yes, we stick to offering a FREE SKU. But we also  offer enhanced SKUs with additional functionality.</span></span></span></p>
<p><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span style="font-family:Verdana,Arial,Helvetica,sans-serif;"><span><span lang="en-us">Q: Which version of Visual Studio is supported? A:There  are three Builds. For VS2005 we support Diagrams only. For VS 2008 we also  included tangible&#8217;s new T4 Editor. <a href="http://tangibleengineering.blogspot.com/2009/05/tangible-t4-editor-now-listed-in-visual.html">Here  is the tangible T4 Editor for Visual Studio 2010 (T4 Editor only as Beta1  includes MS Modelling Tools)</a></span></span></span></span></p>
<p></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/352/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=352&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/07/02/t4-editor-plus-uml-style-modeling-tools-for-visual-studio-20082010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="PreviewT4Editor.png" medium="image" />

		<media:content url="Preview1.png" medium="image" />

		<media:content url="Preview2.png" medium="image" />

		<media:content url="Preview3.png" medium="image" />

		<media:content url="Preview4.png" medium="image" />

		<media:content url="Preview5.png" medium="image" />

		<media:content url="Preview6.png" medium="image" />
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/07/02/t4-editor-plus-uml-style-modeling-tools-for-visual-studio-20082010/</feedburner:origLink></item>
		<item>
		<title>Refactorings in Alphabetical Order</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/OhJTY0z496w/</link>
		<comments>http://pythonyan.wordpress.com/2009/07/02/refactorings-in-alphabetical-order/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:07:39 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[Architects]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=350</guid>
		<description><![CDATA[From Martin Fowler.
Refactorings in Alphabetical Order
This is a simple list of refactorings both from the original book and some later sources. Sadly I haven&#8217;t had enough time and energy to keep this material up to date. Refactorings marked with  with have some  extra material to what&#8217;s in the Refactoring book. Refactorings marked with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=350&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>From Martin Fowler.</p>
<h1>Refactorings in Alphabetical Order</h1>
<p>This is a simple list of refactorings both from the original book and some later sources. Sadly I haven&#8217;t had enough time and energy to keep this material up to date. Refactorings marked with <img src="updated.gif" alt="" /> with have some  extra material to what&#8217;s in the Refactoring book. Refactorings marked with <img src="new.gif" alt="" /> are in addition to those in the refactoring book. Refactorings  with <em>Link Only</em> are references to refactorings described elsewhere.</p>
<p>| <a href="http://xprogramming.com.ua/refactoringpatterns.php">Russian</a> |  <a href="http://www.java-tutor.com/java/refactoring/catalog/">German</a> |</p>
<ul>
<li><a href="addParameter.html">Add Parameter</a></li>
<li><a href="changeBidirectionalAssociationToUnidirectional.html">Change  Bidirectional Association to Unidirectional</a></li>
<li><a href="changeReferenceToValue.html">Change Reference to Value</a></li>
<li><a href="changeUnidirectionalAssociationToBidirectional.html">Change  Unidirectional Association to Bidirectional</a> <img src="updated.gif" alt="" /></li>
<li><a href="changeValueToReference.html">Change Value to Reference</a></li>
<li><a href="collapseHierarchy.html">Collapse Hierarchy</a></li>
<li><a href="consolidateConditionalExpression.html">Consolidate Conditional  Expression</a></li>
<li><a href="consolidateDuplicateConditionalFragments.html">Consolidate  Duplicate Conditional Fragments</a> <img src="updated.gif" alt="" /></li>
<li><a href="convertDynamicToStaticConstruction.html">Convert Dynamic to Static  Construction</a> <em>by Gerard M. Davison</em><img src="new.gif" alt="" /></li>
<li><a href="convertStaticToDynamicConstruction.html">Convert Static to Dynamic  Construction</a> <em>by Gerard M. Davison</em><img src="new.gif" alt="" /></li>
<li><a href="decomposeConditional.html">Decompose Conditional</a></li>
<li><a href="duplicateObservedData.html">Duplicate Observed Data</a></li>
<li><a href="eliminateInterEntityCommunication.html">Eliminate Inter-Entity Bean  Communication</a> <em>(Link Only)</em></li>
<li><a href="encapsulateCollection.html">Encapsulate Collection</a></li>
<li><a href="encapsulateDowncast.html">Encapsulate Downcast</a></li>
<li><a href="encapsulateField.html">Encapsulate Field</a></li>
<li><a href="extractClass.html">Extract Class</a></li>
<li><a href="extractInterface.html">Extract Interface</a></li>
<li><a href="extractMethod.html">Extract Method</a></li>
<li><a href="extractPackage.html">Extract Package</a> <em>by Gerard M.  Davison</em><img src="new.gif" alt="" /></li>
<li><a href="extractSubclass.html">Extract Subclass</a></li>
<li><a href="extractSuperclass.html">Extract Superclass</a></li>
<li><a href="formTemplateMethod.html">Form Template Method</a></li>
<li><a href="hideDelegate.html">Hide Delegate</a></li>
<li><a href="hideMethod.html">Hide Method</a></li>
<li><a href="hidePresentationTierDetails.html">Hide presentation tier-specific  details from the business tier</a> <em>(Link Only)</em></li>
<li><a href="inlineClass.html">Inline Class</a></li>
<li><a href="inlineMethod.html">Inline Method</a></li>
<li><a href="inlineTemp.html">Inline Temp</a></li>
<li><a href="introduceAController.html">Introduce A Controller</a> <em>(Link  Only)</em></li>
<li><a href="introduceAssertion.html">Introduce Assertion</a></li>
<li><a href="introduceBusinessDelegate.html">Introduce Business Delegate</a> <em>(Link Only)</em></li>
<li><a href="introduceExplainingVariable.html">Introduce Explaining Variable</a></li>
<li><a href="introduceForeignMethod.html">Introduce Foreign Method</a></li>
<li><a href="introduceLocalExtension.html">Introduce Local Extension</a> <img src="updated.gif" alt="" /></li>
<li><a href="introduceNullObject.html">Introduce Null Object</a></li>
<li><a href="introduceParameterObject.html">Introduce Parameter Object</a> <img src="updated.gif" alt="" /></li>
<li><a href="introduceSynchronizerToken.html">Introduce Synchronizer Token</a> <em>(Link Only)</em></li>
<li><a href="localizeDisparateLogic.html">Localize Disparate Logic</a> <em>(Link  Only)</em></li>
<li><a href="mergeSessionBeans.html">Merge Session Beans</a> <em>(Link Only)</em></li>
<li><a href="moveBusinessLogicToSession.html">Move Business Logic to Session</a> <em>(Link Only)</em></li>
<li><a href="moveClass.html">Move Class</a> <em>by Gerard M. Davison</em><img src="new.gif" alt="" /></li>
<li><a href="moveField.html">Move Field</a></li>
<li><a href="moveMethod.html">Move Method</a> <img src="updated.gif" alt="" /></li>
<li><a href="parameterizeMethod.html">Parameterize Method</a> <img src="updated.gif" alt="" /></li>
<li><a href="preserveWholeObject.html">Preserve Whole Object</a></li>
<li><a href="pullUpConstructorBody.html">Pull Up Constructor Body</a></li>
<li><a href="pullUpField.html">Pull Up Field</a></li>
<li><a href="pullUpMethod.html">Pull Up Method</a></li>
<li><a href="pushDownField.html">Push Down Field</a></li>
<li><a href="pushDownMethod.html">Push Down Method</a></li>
<li><a href="reduceScopeOfVariable.html">Reduce Scope of Variable</a> <em>by Mats  Henricson</em><img src="new.gif" alt="" /></li>
<li><a href="refactorArchitectureByTiers.html">Refactor Architecture by  Tiers</a> <em>(Link Only)</em></li>
<li><a href="removeAssignmentsToParameters.html">Remove Assignments to  Parameters</a></li>
<li><a href="removeControlFlag.html">Remove Control Flag</a></li>
<li><a href="removeDoubleNegative.html">Remove Double Negative</a> <em>by Ashley  Frieze and Martin Fowler</em><img src="new.gif" alt="" /></li>
<li><a href="removeMiddleMan.html">Remove Middle Man</a></li>
<li><a href="removeParameter.html">Remove Parameter</a></li>
<li><a href="removeSettingMethod.html">Remove Setting Method</a> <img src="updated.gif" alt="" /></li>
<li><a href="renameMethod.html">Rename Method</a></li>
<li><a href="replaceArrayWithObject.html">Replace Array with Object</a></li>
<li><a href="replaceAssignmentWithInitialization.html">Replace Assignment with  Initialization</a> <em>by Mats Henricson</em><img src="new.gif" alt="" /></li>
<li><a href="replaceConditionalWithPolymorphism.html">Replace Conditional with  Polymorphism</a></li>
<li><a href="replaceConditionalWithVisitor.html">Replace Conditional with  Visitor</a> <em>by Ivan Mitrovic</em><img src="new.gif" alt="" /></li>
<li><a href="replaceConstructorWithFactoryMethod.html">Replace Constructor with  Factory Method</a> <img src="updated.gif" alt="" /></li>
<li><a href="replaceDataValueWithObject.html">Replace Data Value with Object</a></li>
<li><a href="replaceDelegationWithInheritance.html">Replace Delegation with  Inheritance</a></li>
<li><a href="replaceErrorCodeWithException.html">Replace Error Code with  Exception</a></li>
<li><a href="replaceExceptionWithTest.html">Replace Exception with Test</a></li>
<li><a href="replaceInheritanceWithDelegation.html">Replace Inheritance with  Delegation</a></li>
<li><a href="replaceIterationWithRecursion.html">Replace Iteration with  Recursion</a> <em>by Dave Whipp</em><img src="new.gif" alt="" /></li>
<li><a href="replaceMagicNumberWithSymbolicConstant.html">Replace Magic Number  with Symbolic Constant</a> <img src="updated.gif" alt="" /></li>
<li><a href="replaceMethodWithMethodObject.html">Replace Method with Method  Object</a> <img src="updated.gif" alt="" /></li>
<li><a href="replaceNestedConditionalWithGuardClauses.html">Replace Nested  Conditional with Guard Clauses</a></li>
<li><a href="replaceParameterWithExplicitMethods.html">Replace Parameter with  Explicit Methods</a></li>
<li><a href="replaceParameterWithMethod.html">Replace Parameter with Method</a></li>
<li><a href="replaceRecordWithDataClass.html">Replace Record with Data Class</a></li>
<li><a href="replaceRecursionWithIteration.html">Replace Recursion with  Iteration</a> <em>by Ivan Mitrovic</em><img src="new.gif" alt="" /></li>
<li><a href="replaceStaticVariableWithParameter.html">Replace Static Variable  with Parameter</a> <em>by Marian Vittek</em><img src="new.gif" alt="" /></li>
<li><a href="replaceSubclassWithFields.html">Replace Subclass with Fields</a></li>
<li><a href="replaceTempWithQuery.html">Replace Temp with Query</a> <img src="updated.gif" alt="" /></li>
<li><a href="replaceTypeCodeWithClass.html">Replace Type Code with Class</a> <img src="updated.gif" alt="" /></li>
<li><a href="replaceTypeCodeWithStateStrategy.html">Replace Type Code with  State/Strategy</a></li>
<li><a href="replaceTypeCodeWithSubclasses.html">Replace Type Code with  Subclasses</a></li>
<li><a href="reverseConditional.html">Reverse Conditional</a> <em>by Bill Murphy  and Martin Fowler</em><img src="new.gif" alt="" /></li>
<li><a href="selfEncapsulateField.html">Self Encapsulate Field</a></li>
<li><a href="separateDataAccessCode.html">Separate Data Access Code</a> <em>(Link  Only)</em></li>
<li><a href="separateQueryFromModifier.html">Separate Query from Modifier</a></li>
<li><a href="splitLoop.html">Split Loop</a> <em>by Martin Fowler</em><img src="new.gif" alt="" /></li>
<li><a href="splitTemporaryVariable.html">Split Temporary Variable</a></li>
<li><a href="substituteAlgorithm.html">Substitute Algorithm</a></li>
<li><a href="useAConnectionPool.html">Use a Connection Pool</a> <em>(Link  Only)</em></li>
<li><a href="wrapEntitiesWithSession.html">Wrap entities with session</a> <em>(Link Only)</em></li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=350&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/07/02/refactorings-in-alphabetical-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="updated.gif" medium="image" />

		<media:content url="new.gif" medium="image" />

		<media:content url="new.gif" medium="image" />
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/07/02/refactorings-in-alphabetical-order/</feedburner:origLink></item>
		<item>
		<title>Israel Kamakawiwo</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/laP2PpgfsyQ/</link>
		<comments>http://pythonyan.wordpress.com/2009/06/05/344/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 21:26:13 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[NET]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/2009/06/05/344/</guid>
		<description><![CDATA[Somewhere Over the Rainbow by Israel Kamakawiwo&#8217;ole LYRICS

Troppo bella.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=344&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Somewhere Over the Rainbow by Israel Kamakawiwo&#8217;ole LYRICS</strong><br />
<span style="text-align:center; display: block;"><a href="http://pythonyan.wordpress.com/2009/06/05/344/"><img src="http://img.youtube.com/vi/pAIKznMPXUk/2.jpg" alt="" /></a></span><br />
Troppo bella.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/344/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/344/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=344&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/06/05/344/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/pAIKznMPXUk/2.jpg" medium="image" />
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/06/05/344/</feedburner:origLink></item>
		<item>
		<title>Framework Design Guidelines</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/2CA5ONJMy6s/</link>
		<comments>http://pythonyan.wordpress.com/2009/06/04/framework-design-guidelines/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:53:17 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[Framework Design Guidelines]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=341</guid>
		<description><![CDATA[Dal blog di Brad Abrams linee guida per lo sviluppo con il framework Microsoft.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=341&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Dal <a href="http://blogs.msdn.com/brada/archive/tags/Framework+Design+Guidelines/default.aspx">blog </a>di Brad Abrams linee guida per lo sviluppo con il framework Microsoft.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/341/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=341&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/06/04/framework-design-guidelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/06/04/framework-design-guidelines/</feedburner:origLink></item>
		<item>
		<title>Web Deployment: Web.Config Transformation</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/1T2nMH0_eps/</link>
		<comments>http://pythonyan.wordpress.com/2009/06/04/web-deployment-web-config-transformation/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:49:46 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=339</guid>
		<description><![CDATA[Nuone funzionalità in Visual Studio 2010<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=339&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We have earlier discussed about Web Deployment and Web Packaging quite a bit, today I wanted to dive into web.config transformation. If you would like to check out the other topics please read through the earlier blog posts below:</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><a href="http://vishaljoshi.blogspot.com/2009/02/web-deployment-with-vs-2010-and-iis.html">Web Deployment with VS 2010 and IIS</a></li>
<li><a href="http://vishaljoshi.blogspot.com/2009/02/web-packaging-creating-web-package.html">Web Packaging: Creating a Web Package using VS 2010</a> </li>
<li><a href="http://vishaljoshi.blogspot.com/2009/02/web-packaging-creating-web-packages.html">Web Packaging: Creating web packages using MSBuild</a> </li>
<li><a href="http://vishaljoshi.blogspot.com/2009/03/how-does-web-deployment-with-vs-10.html">How does Web Deployment with VS 10 &amp; MSDeploy Work?</a> </li>
<li><a href="http://vishaljoshi.blogspot.com/2009/03/web-packaging-installing-web-packages.html" target="_blank">Installing Web Packages using Command Line</a> </li>
</ul>
<p>Usually web applications go through a chain of server deployments before being finally being deployed to production environment. Some of these environments can be Developer box (Debug), QA Server, Staging/Pre-Production, Production (Release). While transitioning between these environments various settings of the web application residing in web.config file change, some of these settings can be items like application settings, connection strings, debug flags, web services end points etc.</p>
<p> </p>
<p> </p>
<p> </p>
<p>VS10’s new web.config transformation model allows you to modify your web.config file in an automated fashion during deployment of your applications to various server environments. To help command line based deployments, Web.Config transformation is implemented as an MSBuild task behind the scene hence you can simply call it even outside of deployment realm.</p>
<p> </p>
<p> </p>
<p> </p>
<p>I will try to go through below steps to explain web.config transformation in detail</p>
<p> </p>
<p> </p>
<p> </p>
<ol>
<li>Creating a “Staging” Configuration on your developer box </li>
<li>Adding a “Staging” Web.Config Transform file to your project </li>
<li>Writing simple transforms to change developer box connection string settings into “Staging” environment settings </li>
<li>Generating a new transformed web.config file for “Staging” environment from command line </li>
<li>Generating a new transformed web.config file for “Staging” environment from VS UI </li>
<li>Understanding various available web.config Transforms and Locators </li>
<li>Using Web.config transformation toolset for config files in sub-folders within the project </li>
</ol>
<p><strong>Step 1: Creating a “Staging” Configuration on your developer box </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Debug and Release build configurations are available by default within Visual Studio but if you would like to add more build configurations (for various server environments like “Dev”, “QA”, “Staging”, “Production” etc then you can do so by going to the Project menu Build &#8211;&gt; Configuration Manager… Learn more about <a href="http://vishaljoshi.blogspot.com/2009/02/tips-tricks-managing-environment.html" target="_blank">creating build configurations</a>.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 2: Adding a “Staging” Web.Config Transform file to your project </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>One of the goals while designing web.config transformation was to make sure that the original runtime web.config file does not need to be modified to ensure that there would be no performance impacts and also to make sure that the design time syntax is not mixed with runtime syntax. To support this goal the concept of Configuration specific web.config files was introduced.</p>
<p> </p>
<p> </p>
<p> </p>
<p>These web.config files follow a naming convention of web.<strong>configuration</strong>.config. For example the web.config files for various Visual Studio + Custom configurations will look as below:</p>
<p> </p>
<p> </p>
<p> </p>
<p><a href="http://lh5.ggpht.com/_E8t3edIzcC8/SchDIcv7GXI/AAAAAAAAAtw/HXJ5vkMMLIM/s1600-h/image%5B4%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/configtransformdoctored25.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<p>Any new Web Application Project (WAP) created in VS10 will by default have Web.Debug.config and Web.Release.config files added to the project. If you add new configurations (e.g. “Staging”) or if you upgrade pre-VS10 projects to VS10 then you will have to issue a command to VS to generate the Configuration specific Transform files as needed.</p>
<p> </p>
<p> </p>
<p> </p>
<p>To add configuration specific transform file (e.g. Web.Staging.Config) you can right click the original web.config file and click the context menu command “Add Config Transforms” as shown below:</p>
<p><a href="http://lh3.ggpht.com/_E8t3edIzcC8/SchDJJJeDaI/AAAAAAAAAt4/TZbJaWZyi38/s1600-h/image%5B9%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/image9.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<p>On clicking the “Add Config Transform” command VS10 will detect the configurations that do not have a transform associated with them and will automatically create the missing transform files. It will not overwrite an existing transform file. If you do not want a particular configuration transform file then you can feel free to delete it off.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Note</strong>: In case of VB Web Application Projects the web.<strong><em>configuration</em></strong>.config transform files will not be visible till you enable the hidden file views as shown below:</p>
<p><a href="http://lh4.ggpht.com/_E8t3edIzcC8/SchDJtalJbI/AAAAAAAAAuA/A8r191dtmJs/s1600-h/image%5B14%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/image14.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<p>The transform files are design time files only and will not be deployed or packaged by VS10. If you are going to xCopy deploy your web application it is advised that you should explicitly leave out these files from deployment just like you do with project (.csproj/.vbproj) or user (.user) files…</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Note</strong>: These transform files should not be harmful even if deployed as runtime does not use them in any fashion and additionally ASP.NET makes sure that .config files are not browsable in any way.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 3: Writing simple transforms to change developer box connection string settings into “Staging” environment settings </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Web.Config Transformation Engine is a simple XML Transformation Engine which takes a source file (your project’s original web.config file) and a transform file (e.g. web.staging.config) and produces an output file (web.config ready for staging environment).</p>
<p> </p>
<p> </p>
<p> </p>
<p>The Transform file (e.g. web.staging.config ) needs to have XML Document Transform namespace registered at the root node as shown below:</p>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;configuration xmlns:xdt=&#8221;http://schemas.microsoft.com/XML-Document-Transform&#8221;&gt;<br />
&lt;/configuration&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Note</strong>: The transform web.config file needs to be a well formed XML.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Inside the XML-Document-Transform namespace two new attributes are defined. These attributes are important to understand as they drive the <strong>XML Transformation Engine</strong>.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong><span style="text-decoration:underline;">Transform </span></strong>– This attribute inside the Web.Staging.config informs the Transformation engine the way to modify web.config file for specific configuration (i.e. staging). Some examples of what Transforms can do are:</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li>Replacing a node </li>
<li>Inserting a node </li>
<li>Delete a node </li>
<li>Removing Attributes </li>
<li>Setting Attributes </li>
</ul>
<p><strong><span style="text-decoration:underline;">Locator </span></strong>– This attribute inside the web.staging.config helps the Transformation engine to exactly pin-point the web.config node that the transform from web.staging.config should be applied to. Some examples of what Locators can do are:</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li>Match on value of a node’s attribute </li>
<li>Exact XPath of where to find a node </li>
<li>A condition match to find a node </li>
</ul>
<p>Based on the above basic understanding let us try to transform connection string from original web.config file to match Staging environment’s connection string</p>
<p> </p>
<p> </p>
<p> </p>
<p>Let us examine the original web.config file and identify the items to replace&#8230; Let’s assume that the original Web Config file’s connection string section looks as below:</p>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;configuration&gt;<br />
  &lt;connectionStrings&gt;<br />
    &lt;add name=&#8221;personalDB&#8221;<br />
     connectionString=&#8221;Server=DevBox; Database=personal; User; password=P@ssw0rd&#8221; providerName=&#8221;System.Data.SqlClient&#8221; /&gt;<br />
    &lt;add name=&#8221;professionalDB&#8221;<br />
     connectionString=&#8221;Server=DevBox; Database=professional; User; password=P@ssw0rd&#8221; providerName=&#8221;System.Data.SqlClient&#8221; /&gt;<br />
&lt;/connectionStrings&gt;<br />
&#8230;.<br />
&#8230;.<br />
&lt;/configuration&gt;</p>
<p> </p>
<p> </p>
<p> <br />
<strong>NOTE</strong>: It is not advisable to keep connection string unencrypted in the web.config file, my example is just for demonstration purposes.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Let us assume that we would like to make following changes to web.config file when moving to staging environment</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li>For “personalDB” we would like to change the connectionString to reflect Server=StagingBox, UserId=admin, passoword=StagingPersonalPassword” </li>
<li>For “professionalDB” we would like to change the connectionString to reflect Server=StagingBox, UserId=professional, passoword=StagingProfessionalPassword” </li>
</ul>
<p>To make the above change happen we will have to open <strong>web.Staging.Config</strong> file and write the below piece of code</p>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;?xml version=&#8221;1.0&#8243;?&gt;<br />
&lt;configuration xmlns:xdt=&#8221;http://schemas.microsoft.com/XML-Document-Transform&#8221;&gt;<br />
     &lt;connectionStrings&gt;<br />
        &lt;add name=&#8221;personalDB&#8221;<br />
          connectionString=&#8221;Server=StagingBox; Database=personal; User Id=admin; password=StagingPersonalPassword&#8221;<br />
          providerName=&#8221;System.Data.SqlClient&#8221; xdt:Transform=&#8221;Replace&#8221; xdt:Locator=&#8221;Match(name)&#8221; /&gt;<br />
        &lt;add name=&#8221;professionalDB&#8221;<br />
         connectionString=&#8221;Server=StagingBox; Database=professional; User Id=professional; password=StagingProfessionalPassword&#8221;<br />
         providerName=&#8221;System.Data.SqlClient&#8221; xdt:Transform=&#8221;Replace&#8221; xdt:Locator=&#8221;Match(name)&#8221;/&gt;<br />
       &lt;/connectionStrings&gt;<br />
&lt;/configuration&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<p>The above syntax in web.staging.config has <strong>Transform</strong> and <strong>Locator</strong> attributes from the <strong>xdt </strong>namespace. If we analyze the connection string node syntax we can notice that the Transform used here is “<strong>Replace</strong>” which is instructing the Transformation Engine to Replace <span style="text-decoration:underline;">the entire node</span></p>
<p> </p>
<p> </p>
<p> </p>
<p>Further if we notice the Locator used here is “<strong>Match</strong>” which is informing Transformation engine that among all the <em>“configuration/connectionStrings/add”</em> nodes that are found, pick up the node whose name attribute matches with the name attribute of &lt;add&gt; node in web.Staging.config.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Also if you notice web.Staging.config does not contain anything else but the connectionStrings section (i.e. it <span style="text-decoration:underline;">does not</span> have &lt;system.web&gt; and various other sections that web.config file usually has, this is because of the fact that the Transformation Engine does not require a complete web.config file in web.staging.config. It does the merging for you thus saving you duplication of all the rest of the sections in web.config file.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Simplest Approach: </strong>If you do not mind replicating the entire web.config file in web.staging.config then you can certainly do so by copying the entire web.config content into web.staging.config and change the relevant nodes inside web.staging.config. In such a situation you will just have to put <strong>xdt:Transform=&#8221;Replace&#8221; </strong>attribute on the topmost node (i.e. configuration) of web.staging.config. You will not need xdt:Locator attribute at all as you are replacing your entire web.config file with web.staging.config without Matching anything.</p>
<p> </p>
<p> </p>
<p> </p>
<p>So far we have seen one Transform (i.e. Replace) and one Locator (i.e. Match), we will see various other Transforms and Locators further in the post but first let us understand how we can produce the Transformed web.config file for the Staging environment after using original web.config and web.staging.config.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 4: Generating a new transformed web.config file for “Staging” environment from command line </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Open Visual Studio Command prompt by going to Start &#8211;&gt; Program Files –&gt; Visual Studio v10.0 –&gt; Visual Studio tools –&gt; Visual Studio 10.0 Command Prompt</p>
<p> </p>
<p> </p>
<p> </p>
<p>Type “MSBuild “<strong><em>Path to Application project file (.csproj/.vbproj)</em></strong> ” /t:TransformWebConfig /p:Configuration=Staging&#8221; and hit enter as shown below:</p>
<p><a href="http://lh4.ggpht.com/_E8t3edIzcC8/SchDKEg75PI/AAAAAAAAAuI/3N8u7-8be34/s1600-h/image%5B21%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/image26.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<p>Once the transformation is successful the web.config for the “Staging” configuration will be stored under obj &#8211;&gt;Staging folder under your project root (In solution explorer you can access this folder by first un-hiding the hidden files) :</p>
<p><a href="http://lh4.ggpht.com/_E8t3edIzcC8/SchDLDpDZuI/AAAAAAAAAuQ/DFrtMWygIrc/s1600-h/image%5B28%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/image25.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li>In the solution explorer click the button to show hidden files</li>
<li>Open the Obj folder </li>
<li>Navigate to your Active configuration (in our current case it is “Staging”) </li>
<li>You can find the transformed web.config there </li>
</ul>
<p>You can now verify that the new staging web.config file generated has the changed connection string section.</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 5: Generating a new transformed web.config file for “Staging” environment from VS UI </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>Right Click on your project and click Package –&gt; Create Package</p>
<p><a href="http://lh4.ggpht.com/_E8t3edIzcC8/SchDL6B0jeI/AAAAAAAAAuY/aW8Eq3QY938/s1600-h/image%5B34%5D.png"></a></p>
<p><a href="/Users/vijoshi/AppData/Local/Temp/WindowsLiveWriter-429641856/supfiles239CB3DE/image34.png"></a></p>
<p> </p>
<p> </p>
<p> </p>
<p>The <a href="http://vishaljoshi.blogspot.com/2009/02/web-packaging-creating-web-package.html" target="_blank">Create Package</a> step already does web.config transformation as one of its intermediate steps before creating a package and hence you should be able to find the transformed web.config file in the same place as described in Step 4</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 6: Understanding various available web.config Transforms and Locators </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>xdt:Locators </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>The inbuilt xdt:Locators are discussed below.</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>Match &#8211; </strong>In the provided syntax sample below the Replace transform will occur only when the name Northwind matches in the list of connection strings in the source web.config.Do note that Match Locator can take multiple attributeNames as parameters e.g. Match(name, providerName) ] </li>
</ul>
<p>&lt;connectionStrings&gt;<br />
     &lt;add name=&#8221;Northwind&#8221; connectionString=&#8221;connectionString goes    here&#8221; providerName=&#8221;System.Data.SqlClient&#8221; xdt:Transform=&#8221;Replace&#8221; xdt:Locator=&#8221;Match(name)&#8221; /&gt;<br />
&lt;/connectionStrings&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>Condition &#8211; </strong>Condition Locator will create an XPath predicate which will be appended to current element’s XPath. The resultant XPath generated in the below example is <em>“/configuration/connectionStrings/add[@name='Northwind or @providerName=’ System.Data.SqlClient’ ]”</em></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p>This XPath is then used to search for the correct node in the source web.config file</p>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;connectionStrings&gt;<br />
      &lt;add name=&#8221;Northwind&#8221; connectionString=&#8221;connectionString goes here&#8221; providerName=&#8221;System.Data.SqlClient&#8221; xdt:Transform=&#8221;Replace&#8221; xdt:Locator=&#8221;Condition(@name=’Northwind or @providerName=’System.Data.SqlClient’)&#8221; /&gt;<br />
&lt;/connectionStrings&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>XPath- </strong>This Locator will support complicated XPath expressions to identify the source web.config nodes. In the syntax example we can see that the XPath provided will allow user to replace <strong>system.web</strong> section no matter where it is located inside the web.config (i.e. all the system.web sections under any location tag will be removed.)</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;location path=&#8221;c:\MySite\Admin&#8221; &gt;<br />
    &lt;system.web xdt:Transform=&#8221;RemoveAll&#8221; xdt:Locator=&#8221;XPath(//system.web)&#8221;&gt;<br />
    &#8230;<br />
    &lt;/system.web&gt;<br />
&lt;/location&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>xdt:Transform </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>Replace &#8211; </strong>Completely replaces the first matching element along with all of its children from the destination web.config (e.g. staging environment’s web.config file). Do note that transforms do not modify your source web.config file.<br />
&lt;assemblies xdt:Transform=&#8221;Replace&#8221;&gt;<br />
    &lt;add assembly=&#8221;System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089&#8243; /&gt;<br />
&lt;/assemblies&gt; </li>
</ul>
<ul>
<li><strong>Remove &#8211; </strong>Removes the first matching element along with all of its children<br />
&lt;assemblies xdt:Transform=&#8221;Remove&#8221;&gt;&lt;/assemblies&gt;</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>RemoveAll &#8211; </strong>Removes all the matching elements from the destination’s web.config (e.g. staging environment’s web.config file).</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;connectionStrings&gt;<br />
    &lt;add xdt:Transform=&#8221;RemoveAll&#8221;/&gt;<br />
&lt;/connectionStrings&gt;<strong> </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>Insert &#8211; </strong>Inserts the element defined in web.staging.config at the bottom of the list of all the siblings in the destination web.config (e.g. staging environment’s web.config file).</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;authorization&gt;<br />
     &lt;deny users=&#8221;*&#8221; xdt:Transform=&#8221;Insert&#8221;/&gt;<br />
&lt;/authorization&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>SetAttributes &#8211; </strong>Takes the value of the specified attributes from the web.staging.config and sets the attributes of the matching element in the destination web.config. This Transform takes a comma separated list of attributes which need to be set. If no attributes are given to SetAttributes transform then it assumes that you would like to Set all the attributes present on the corresponding node in web.staging.config<br />
&lt;compilation batch=&#8221;false&#8221;xdt:Transform=&#8221;SetAttributes(batch)&#8221;&gt;</li>
</ul>
<p>   …</p>
<p>   &lt;/compilation&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>RemoveAttributes &#8211; </strong>Removes the specified attributes from the destination web.config (i.e. staging environment’s web.config file). The syntax example shows how multiple attributes can be removed.</li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p>&lt;compilation xdt:Transform=&#8221;RemoveAttributes(debug,batch)&#8221;&gt;<br />
&lt;/compilation&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>InsertAfter (XPath) </strong>- Inserts the element defined in the web.staging.config exactly after the element defined by the specified XPath passed to “InsertAfter()” transform. In the syntax example the element &lt;deny users=&#8221;Vishal&#8221; /&gt;will be exactly inserted after the element &lt;allow roles=&#8221;Admins&#8221; /&gt; in the destinationXML. </li>
</ul>
<p>&lt;authorization&gt;<br />
     &lt;deny users=&#8221;Vishal&#8221; xdt:Transform=&#8221;InsertAfter(/configuration/system.web/authorization/allow[@roles='Admins'])” /&gt;</p>
<p>&lt;/authorization&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li><strong>InsertBefore (XPath) &#8211; </strong>Inserts the element defined in the web.staging.config exactly before the element defined by the specified XPath passed to “InsertBefore()” transform. In the syntax example the element &lt;allow roles=&#8221;Admins&#8221; /&gt;will be exactly inserted before the element &lt;deny users=&#8221;*&#8221; /&gt;in the destinationXML. </li>
</ul>
<p>&lt;authorization&gt;<br />
      &lt;allow roles=&#8221; Admins&#8221; xdt:Transform=&#8221;InsertBefore(/configuration/system.web/authorization/ deny[@users='*'])&#8221; /&gt;<br />
&lt;/authorization&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong><span style="text-decoration:underline;">Some advanced points to note:</span></strong></p>
<p> </p>
<p> </p>
<p> </p>
<ul>
<li>If the Transformation Engine does not find a xdt:Transform attribute specified on a node in web.staging.config file then that node is ignored for Transformation and the Tranformation engine moves ahead traversing the rest of the web.staging.config. </li>
<li>A xdt:Transform attribute on a parent can very easily impact child elements even if there is no Transform specified for child e.g. If xdt:Transform=”Replace” is put on &lt;system.web&gt; then everything underneath &lt;system.web&gt; node will be replaced with the content from web.staging.config </li>
<li>It is completely valid to place xdt:Locators attributes on arbitrary nodes inside web.staging.config just for filtering purposes. xdt:Locator does not need to be accompanied with xdt:Transform attribute. (great example here is &lt;location&gt; tag which might just be used for filtering… The example code here would be: </li>
</ul>
<p>&lt;location path=&#8221;c:\MySite\Admin&#8221; xdt:Locator=&#8221;Match(path)&#8221;&gt;&gt;<br />
        &lt;system.web&gt;<br />
          &#8230; Bunch of transforms written under here will<br />
          &#8230;. only apply if location path = C:\MySite\Admin<br />
        &lt;/system.web&gt;<br />
&lt;/location&gt;</p>
<p> </p>
<p> </p>
<p> </p>
<p><strong>Step 7: Using Web.config</strong><strong> transformation toolset for config files in sub-folders within the project </strong></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>All of the above discussion directly applies to any web.config file present in sub folders of your project (e.g. if you have a separate web.config file for say “Admin” folder then VS 10 will support transforms for them too). You can add transform files within sub-folders and use the same packaging functionality mentioned in all of the above steps to create transformed web.config files for web.config files specific to the sub folders within your project.</p>
<p> </p>
<p> </p>
<p> </p>
<p>I think this has become a rather long post; but I hope it helps!!</p>
<p>Vishal R. Joshi | Program Manager | Visual Studio Web Developer</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/339/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=339&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/06/04/web-deployment-web-config-transformation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/06/04/web-deployment-web-config-transformation/</feedburner:origLink></item>
		<item>
		<title>YouTube XL</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/0CsLsi7bnbo/</link>
		<comments>http://pythonyan.wordpress.com/2009/06/04/youtube-xl/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:47:21 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[Video YouTube]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/2009/06/04/youtube-xl/</guid>
		<description><![CDATA[Bellissimo.. http://www.youtube.com/xl
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=338&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bellissimo.. <a href="http://www.youtube.com/xl">http://www.youtube.com/xl</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/338/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/338/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/338/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=338&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/06/04/youtube-xl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/06/04/youtube-xl/</feedburner:origLink></item>
		<item>
		<title>C# 4.0 Optional Parameters and C# 4.0 Named Parameters</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/eMvi1stJSrM/</link>
		<comments>http://pythonyan.wordpress.com/2009/06/04/c-4-0-optional-parameters-and-c-4-0-named-parameters/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:46:15 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[C# 4.0]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/2009/06/04/c-4-0-optional-parameters-and-c-4-0-named-parameters/</guid>
		<description><![CDATA[From David Hayden<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=337&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="font-family:Verdana;font-size:x-small;">I have to say I absolutely love the C# Language and am so happy that I decided to learn and embrace C# when .NET came on the scene and I transitioned from VB6. It is not to say VB is bad or inferior to C#, but that I really enjoy the tidiness and expressiveness of C#. It just speaks to me <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </span></p>
<p><span style="font-family:Verdana;font-size:x-small;">With <a href="http://davidhayden.com/blog/dave/archive/2009/05/23/DownloadVisualStudio2010Beta.aspx">Visual Studio 2010 and the .NET Framework 4.0</a> we get a new version of the C# Language, C# 4.0.</span></p>
<p> </p>
<h2><span style="font-family:Verdana;">C# 4.0 Optional Parameters and Named Parameters</span></h2>
<p><span style="font-family:Verdana;font-size:x-small;">A few of the interesting features in C# 4.0 are <strong>Optional Parameters, Default Values, and Named Parameters</strong>. The idea is that the arguments on a method may have “Default Values” and therefore it is unnecessary to supply those arguments in a method call if you are willing to accept those default values. This helps in those cases when we overload methods several times to help alleviate the caller from having to provide all values in a method. With Optional Parameters and Default Values you can now set Default Values to arguments on a method:</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">static void Write(string name, string address, <span style="color:#0000ff;">string city = “Sarasota”</span>) { &#8230; }</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">In the method above we have assigned the city parameter a default value of “Sarasota”, which means it can now be used optionally by the caller of the method:</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Write(”David Hayden”, “1234 Broad Street”); city not specified, accept default.</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">or I can override the value by passing in the city as usual:</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Write(“David Hayden“,“1234 Broad Street“,<span style="color:#0000ff;">“Tampa“</span>); // Overriding Default</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Sometimes you may have multiple optional parameters:</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">static void Write(string name, string address, <span style="color:#0000ff;">string city = “Sarasota”, </span><span style="color:#ff0000;">string state=“Florida“</span>) { &#8230; }</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">and the question becomes how do you specity a value for the state without specifying a value for the city? <strong>Named parameters</strong>, of course! We can now do the following:</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Write(“David Hayden“,“1234 Broad Street“, <span style="color:#ff0000;">state: “Hawaii“</span>); </span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Using the new “[parameter]:“ syntax is mind blowing and quite neat, no? <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">The only real convention here with optional parameters is that optional parameters must come <strong>at the end</strong> of the list of method arguments. Hence, you specify all your required arguments in the method first and then list the optional arguments last just like we did above.</span></p>
<p><span style="font-family:Verdana;font-size:x-small;">The intellisense is pretty cool in Visual Studio 2010 for Optional Parameters, Default Values, and Named Parameters. Notice below how Visual Studio 2010 shows you the default values as well as pops-up the named parameter choices available for you to choose. Also notice in the screenshot that I chose to also use the named parameter syntax on the required <strong>zip</strong> parameter for kicks. That offers a bit of self-documenting code so you know what the values represent in the method call.</span></p>
<p> </p>
<p align="center"><span style="font-family:Verdana;font-size:x-small;"><img src="http://pythonyan.wordpress.com/photos/CSharp4OptionalParameters.jpg" alt="C# 4.0 Optional Parameters" /></span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;">Cool Stuff!!</span></p>
<p> </p>
<h2><span style="font-family:Verdana;">Conclusion</span></h2>
<p><span style="font-family:Verdana;font-size:x-small;"><a href="http://davidhayden.com/blog/dave/archive/2009/05/23/DownloadVisualStudio2010Beta.aspx">Download Visual Studio 2010 Beta 1</a> and try out the C# 4.0 language features yourself.</span></p>
<p> </p>
<p><span style="font-family:Verdana;font-size:x-small;"><a href="http://www.davidhayden.com/">David Hayden</a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=337&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/06/04/c-4-0-optional-parameters-and-c-4-0-named-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="http://pythonyan.wordpress.com/photos/CSharp4OptionalParameters.jpg" medium="image">
			<media:title type="html">C# 4.0 Optional Parameters</media:title>
		</media:content>
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/06/04/c-4-0-optional-parameters-and-c-4-0-named-parameters/</feedburner:origLink></item>
		<item>
		<title>A beginner’s guide for consuming a WCF service in JavaScript using ASP.NET AJAX</title>
		<link>http://feedproxy.google.com/~r/pythonyan/~3/PhHcWcwaywk/</link>
		<comments>http://pythonyan.wordpress.com/2009/03/24/a-beginner%e2%80%99s-guide-for-consuming-a-wcf-service-in-javascript-using-aspnet-ajax/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 08:05:49 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[Asp.net 3.5]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/?p=335</guid>
		<description><![CDATA[Preso da CodeProject articolo molto interessante.
Contents

Development Platform
Introduction
Using an AJAX-Enabled WCF Service Item Template
Using a Service Interface Defined in the Class Library
Configure a Web Application to Use the TODO Service
Using the Service in JavaScript
Summary
References

Development Platform

Visual Studio 2008 SP1
.NET Framework 3.5 SP1
ASP.NET AJAX
IIS 7 or VS Integrated Web Server [WCF and SVS file configured]
Windows Vista


Introduction
WCF (Windows Communication [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=335&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Preso da CodeProject <a href="http://www.codeproject.com/KB/aspnet/wcfinjavascript.aspx" target="_blank">articolo </a>molto interessante.</p>
<h2>Contents</h2>
<ul>
<li><a href="#1">Development Platform</a></li>
<li><a href="#2">Introduction</a></li>
<li><a href="#3">Using an AJAX-Enabled WCF Service Item Template</a></li>
<li><a href="#4">Using a Service Interface Defined in the Class Library</a></li>
<li><a href="#5">Configure a Web Application to Use the TODO Service</a></li>
<li><a href="#6">Using the Service in JavaScript</a></li>
<li><a href="#7">Summary</a></li>
<li><a href="#8">References</a></li>
</ul>
<h2><a name="1">Development Platform</a></h2>
<ol>
<li>Visual Studio 2008 SP1</li>
<li>.NET Framework 3.5 SP1</li>
<li>ASP.NET AJAX</li>
<li>IIS 7 or VS Integrated Web Server [WCF and SVS file configured]</li>
<li>Windows Vista</li>
</ol>
<p><img src="wcfinjavascript/ClientAjaxTodoApp.jpg" alt="ClientAjaxTodoApp.jpg" width="600" height="514" /></p>
<h2><a name="2">Introduction</a></h2>
<p>WCF (Windows Communication Foundation) added a lot of new capabilities to the  Microsoft application development platform, particularly in how applications  communicate with each other. In this article, we are going to see how WCF can be  used directly from a client-side JavaScript code. It is a very cool future  provided by ASP.NET AJAX. In this article, we are not going to cover every  theory about WCF internals, rather we only remain focused on how to use a  service directly from JavaScript. So, no behind-the-scenes stuff on how ASP.NET  or the .NET runtime manages this feature.</p>
<p>To demonstrate the ideas and facts, we are going create a demo solution with  two projects. So, with no time waste, create a blank solution and save it. Now,  add a Class Library project to the solution. Name the class library  <em>ServiceLibrary</em>. Now, add a Web Application project to the solution and  name it <em>WEBUI</em>. We are going to see two approaches to add a WCF Service  that can be consumed from JavaScript.</p>
<ol>
<li>Using Ajax-Enable WCF Service item template</li>
<li>Using Service Interface defined in a class library</li>
</ol>
<h2><a name="3">Using an AJAX-Enabled WCF Service Item Template</a></h2>
<p>Here, we will see a very straightforward way to use a WCF Service in  JavaScript. Right click on the Web Application project and select Add New Item.  Select <em>AJAX-Enabled WCF Service Item Template</em>, and name it  “<em>HelloWorldService.svc</em>” and click OK. The wizard will add a  <em>HelloWorldService.svc</em> file to the solution as expected. This file will  have a code-behind file as well. If you open <em>HelloWorldService.svc</em> in  an XML file editor, you will see a markup like this:</p>
<div id="premain0" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-pagedirective">&lt;%@</span><span class="code-leadattribute"> ServiceHost Language</span><span class="code-keyword">="</span><span class="code-keyword">C#"</span><span class="code-attribute"> Debug</span><span class="code-keyword">="</span><span class="code-keyword">true"</span><span class="code-attribute">
  Service</span><span class="code-keyword">="</span><span class="code-keyword">WebUI.HelloWorldService"</span><span class="code-attribute"> CodeBehind</span><span class="code-keyword">="</span><span class="code-keyword">HelloWorldService.svc.cs"</span><span class="code-attribute"> </span><span class="code-pagedirective">%&gt;</span></pre>
<p><img src="wcfinjavascript/ChooseItemTemplate.jpg" alt="ChooseItemTemplate.jpg" width="600" height="344" /></p>
<p>If you open the code-behind file, you will see code like this:</p>
<div id="premain1" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">namespace</span> WebUI
{
    [ServiceContract(Namespace = <span class="code-string">"</span><span class="code-string">"</span>)]
    [AspNetCompatibilityRequirements(RequirementsMode =
        AspNetCompatibilityRequirementsMode.Allowed)]
    <span class="code-keyword">public</span> <span class="code-keyword">class</span> HelloWorldService
    {
        [OperationContract]
        <span class="code-keyword">public</span> <span class="code-keyword">void</span> DoWork()
        {
            <span class="code-keyword">return</span>;
        }
    }
}</pre>
<p>Visual Studio 2008 automatically adds the necessary configurations for you in  the <em>web.config</em> file, so no need to configure any thing in the  <em>web.config</em>. Now, go ahead and add a <code>HelloWorld()</code> method  which returns a string “HelloWorld”, and add a <code>[OperationContract]</code> attribute to the method. We will explain what the attributes are later in this  article. Now, add a page to the Web Application project and name it  “<em>HelloWorldTest.aspx</em>”. Drag and drop a Script Manager item from the  Visual Studio tool box. Inside the <code>ScriptManager</code> tag, add a service  reference to the service. An example code is given below:</p>
<div id="premain2" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ScriptManager</span> <span class="code-attribute">ID</span><span class="code-keyword">="</span><span class="code-keyword">ScriptManager1"</span> <span class="code-attribute">runat</span><span class="code-keyword">="</span><span class="code-keyword">server"</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ServiceReference</span> <span class="code-attribute">Path</span><span class="code-keyword">="</span><span class="code-keyword">~/HelloWorldService.svc"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">asp:ScriptManager</span><span class="code-keyword">&gt;</span></pre>
<p>Now, add a button and a textbox to the page, and on the button click event,  use a JavaScript function to call the Service. When you write the service call  function, the Visual Studio 2008 HTML Editor will provide intellisense to write  the necessary function call. The full HTML code is give below:</p>
<div id="premain3" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">&lt;</span><span class="code-leadattribute">form</span> <span class="code-attribute">id</span><span class="code-keyword">="</span><span class="code-keyword">form1"</span> <span class="code-attribute">runat</span><span class="code-keyword">="</span><span class="code-keyword">server"</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-leadattribute">div</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">script</span> <span class="code-attribute">language</span><span class="code-keyword">="</span><span class="code-keyword">javascript"</span> <span class="code-attribute">type</span><span class="code-keyword">="</span><span class="code-keyword">text/javascript"</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">function</span> GetValueFromServer() {
            HelloWorldService.HelloWorld(onSuccess, onFailure);
        }

        <span class="code-keyword">function</span> onSuccess(result) {
            document.getElementById(<span class="code-string">'</span><span class="code-string">txtValueContainer'</span>).value = result;
        }

        <span class="code-keyword">function</span> onFailure(result) {
            window.alert(result);
        }
    <span class="code-keyword">&lt;/</span><span class="code-leadattribute">script</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ScriptManager</span> <span class="code-attribute">ID</span><span class="code-keyword">="</span><span class="code-keyword">ScriptManager1"</span> <span class="code-attribute">runat</span><span class="code-keyword">="</span><span class="code-keyword">server"</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">&lt;</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
            <span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ServiceReference</span> <span class="code-attribute">Path</span><span class="code-keyword">="</span><span class="code-keyword">~/HelloWorldService.svc"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">asp:ScriptManager</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">input</span> <span class="code-attribute">id</span><span class="code-keyword">="</span><span class="code-keyword">btnServiceCaller"</span> <span class="code-attribute">type</span><span class="code-keyword">="</span><span class="code-keyword">button"</span> <span class="code-attribute">value</span><span class="code-keyword">="</span><span class="code-keyword">Get Value"</span>
           <span class="code-attribute">onclick</span><span class="code-keyword">="</span><span class="code-keyword">GetValueFromServer()"</span><span class="code-attribute">;</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">input</span> <span class="code-attribute">id</span><span class="code-keyword">="</span><span class="code-keyword">txtValueContainer"</span> <span class="code-attribute">type</span><span class="code-keyword">="</span><span class="code-keyword">text"</span> <span class="code-attribute">value</span><span class="code-keyword">="</span><span class="code-keyword">"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">div</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">form</span><span class="code-keyword">&gt;</span></pre>
<p>Note that when calling the service, we have passed two methods: one for the  callback and the other for the error callback. If we need to pass any parameters  to the function, the parameters will go first and then the callback. So, if we  have a function named <code>getvalue</code> which takes two string parameters as  arguments, we are going to call the function as  <em>[NameSpaceName].[ServiceName].getvalue(“value one”,”value  two”,on_success,on_error);</em>, where <code>on_sucess</code> and  <code>on_error</code> are the callback and the error callback, respectively.</p>
<h2><a name="4">Using a Service Interface Defined in the Class Library</a></h2>
<p>So, we have looked at how to use an AJAX-enabled WCF Service using an item  template. Now, we are going to see a more traditional WCF Service  implementation, and we are also going to see how we can expose this service for  ASP.NET AJAX. When we created the Class Library project, by default, it is not  added with the service model and the runtime serialization support which is  necessary to run WCF. So, we have to add the necessary service references. Go  ahead and right click on the Class Library project and select Add Reference, and  then select these references:</p>
<ul>
<li><code>System.Runtime.Serialization</code></li>
<li><code>System.ServiceModel</code></li>
</ul>
<p><img src="wcfinjavascript/ProjectOfTodo.png" alt="ProjectOfTodo.png" width="421" height="572" /></p>
<p>In this phase, we are going to use a TODO Management example to demonstrate  the whole idea. Add a Service based database, and then create a <em>TODO</em> table with <code>ID</code>, <code>Description</code>, and <code>Status</code> fields. Now, add a LINQ to SQL class file from the item template. Drag and drop  the <em>TODO</em> table from database to the LINQ to SQL Class File Designer.  Now, click on the designer surface and from the property window, change the  serialization mode to Unidirectional. Now, our designer generated LINQ to SQL  classes are ready to be used for WCF. If you want to use custom user defined  types, you must set the <code>[DataContract]</code> class attribute to your  class and you must add the <code>[DataMember]</code> property attribute to each  property of the class you want to expose to WCF.</p>
<p>Now, we are going to add a service interface like this:</p>
<div id="premain4" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">namespace</span> ServiceLibrary
{
    [ServiceContract(Namespace = <span class="code-string">"</span><span class="code-string">ServiceLibrary"</span>)]
    <span class="code-keyword">interface</span> IToDoService
    {
        [OperationContract]
        ToDo GetToDo(<span class="code-keyword">long</span> ID);
        [OperationContract]
        ToDo AddToDo(ToDo toDo);
        [OperationContract]
        <span class="code-keyword">bool</span> DeleteToDo(ToDo todo);
        [OperationContract]
        ToDo UpdateToDo(ToDo todo);
        [OperationContract]
        List&lt;ToDo&gt; GetAllToDo();
    }
}</pre>
<p>Note that we have mentioned a namespace inside the  <code>ServiceContract</code> interface attribute. This is very important. We are  going to use this name as the service name inside the JavaScript code to access  the services. Now, we are going to add the implementation to this service  interface; the code is given below. Please note that in the code, I have used  the <code>[AspNetCompatibilityRequirements(RequirementsMode =  AspNetCompatibilityRequirementsMode.Allowed)]</code> class attribute; this is a  must requirement for exposing the service as an ASP.NET AJAX enabled WCF  Service.</p>
<div id="premain5" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">namespace</span> ServiceLibrary
{
    [AspNetCompatibilityRequirements(RequirementsMode =
        AspNetCompatibilityRequirementsMode.Allowed)]
    <span class="code-keyword">public</span> <span class="code-keyword">class</span> ToDoService : IToDoService
    {
        <span class="code-preprocessor">#region</span> IToDoService Members
        <span class="code-keyword">public</span> ToDo GetToDo(<span class="code-keyword">long</span> ID)
        {
            DataClasses1DataContext context = <span class="code-keyword">new</span> DataClasses1DataContext();
            var toDos = from p <span class="code-keyword">in</span> context.ToDos
                        where p.ID == ID
                        select p;
            List&lt;ToDo&gt; listTodos =  toDos.ToList();
            <span class="code-keyword">if</span> (listTodos != <span class="code-keyword">null</span> &amp;&amp; listTodos.Count &gt; <span class="code-digit">0</span>)
            {
                <span class="code-keyword">return</span> listTodos[<span class="code-digit">0</span>];
            }
            <span class="code-keyword">else</span>
            {
                <span class="code-keyword">return</span> <span class="code-keyword">null</span>;
            }
        }
        <span class="code-preprocessor">#endregion</span>
    }
}</pre>
<h2><a name="5">Configure a Web Application to Use the TODO Service</a></h2>
<p>Now that we have defined all the necessary stuff to run our TODO application,  it is time to expose the Service to the client as an ASP.NET AJAX enabled WCF  Service. For this, we are going to add an AJAX-enabled WCF Service <em>.svc</em> file. And, we will get rid of the code-behind file. Or, we can add an XML file  or a text file and then rename it to <em>ToDoService.svc</em>. Open it with an  XML editor and add a directive like shown below:</p>
<div id="premain6" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-pagedirective">&lt;%@</span><span class="code-leadattribute"> ServiceHost Language</span><span class="code-keyword">="</span><span class="code-keyword">C#"</span><span class="code-attribute"> Debug</span><span class="code-keyword">="</span><span class="code-keyword">true"</span><span class="code-attribute"> Service</span><span class="code-keyword">="</span><span class="code-keyword">ServiceLibrary.ToDoService"</span><span class="code-attribute"> </span><span class="code-pagedirective">%&gt;</span></pre>
<p>Now, we are going to put the necessary configuration to run this service in  <em>web.config</em>. The code is given below:</p>
<div id="premain7" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">&lt;</span><span class="code-leadattribute">system.serviceModel</span><span class="code-keyword">&gt;</span>
  <span class="code-keyword">&lt;</span><span class="code-leadattribute">behaviors</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-leadattribute">endpointBehaviors</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">behavior</span> <span class="code-attribute">name</span><span class="code-keyword">="</span><span class="code-keyword">AspNetAjaxBehavior"</span><span class="code-keyword">&gt;</span>
     <span class="code-keyword">&lt;</span><span class="code-leadattribute">enableWebScript</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">behavior</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">behavior</span> <span class="code-attribute">name</span><span class="code-keyword">="</span><span class="code-keyword">WebUI.HelloWorldServiceAspNetAjaxBehavior"</span><span class="code-keyword">&gt;</span>
     <span class="code-keyword">&lt;</span><span class="code-leadattribute">enableWebScript</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">behavior</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">endpointBehaviors</span><span class="code-keyword">&gt;</span>
  <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">behaviors</span><span class="code-keyword">&gt;</span>
  <span class="code-keyword">&lt;</span><span class="code-leadattribute">serviceHostingEnvironment</span> <span class="code-attribute">aspNetCompatibilityEnabled</span><span class="code-keyword">="</span><span class="code-keyword">true"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
  <span class="code-keyword">&lt;</span><span class="code-leadattribute">services</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-leadattribute">service</span> <span class="code-attribute">name</span><span class="code-keyword">="</span><span class="code-keyword">ServiceLibrary.ToDoService"</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">endpoint</span> <span class="code-attribute">behaviorConfiguration</span><span class="code-keyword">="</span><span class="code-keyword">AspNetAjaxBehavior"</span> <span class="code-attribute">binding</span><span class="code-keyword">="</span><span class="code-keyword">webHttpBinding"</span>
     <span class="code-attribute">contract</span><span class="code-keyword">="</span><span class="code-keyword">ServiceLibrary.IToDoService"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">service</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-leadattribute">service</span> <span class="code-attribute">name</span><span class="code-keyword">="</span><span class="code-keyword">WebUI.HelloWorldService"</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">endpoint</span> <span class="code-attribute">address</span><span class="code-keyword">="</span><span class="code-keyword">"</span> <span class="code-attribute">behaviorConfiguration</span><span class="code-keyword">="</span><span class="code-keyword">WebUI.HelloWorldServiceAspNetAjaxBehavior"</span>
     <span class="code-attribute">binding</span><span class="code-keyword">="</span><span class="code-keyword">webHttpBinding"</span> <span class="code-attribute">contract</span><span class="code-keyword">="</span><span class="code-keyword">WebUI.HelloWorldService"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
   <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">service</span><span class="code-keyword">&gt;</span>
  <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">services</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">system.serviceModel</span><span class="code-keyword">&gt;</span></pre>
<p>Now, right click on the file and select View in Browser to see the service up  and running well. A few things must be mentioned before moving to the next  phase. You must add a <code>serviceHostingEnvironment</code> and set <code>aspNetCompatibilityEnabled="true"</code> to be able to use a WCF  Service in ASP.NET with its features like HTTP Context, Session etc.</p>
<h2><a name="6">Using the Service in JavaScript</a></h2>
<p>Now, use the service just like the HelloWorldService we previously used.  Below, I have given example code to make things clear. The  <code>ScriptManager</code> markup is also shown. Note that we have added a  <em>clientServiceHelper.js</em> file. We have put all the client to WCF  communication JavaScript functions in that file.</p>
<div id="premain8" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;"><span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ScriptManager</span> <span class="code-attribute">ID</span><span class="code-keyword">="</span><span class="code-keyword">ScriptManager1"</span> <span class="code-attribute">runat</span><span class="code-keyword">="</span><span class="code-keyword">server"</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">Scripts</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ScriptReference</span> <span class="code-attribute">Path</span><span class="code-keyword">="</span><span class="code-keyword">~/Script/ClientServiceHeler.js"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">Scripts</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
        <span class="code-keyword">&lt;</span><span class="code-leadattribute">asp:ServiceReference</span> <span class="code-attribute">Path</span><span class="code-keyword">="</span><span class="code-keyword">~/ToDoService.svc"</span> <span class="code-keyword">/</span><span class="code-keyword">&gt;</span>
    <span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">Services</span><span class="code-keyword">&gt;</span>
<span class="code-keyword">&lt;</span><span class="code-keyword">/</span><span class="code-leadattribute">asp:ScriptManager</span><span class="code-keyword">&gt;</span></pre>
<p>We have used an ASP.NET AJAX client-side object oriented model to write the  JavaScript client-code which is part of <em>clientServiceHelper.js</em>.</p>
<div id="premain9" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;">Type.registerNamespace(<span class="code-string">"</span><span class="code-string">ServiceClients"</span>);
    ServiceClients.ToDoClient = function() {
}

ServiceClients.ToDoClient.prototype = {

    AddToDo: function(todo, callback, errorCallBack) {
        ServiceLibrary.IToDoService.AddToDo(todo, callback, errorCallBack);
    },

    DeleteToDo: function(todo, callback, errorCallBack) {
        ServiceLibrary.IToDoService.DeleteToDo(todo, callback, errorCallBack);
    },

    UpdateToDo: function(todo, callback, errorCallBack) {
        ServiceLibrary.IToDoService.UpdateToDo(todo, callback, errorCallBack);
    },

    GetAllToDo: function(callback, errorCallBack) {
        ServiceLibrary.IToDoService.GetAllToDo(callback, errorCallBack);
    },

    dispose: function() {
    }
}

ServiceClients.ToDoClient.registerClass(<span class="code-string">'</span><span class="code-string">ServiceClients.ToDoClient'</span>, <span class="code-keyword">null</span>, Sys.IDisposable)

<span class="code-keyword">if</span> (<span class="code-keyword">typeof</span> (Sys) !== <span class="code-string">'</span><span class="code-string">undefined'</span>) Sys.Application.notifyScriptLoaded();</pre>
<h2><a name="7">Summary</a></h2>
<p>In this article, we have seen how we can use an AJAX-enabled WCF Service Item  Template. Then, we saw how we can use a service interface based WCF Service. We  also saw how to configure the <em>web.config</em> to use the Services. Last of  all, we saw how we to add a service reference in <code>ScriptManager</code>. A  few things must be mentioned before ending this article. We can also add a  service reference in the C# code. A simple code example is given below:.</p>
<div id="premain10" class="SmallText" style="width:100%;"><img style="cursor:pointer;" src="http://www.codeproject.com/images/minus.gif" alt="" width="9" height="9" /><span style="margin-bottom:0;cursor:pointer;"> Collapse</span><img style="margin-left:35px;" src="http://www.codeproject.com/images/copy_16.png" alt="" width="16" height="16" /><a href="#"> Copy Code</a></div>
<pre style="margin-top:0;">ScriptManager manager = ScriptManager.GetCurrent(Page);
ServiceReference reference = <span class="code-keyword">new</span> ServiceReference(<span class="code-string">"</span><span class="code-string">ToDoService.svc"</span>);
manager.Services.Add(reference);</pre>
<p>If beginners encounter problems or do not understand any particular portion  of the article, please drop me a message. You can learn the ABCs of WCF <a href="http://msdn.microsoft.com/en-us/library/aa480190.aspx" target="_blank">here</a>. If you have any difficulty configuring WCF in IIS,  please see the article <a href="http://msdn.microsoft.com/en-us/library/bb763177.aspx" target="_blank">here</a>.</p>
<h2><a name="8">References</a></h2>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa480190.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/aa480190.aspx</a> [WCF -  ABC]</li>
<li><a href="http://munna.shatkotha.com/Blog/post/2008/07/08/Install-WCF-Aspnet-in-IIS7.aspx" target="_blank">http://munna.shatkotha.com/Blog/post/2008/07/08/Install-WCF-Aspnet-in-IIS7.aspx</a> [Configure WCF]</li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb514961.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb514961.aspx</a> [Expose  WCF to Client Script]</li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb763177.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bb763177.aspx</a> [Configure WCF in an ASP.NET Environment]</li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb398785.aspx">http://msdn.microsoft.com/en-us/library/bb398785.aspx</a> [Web Services in ASP.NET]</li>
<li><a href="http://peterkellner.net/2008/09/14/wcf-web-service-json-vs2008/" target="_blank">http://peterkellner.net/2008/09/14/wcf-web-service-json-vs2008/</a> [Article discussing the same concept]</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/335/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/335/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/335/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/335/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/335/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=335&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/03/24/a-beginner%e2%80%99s-guide-for-consuming-a-wcf-service-in-javascript-using-aspnet-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="wcfinjavascript/ClientAjaxTodoApp.jpg" medium="image">
			<media:title type="html">ClientAjaxTodoApp.jpg</media:title>
		</media:content>

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="wcfinjavascript/ChooseItemTemplate.jpg" medium="image">
			<media:title type="html">ChooseItemTemplate.jpg</media:title>
		</media:content>

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="wcfinjavascript/ProjectOfTodo.png" medium="image">
			<media:title type="html">ProjectOfTodo.png</media:title>
		</media:content>

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />

		<media:content url="http://www.codeproject.com/images/minus.gif" medium="image" />

		<media:content url="http://www.codeproject.com/images/copy_16.png" medium="image" />
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/03/24/a-beginner%e2%80%99s-guide-for-consuming-a-wcf-service-in-javascript-using-aspnet-ajax/</feedburner:origLink></item>
		<item>
		<title />
		<link>http://feedproxy.google.com/~r/pythonyan/~3/C_PHwV6jLrE/</link>
		<comments>http://pythonyan.wordpress.com/2009/03/11/334/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 15:55:55 +0000</pubDate>
		<dc:creator>pythonyan</dc:creator>
				<category><![CDATA[NET]]></category>

		<guid isPermaLink="false">http://pythonyan.wordpress.com/2009/03/11/334/</guid>
		<description><![CDATA[James Last &#8211; Romance
bellissima
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=334&subd=pythonyan&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><b>James Last &#8211; Romance</b><br />
<span style="text-align:center; display: block;"><a href="http://pythonyan.wordpress.com/2009/03/11/334/"><img src="http://img.youtube.com/vi/2epsvd9EjzU/2.jpg" alt="" /></a></span><br />bellissima</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pythonyan.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pythonyan.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pythonyan.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pythonyan.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pythonyan.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pythonyan.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pythonyan.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pythonyan.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pythonyan.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pythonyan.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pythonyan.wordpress.com&blog=1393879&post=334&subd=pythonyan&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://pythonyan.wordpress.com/2009/03/11/334/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/86d14eb34cd8ef5583383c4a8612c0b1?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">pythonyan</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/2epsvd9EjzU/2.jpg" medium="image" />
	<feedburner:origLink>http://pythonyan.wordpress.com/2009/03/11/334/</feedburner:origLink></item>
	</channel>
</rss>
