<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sam Lam's Weblog</title>
	<atom:link href="http://samuellam.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://samuellam.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 08 Aug 2011 07:07:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='samuellam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Sam Lam's Weblog</title>
		<link>http://samuellam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://samuellam.wordpress.com/osd.xml" title="Sam Lam&#039;s Weblog" />
	<atom:link rel='hub' href='http://samuellam.wordpress.com/?pushpress=hub'/>
		<item>
		<title>C# Singleton for Facade Pattern</title>
		<link>http://samuellam.wordpress.com/2011/08/07/c-sharp-singleton-for-facade-pattern/</link>
		<comments>http://samuellam.wordpress.com/2011/08/07/c-sharp-singleton-for-facade-pattern/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 07:06:13 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=220</guid>
		<description><![CDATA[While researching the facade pattern that can be implemented in similar way to HttpContext (in ASP.net), I came to a MSDN article that talks about implementing the singleton pattern in C#. It is fairly straight forward and works extremely well for what I needed for the project. Here is the context class, which exposees the CMSManager [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=220&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While researching the facade pattern that can be implemented in similar way to HttpContext (in ASP.net), I came to a <a href="http://msdn.microsoft.com/en-us/library/ff650316.aspx" target="_blank">MSDN article</a> that talks about implementing the singleton pattern in C#. It is fairly straight forward and works extremely well for what I needed for the project.</p>
<p>Here is the context class, which exposees the CMSManager (a factory class). The context manages the instantiation and destruction of the facade:</p>
<p><pre class="brush: csharp;">
public sealed partial class CMSContext
{
	/// &lt;summary&gt;
	/// clutch object is used to prevent multiple access during the initialization
	/// &lt;/summary&gt;
	private static object clutch = new object();
	/// &lt;summary&gt;
	/// actual instance of the CMSContext object
	/// &lt;/summary&gt;
	private static volatile CMSContext uniqueInstance;

	/// &lt;summary&gt;
	/// instance of the CMSManager
	/// &lt;/summary&gt;
	private CMSManager _cmsFacade = null;

	/// &lt;summary&gt;
	/// Gets the CMS facade.
	/// &lt;/summary&gt;
	public CMSManager CMSFacade
	{
		get
		{
			return _cmsFacade;
		}
	}

	/// &lt;summary&gt;
	/// Prevents a default instance of the &lt;see cref=&quot;CMSContext&quot;/&gt; class from being created.
	/// &lt;/summary&gt;
	private CMSContext()
	{
		_cmsFacade = new CMSManager();
	}

	/// &lt;summary&gt;
	/// Gets the instance.
	/// &lt;/summary&gt;
	public static CMSContext Instance
	{
		get
		{
			if (uniqueInstance == null)
			{
				lock (clutch)
				{
					if (uniqueInstance == null)
						uniqueInstance = new CMSContext();
				}
			}
			return uniqueInstance;
		}
	}

	/// &lt;summary&gt;
	/// Releases unmanaged resources and performs other cleanup operations before the
	/// &lt;see cref=&quot;CMSContext&quot;/&gt; is reclaimed by garbage collection.
	/// &lt;/summary&gt;
	~CMSContext()
	{
		if (_cmsFacade != null) _cmsFacade.Dispose();
	}

}


</pre></p>
<p>This context class simplifies the way my client application accesses the CMS subsystem. It only requires two lines of code to access the factory class.</p>
<p><pre class="brush: csharp;">
CMSContext cms = CMSContext.Instance;

ContentFile f = new ContentFile();
f.FileName = &quot;Test.txt&quot;;
f.FileSize = 10;
f.LastModified = DateTime.Now;

cms.CMSFacade.SaveContent(f);
</pre></p>
<p>One important note to achieve this simplicity, both context class and factory class should be autonomous; if there is any external dependency, it can make the client code messy.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=220&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2011/08/07/c-sharp-singleton-for-facade-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting the MAC and IP address in .net</title>
		<link>http://samuellam.wordpress.com/2011/03/27/getting-the-mac-and-ip-address-in-net/</link>
		<comments>http://samuellam.wordpress.com/2011/03/27/getting-the-mac-and-ip-address-in-net/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 23:58:47 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=210</guid>
		<description><![CDATA[System.Net.NetworkInformation namespace provides MAC and IP address in .net <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=210&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It took me forever to find this information and the solution was extremely simple. The System.Net.NetworkInformation namespace provides network card information.</p>
<p><pre class="brush: csharp;">
static void Main(string[] args)
{
  NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().Where(a=&gt; a.OperationalStatus.Equals( OperationalStatus.Up)).FirstOrDefault();
  string macAddress = networkInterface.GetPhysicalAddress().ToString();
  string clientIp = networkInterface.GetIPProperties().UnicastAddresses[0].Address.ToString();
}

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=210&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2011/03/27/getting-the-mac-and-ip-address-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>WCF REST 4 anonymous output</title>
		<link>http://samuellam.wordpress.com/2010/12/26/wcf-rest-4-anonymous-output/</link>
		<comments>http://samuellam.wordpress.com/2010/12/26/wcf-rest-4-anonymous-output/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 20:05:35 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=164</guid>
		<description><![CDATA[A step-by-step guide to create WCF REST service that supports anonymous output. All you need is Visual Studio 2010 and Microsoft WCF REST 4 template<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=164&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Using RESTful service is definitely the way to go. It&#8217;s practical and easier to consume. I always opt for simplicity when choosing a design approach and WCF REST template is definitely the hammer in my toolbox.</p>
<p>However, I came to a problem when trying to expose anonymous object as output. I would get a runtime &#8220;Request Error&#8221; whenever using object as the return type.</p>
<p>BACKGROUND: WCF requires strong return type which creates unnecessary complexity. It doesn&#8217;t make sense to create a return type for each of my WCF REST methods. I would rather go back to SOAP the old way. Beside WCF, I&#8217;ve always been creating REST service just using ASP.net which, in my view, is extremely easy. After a day of digging around the Google search, I found only bits and pieces of information. Then I came across System.ServiceModel.Channels.Message type which gave me an idea to create a string output inside the Message. It gives me the freedom to manipulate the output however I want.</p>
<p>So here are the steps to setup the project. First download the WCF REST Service template using the Extension Manager in Visual Studio 2010</p>
<p><a href="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-extmgr.gif"><img class="alignnone size-medium wp-image-166" title="AnonymousWCF.ExtMgr" src="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-extmgr.gif?w=248&#038;h=300" alt="Extension Manager" width="248" height="300" /></a></p>
<p>Just install the template provided by Microsoft</p>
<p><a href="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-template.gif"><img class="alignnone size-medium wp-image-167" title="AnonymousWCF.Template" src="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-template.gif?w=300&#038;h=162" alt="WCF REST 4 template" width="300" height="162" /></a></p>
<p>Create new project using the new template &#8220;WCF REST Service Application&#8221;. The template pretty much setup everything and it should give you the Hello World sample output when running it. The new template should be listed under Visual C# category. (you will notice the template is quite different from the WCF Service Application; in most of my works, I can do away with interface definitions; this makes it easier to read the codes without flipping between two different cs files)</p>
<p>Follow these steps to create a method to return a Message type that contains the anonymous object.</p>
<p>Add the following references in the Service1.cs file<br />
<pre class="brush: csharp;">

using System.ServiceModel.Channels;
using System.Net;
using System.Web.Script.Serialization;

</pre></p>
<p>Add a new method called JSON_Anonymous()</p>
<p><pre class="brush: csharp;">

[WebGet(UriTemplate = &quot;/JSON&quot;)]
public Message JSON_Anonymous()
{
  WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.ContentType] = &quot;application/json&quot;;
  var ret = new
  {
    Name = &quot;John Doe&quot;
    ,Title = &quot;SVP Sales and Marketing&quot;
  };

  return WebOperationContext.Current.CreateTextResponse(ret.ToJSON());
}

</pre></p>
<p>I added a ToJSON extension method to the cs file as well, to help simplify my code. ToJSON Original source was from <a href="http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx">Scott Gu&#8217;s blog</a></p>
<p><pre class="brush: csharp;">

public static class JSONHelper
{
  public static string ToJSON(this object obj)
  {
    JavaScriptSerializer jss = new JavaScriptSerializer();
    return jss.Serialize(obj);
  }
}
</pre></p>
<p>Go ahead run the program and download the JSON output</p>
<p><a href="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-output.gif"><img class="alignnone size-medium wp-image-169" title="AnonymousWCF.Output" src="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-output.gif?w=300&#038;h=207" alt="WCF REST anonymous JSON output" width="300" height="207" /></a></p>
<p>The output should look like this<br />
<pre class="brush: jscript;">
{
    &quot;Name&quot;: &quot;John Doe&quot;,
    &quot;Title&quot;: &quot;SVP Sales and Marketing&quot;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=164&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/12/26/wcf-rest-4-anonymous-output/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>

		<media:content url="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-extmgr.gif?w=248" medium="image">
			<media:title type="html">AnonymousWCF.ExtMgr</media:title>
		</media:content>

		<media:content url="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-template.gif?w=300" medium="image">
			<media:title type="html">AnonymousWCF.Template</media:title>
		</media:content>

		<media:content url="http://samuellam.files.wordpress.com/2010/12/anonymouswcf-output.gif?w=300" medium="image">
			<media:title type="html">AnonymousWCF.Output</media:title>
		</media:content>
	</item>
		<item>
		<title>IsNumeric() function</title>
		<link>http://samuellam.wordpress.com/2010/12/02/isnumeric-function/</link>
		<comments>http://samuellam.wordpress.com/2010/12/02/isnumeric-function/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 17:33:53 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=151</guid>
		<description><![CDATA[IsNumeric() function to validate numeric value in javascript<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=151&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A simple IsNumeric() function to validate numeric variables in javascript</p>
<p><pre class="brush: jscript;">
    function IsNumeric(input)
    {
        input = input + &quot;&quot;;
        return (input/1) == input &amp;&amp; input.length &gt; 0;
    }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=151&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/12/02/isnumeric-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>Decoding Numara Footprints special characters</title>
		<link>http://samuellam.wordpress.com/2010/11/24/decoding-numara-footprints-special-characters/</link>
		<comments>http://samuellam.wordpress.com/2010/11/24/decoding-numara-footprints-special-characters/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 21:04:36 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Footprints]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=138</guid>
		<description><![CDATA[Create a SQL user-defined function to decode Footprints special characters<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=138&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My client wants to query and run report against the <a href="http://www.numarasoftware.com/footprints/service_desk_software.aspx">Footprints </a>database, which is a Microsoft SQL server. It was simple enough until we noticed the data have some kind of encoding, a blank space will appear to be &#8220;__b&#8221;. This applies to all the records and fields. After contacting the support, I was given a list of all the encoding values.</p>
<p>To be able to decode the data in a query, I built an user-defined function to simplify the conversion for me. A quick and dirty solution.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Note: the collate clause tells the SQL server to compare string in case-sensitive manner.</p>
<p><pre class="brush: sql;">

CREATE function [dbo].[udf_decodeFootprintsStringValue] (@pFootprintValue varchar(2000)) 
returns varchar(2000)
as
	begin
		declare @pMappedValue varchar(2000)
		set @pMappedValue = replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(
							replace(@pFootprintValue COLLATE SQL_Latin1_General_CP1_CS_AS
								, '__' + char(66), '!')  --B
								, '__' + char(98), ' ')  --b
								, '__' + char(65), '+')  --A
								, '__f', '/')
								, '__' + char(117), '-') --u
								, '__4', '$')
								, '__' + char(71), '&lt;')  --G
								, '__a', '''')
								, '__5', '%')
								, '__' + char(113), '&quot;') --q
								, '__6', '^')
								, '__' + char(87), '{')  --W
								, '__t', '`')
								, '__7', '%')
								, '__' + char(119), '}') --w
								, '__' + char(109), '@') --m
								, '__8', '*')
								, '__' + char(67), '=')  --C
								, '__' + char(100), '.') --d
								, '__0', '~')
								, '__I', '|')
								, '__s', ';')
								, '__' + char(70), '\')  --F
								, '__' + char(77), ',')  --M
								, '__' + char(99), ':')  --c
								, '__' + char(81), '?')  --Q
								, '__' + char(112), ')') --p
								, '__' + char(101), ']') --e
								, '__' + char(80), '(')  --P
								, '__' + char(69), '[')  --E
								, '__3', '#')
								, '__' + char(103), '&gt;') --g


		return @pMappedValue
	end


</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=138&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/11/24/decoding-numara-footprints-special-characters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>Capture SOAP Envelope using ASP.net</title>
		<link>http://samuellam.wordpress.com/2010/11/23/capture-soap-envelope-using-asp-net/</link>
		<comments>http://samuellam.wordpress.com/2010/11/23/capture-soap-envelope-using-asp-net/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 17:49:01 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[InputStream]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=124</guid>
		<description><![CDATA[Built a simple ASP web page to capture SOAP envelope <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=124&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to use the jQuery to post a 3rd party webservice call. First step is to understand the SOAP envelope. With <a href="http://www.soapui.org/">soapUI</a>, I was able to construct the SOAP envelope from the WSDL. However, the API involves complexType with objects inside nested arrays. The base envelope was not useful to me. </p>
<p>Since I&#8217;m not familiar with constructing complexType xml from scratch, I have to find an easy way to build the xml. The best route is to trace the exact SOAP call from my other .net application. So i built a simple ASP web application to capture the service call.</p>
<p>In the code behind, the ASP writes the data from Request.InputStream into a local file.</p>
<p><pre class="brush: csharp;">
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (string o in Request.Params)
        {
            Response.Write(o + &quot; : &lt;span style='color:#a3a3a3'&gt;&quot; 
                 + Request[o] 
                 + &quot;&lt;/span&gt;&lt;br/&gt;&quot; 
                 + System.Environment.NewLine);
        }
        Stream file = File.OpenWrite(Server.MapPath(&quot;RequestStream.txt&quot;));
        CopyStream(Request.InputStream, file);
        file.Flush(); 
        file.Close();

    }
}
</pre></p>
<p>found this code snippet to write stream data into a file</p>
<p><pre class="brush: csharp;">

    public void CopyStream(Stream input, Stream output)
    {
        byte[] buffer = new byte[8 * 1024];
        int len;
        while ((len = input.Read(buffer, 0, buffer.Length)) &gt; 0)
        {
            output.Write(buffer, 0, len);
        }
    } 

</pre></p>
<p>By changing the URL (to the url of this ASP site) on my other .net application, I was able to capture the content of the SOAP envelope.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=124&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/11/23/capture-soap-envelope-using-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Calendar table</title>
		<link>http://samuellam.wordpress.com/2010/11/22/sql-calendar-table/</link>
		<comments>http://samuellam.wordpress.com/2010/11/22/sql-calendar-table/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 21:17:50 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=118</guid>
		<description><![CDATA[The InsertCalendar procedure is written in a way that i can repopulate/ refresh an existing calendar table. Much of the logic was originally taken from this link &#160; &#160; &#160; MilitaryHour Hour AMPM 0 12 AM 1 1 AM 2 2 AM 3 3 AM 4 4 AM 5 5 AM 6 6 AM 7 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=118&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The InsertCalendar procedure is written in a way that i can repopulate/ refresh an existing calendar table. Much of the logic was originally taken from <a href="http://consultingblogs.emc.com/jamespipe/archive/2007/04/24/T_2D00_SQL-Calendar-table.aspx">this link</a></p>
<p>&nbsp;</p>
<p><pre class="brush: sql;">

CREATE TABLE [dbo].[CORP_Calendar](
       [date] [datetime] NULL,
       [day of year] [int] NULL,
       [day] [nvarchar](30) NULL,
       [day of week] [int] NULL,
       [day of month] [int] NULL,
       [week] [int] NULL,
       [month] [int] NULL,
       [monthName] [nvarchar](30) NULL,
       [quarter] [int] NULL,
       [year] [int] NULL,
       [weekby7days] [varchar](7) NULL
)



ALTER Proc [dbo].[InsertCalendar]
as
/*
 * code from internet http://consultingblogs.emc.com/jamespipe/archive/2007/04/24/T_2D00_SQL-Calendar-table.aspx
 * to generate calendar table
 */
SET NOCOUNT ON

declare @start datetime, @end datetime
declare @no_of_Days bigint

set @start = '2000-01-01'
set @end = '2020-01-01'

set @no_of_days = datediff(dd,@start,@end) + 1

set rowcount @no_of_days
select identity(bigint,0,1) as dy 
into #temp 
from syscolumns a, syscolumns b
set rowcount 0

drop INDEX IX_CORP_Calendar on dbo.CORP_Calendar 

Truncate table dbo.CORP_Calendar
INSERT dbo.CORP_Calendar
select dateadd(dd,dy,@start) as [date] 
    ,datepart(dy, dateadd(dd,dy,@start)) [day of year]
    ,datename(dw, dateadd(dd,dy,@start)) [day]
    ,datepart(dw, dateadd(dd,dy,@start)-1) [day of week]
    ,datepart(dd, dateadd(dd,dy,@start)) [day of month]
    ,datepart(ww, dateadd(dd,dy,@start)) [week]
    ,datepart(mm, dateadd(dd,dy,@start)) [month]
    ,datename(mm, dateadd(dd,dy,@start)) [monthName]
    ,datepart(qq, dateadd(dd,dy,@start)) [quarter]
    ,datepart(yy, dateadd(dd,dy,@start)) [year]
       ,null as [weekby7days]
from #temp
drop table #temp

Create clustered INDEX IX_CORP_Calendar on dbo.CORP_Calendar ([Date])

update dbo.CORP_Calendar
set weekby7days = dbo.udf_GetWeek (date)

SET NOCOUNT OFF



</pre></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><pre class="brush: sql;">
CREATE TABLE [dbo].[CORP_Hour](
       [MilitaryHour] [int] NOT NULL,
       [Hour] [int] NOT NULL,
       [AMPM] [varchar](2) NOT NULL,
 CONSTRAINT [PK_CORP_Hour] PRIMARY KEY CLUSTERED 
(
       [MilitaryHour] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
)

</pre></p>
<p><code><br />
MilitaryHour  Hour   AMPM<br />
0      12     AM<br />
1      1      AM<br />
2      2      AM<br />
3      3      AM<br />
4      4      AM<br />
5      5      AM<br />
6      6      AM<br />
7      7      AM<br />
8      8      AM<br />
9      9      AM<br />
10     10     AM<br />
11     11     AM<br />
12     12     PM<br />
13     1      PM<br />
14     2      PM<br />
15     3      PM<br />
16     4      PM<br />
17     5      PM<br />
18     6      PM<br />
19     7      PM<br />
20     8      PM<br />
21     9      PM<br />
22     10     PM<br />
23     11     PM<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=118&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/11/22/sql-calendar-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>Render DataTable as HTML Table</title>
		<link>http://samuellam.wordpress.com/2010/11/18/render-datatable-as-html-table/</link>
		<comments>http://samuellam.wordpress.com/2010/11/18/render-datatable-as-html-table/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 00:44:43 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=99</guid>
		<description><![CDATA[This is a fairly simple c# function to convert any DataTable into HTML table. This function works perfectly well with iqy file feeding tabular data into Excel.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=99&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a fairly simple c# function to convert any DataTable into HTML table. This function works perfectly well with iqy file feeding tabular data into Excel.</p>
<p><pre class="brush: csharp;">
    public static string ConvertDataTable2HTMLString(DataTable dt)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append(&quot;&lt;html&gt;&lt;body&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&quot;);
        foreach (DataColumn c in dt.Columns)
        {
            sb.AppendFormat(&quot;&lt;th&gt;{0}&lt;/th&gt;&quot;, c.ColumnName);
        }
        sb.AppendLine(&quot;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&quot;);
        foreach (DataRow dr in dt.Rows)
        {
            sb.Append(&quot;&lt;tr&gt;&quot;);
            foreach (object o in dr.ItemArray)
            {
                sb.AppendFormat(&quot;&lt;td&gt;{0}&lt;/td&gt;&quot;, Server.HtmlEncode(o.ToString()));
            }
            sb.AppendLine(&quot;&lt;/tr&gt;&quot;);
        }
        sb.AppendLine(&quot;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
        return sb.ToString();
    }
</pre></p>
<p> </p>
<p>Here&#8217;s the sample iqy Excel file to query data that are in HTML table format</p>
<p><pre class="brush: plain;">
WEB
1
http://url/PATH/script.aspx

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=99&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/11/18/render-datatable-as-html-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>c# extensions</title>
		<link>http://samuellam.wordpress.com/2010/03/21/c-extensions/</link>
		<comments>http://samuellam.wordpress.com/2010/03/21/c-extensions/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 01:47:12 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=81</guid>
		<description><![CDATA[c# Example found on the net, demonstrated how Dot Net 3 extensions are declared and consumed.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=81&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>c# Example found on the net, demonstrated how Dot Net 3 extensions are declared and consumed.<br />
<pre class="brush: csharp;">
namespace myExtensionExample
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] values = { 5, 6, 10 };

            bool isInArray = 7.In(values);

            string[] s_vals = { &quot;5&quot;, &quot;6&quot;, &quot;10&quot; };
            bool isInStringArray = &quot;10&quot;.In(s_vals);

            string s = &quot;Hello Extension Methods&quot;;
            int i = s.WordCount();
        }
    }

    //define extension methods within a static class
    public static class myExtensions
    {
        //'this' parameter is usually used on object where the method is applied to
        public static int WordCount(this string str)
        {
            return str.Split(new char[] { ' ', '.', '?' }, StringSplitOptions.RemoveEmptyEntries).Length;
        }
        public static bool In(this T o, IEnumerable items)
        {
            foreach (T item in items)
            {
                if (item.Equals(o))
                    return true;
            }
            return false;
        }
    }
}
</pre></p>
<p>Original materials from <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx">http://msdn.microsoft.com/en-us/library/bb383977.aspx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=81&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2010/03/21/c-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
		<item>
		<title>Objective-C link to website</title>
		<link>http://samuellam.wordpress.com/2008/08/04/objective-c-link-to-website/</link>
		<comments>http://samuellam.wordpress.com/2008/08/04/objective-c-link-to-website/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 08:00:09 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://samuellam.wordpress.com/?p=77</guid>
		<description><![CDATA[[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString: @&#8221;http://www.mywebsite.com/&#8221;]];<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=77&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString: @&#8221;http://www.mywebsite.com/&#8221;]];</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/samuellam.wordpress.com/77/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/samuellam.wordpress.com/77/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/samuellam.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/samuellam.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/samuellam.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=samuellam.wordpress.com&amp;blog=4528697&amp;post=77&amp;subd=samuellam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://samuellam.wordpress.com/2008/08/04/objective-c-link-to-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4693ab4bc40d8d79d7fe142b1d255583?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuellam</media:title>
		</media:content>
	</item>
	</channel>
</rss>
