<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Incandescent Blur</title>
	<atom:link href="http://guerven.com/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://guerven.com/wordpress</link>
	<description>.Net Developer's notes</description>
	<lastBuildDate>Tue, 01 Sep 2009 10:17:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XMl in .Net</title>
		<link>http://guerven.com/wordpress/?p=18</link>
		<comments>http://guerven.com/wordpress/?p=18#comments</comments>
		<pubDate>Tue, 01 Sep 2009 07:36:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://guerven.com/wordpress/?p=18</guid>
		<description><![CDATA[In Many cases we may need to send information across services in XML form.
Some common practice is to create a class as a model and serialize it to XML after assigning values.
Or you can use from a variety of ways in which .Net support XML data, such as Xpath, xdocument, xpathnavigator yada, yada
And then there [...]]]></description>
			<content:encoded><![CDATA[<p>In Many cases we may need to send information across services in XML form.<br />
Some common practice is to create a class as a model and serialize it to XML after assigning values.</p>
<p>Or you can use from a variety of ways in which .Net support XML data, such as Xpath, xdocument, xpathnavigator yada, yada</p>
<p>And then there is Linq XML.  namespace System.Linq.Xml;</p>
<p>With Linq to XMl, we can create Xml fragments easily.<br />
The code below shows how to create an Xml fragment from a Dictionary.<br />
 assuming resultPair is a Dictionary<string,string> with values.</p>
<hr/>
<code><br />
                    XDocument doc = new XDocument(<br />
                    new XElement("Results",<br />
                        from myListItem in resultPair<br />
                        select<br />
                            new XElement("Pair",<br />
                            new XElement("Key", myListItem.Key),<br />
                            new XElement("Value", myListItem.Value)<br />
                            )<br />
                            )<br />
                        );<br />
</code></p>
<hr/>
<p>Now You&#8217;ve seen the big chunk, lets break it down!</p>
<p>Now to break it down we can start with the XElement<br />
<code><br />
XElement myVar = new XElement("elementName", "any xml data");<br />
</code></p>
<p>myVar will have the value of &#8220;&lt;elementName&gt;any xml data&lt;/elementName&gt;&#8221;</p>
<p>likewise<br />
<code><br />
XElement myVar = new XElement("elementName1",<br />
                                           new XElement("elementName2", "any xml data")<br />
                                    );<br />
</code><br />
myVar will have the value of &#8220;&lt;elementName1&gt;<br />
                                             &lt;elementName2&gt;<br />
                                                any xml data<br />
                                             &lt;/elementName2&gt;<br />
                                       &lt;/elementName1&gt;&#8221;</p>
<p>I&#8217;ll Continue on this topic on my next blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://guerven.com/wordpress/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing with Cache</title>
		<link>http://guerven.com/wordpress/?p=5</link>
		<comments>http://guerven.com/wordpress/?p=5#comments</comments>
		<pubDate>Fri, 28 Aug 2009 04:36:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Testing]]></category>

		<guid isPermaLink="false">http://guerven.com/wordpress/?p=5</guid>
		<description><![CDATA[One time I was working on a TEST-project for one of my web projects, I basically needed to test a UserControl. However, one of the function I need to test is referring to the  HttpContext.Current.Cache. .
Running the test without a running web application will cause an error because HttpContext.Current.Cache is null.
So the solution was [...]]]></description>
			<content:encoded><![CDATA[<p>One time I was working on a TEST-project for one of my web projects, I basically needed to test a UserControl. However, one of the function I need to test is referring to the  <strong>HttpContext.Current.Cache. </strong>.</p>
<p>Running the test without a running web application will cause an error because HttpContext.Current.Cache is null.</p>
<p>So the solution was to create a sort of a dummy HttpContext.Current.</p>
<p>and heres how to do it.</p>
<hr/>
<code><br />
TextWriter txtw = new StringWriter();<br />
HttpWorkerRequest hwr= new SimpleWorkerRequest("/webapp", "c:\\inetpub\\wwwroot\\webapp\\", "default.aspx", "", txtw );<br />
HttpContext.Current = new HttpContext(hwr);<br />
</code></p>
<hr/>
<p>after this HttpContext.Current.Cache is now accessible.</p>
<p>or even simpler</p>
<hr/>
<code><br />
   HttpContext.Current = new HttpContext(new HttpRequest(null, "http://tempuri.org", null), new HttpResponse(null));<br />
</code></p>
<hr/>
<p>However if you want to access <strong>HttpContext.Current.Session</strong><br />
then I suggest you check this Website for more options<br />
 <a href="http://www.eioba.com/a75384/unit_test_web_code_without_a_web_server_using_httpsimulator">Unit Test Web Code</a></p>
<p>You can also download the code files for simulating HTTP stuff.  It Should be easy to find in the link above.</p>
]]></content:encoded>
			<wfw:commentRss>http://guerven.com/wordpress/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
