<?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>Jamie Dixon &#187; Uncategorized</title>
	<atom:link href="http://www.jamie-dixon.co.uk/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamie-dixon.co.uk</link>
	<description>Web Developer, Software Engineer and Mixed Language Artist</description>
	<lastBuildDate>Thu, 18 Aug 2011 09:31:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get random item from IList&lt; T &gt;</title>
		<link>http://www.jamie-dixon.co.uk/uncategorized/get-random-item-from-ilist-t/</link>
		<comments>http://www.jamie-dixon.co.uk/uncategorized/get-random-item-from-ilist-t/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 10:39:38 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jamie-dixon.co.uk/?p=273</guid>
		<description><![CDATA[In what could turn out to be a series of posts about helpful extension methods I thought I&#8217;d include this quick little method for getting a random item from an IList collection.

?View Code CSHARPpublic static T GetRandomItem&#60;T&#62;&#40;this IList&#60;T&#62; collection&#41;
        &#123;
         [...]]]></description>
			<content:encoded><![CDATA[<p>In what could turn out to be a series of posts about helpful extension methods I thought I&#8217;d include this quick little method for getting a random item from an IList<T> collection.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p273code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2733"><td class="code" id="p273code3"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> T GetRandomItem<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> IList<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> collection<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> collection<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Random<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, collection<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>This can then be used as follows:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p273code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2734"><td class="code" id="p273code4"><pre class="csharp" style="font-family:monospace;">var collectionList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> <span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;String 1&quot;</span>, <span style="color: #666666;">&quot;String 2&quot;</span>, <span style="color: #666666;">&quot;String 3&quot;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">string</span> item <span style="color: #008000;">=</span> collectionList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetRandomItem</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jamie-dixon.co.uk/uncategorized/get-random-item-from-ilist-t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ContainsAny &amp; EquelsAny</title>
		<link>http://www.jamie-dixon.co.uk/uncategorized/containsany-equelsany/</link>
		<comments>http://www.jamie-dixon.co.uk/uncategorized/containsany-equelsany/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 11:19:07 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jamie-dixon.co.uk/?p=268</guid>
		<description><![CDATA[This post is a bit of a reference for myself and also a handy tip for those wondering how to perform Contains and Equels on a collection of strings.
For the purposes I needed I simply wanted to check if a string Equels Any or Contains Any of an array of strings. I put these together [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a bit of a reference for myself and also a handy tip for those wondering how to perform Contains and Equels on a collection of strings.</p>
<p>For the purposes I needed I simply wanted to check if a string Equels Any or Contains Any of an array of strings. I put these together as a couple of extension methods:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p268code8'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2688"><td class="code" id="p268code8"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> ContainsAny<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span> input, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> items<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> items<span style="color: #008000;">.</span><span style="color: #0000FF;">Any</span><span style="color: #008000;">&#40;</span>input<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p268code9'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2689"><td class="code" id="p268code9"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> EqualsAny<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span> input, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> items<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> items<span style="color: #008000;">.</span><span style="color: #0000FF;">Any</span><span style="color: #008000;">&#40;</span>input<span style="color: #008000;">.</span><span style="color: #0000FF;">Equels</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s all that&#8217;s required.</p>
<p>This means we can  now do things like:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p268code10'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p26810"><td class="code" id="p268code10"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">bool</span> isWomenOrUnisex <span style="color: #008000;">=</span> category<span style="color: #008000;">.</span><span style="color: #0000FF;">EquelsAny</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;women&quot;</span>,<span style="color: #666666;">&quot;unisex&quot;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Simples!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamie-dixon.co.uk/uncategorized/containsany-equelsany/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing Parameters to an ActionFilter in ASP.NET MVC</title>
		<link>http://www.jamie-dixon.co.uk/uncategorized/passing-parameters-to-an-actionfilter-in-asp-net-mvc/</link>
		<comments>http://www.jamie-dixon.co.uk/uncategorized/passing-parameters-to-an-actionfilter-in-asp-net-mvc/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 11:04:41 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jamie-dixon.co.uk/?p=254</guid>
		<description><![CDATA[Creating action filters is quite a simple process. You can simply inherit from ActionFilterAttribute and bingo, you&#8217;ve got yourself a custom ActionFilter.
There&#8217;s a lot of articles out in the wilderness of the web that explain how to go about creating custom ActionFilters and most of them are pretty good articles.
The one thing I&#8217;ve not been [...]]]></description>
			<content:encoded><![CDATA[<p>Creating action filters is quite a simple process. You can simply inherit from ActionFilterAttribute and bingo, you&#8217;ve got yourself a custom ActionFilter.</p>
<p>There&#8217;s a lot of articles out in the wilderness of the web that explain how to go about creating custom ActionFilters and most of them are pretty good articles.</p>
<p>The one thing I&#8217;ve not been able to find online is some instruction of how to create action filters that accept some kind of parameters. We already see this concept being used by such things as the OutputCacheAttribute action method where we can pass in a Duration, and various other parameters:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p254code14'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25414"><td class="code" id="p254code14"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>OutputCache<span style="color: #008000;">&#40;</span>Duration <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span></pre></td></tr></table></div>

<p>So how do we allow our own custom action filters to accept parameters in this same way?</p>
<p>The answer seems really simple once you know however a search on Google doesn&#8217;t seem to return much in the way of any answers to this question (as with many of my posts, they&#8217;re usually things that I haven&#8217;t been able to find online already).</p>
<p>The simple answer is that: <strong>Action filter parameters are properties of the action filter.</strong></p>
<p>Here&#8217;s a short example custom action filter that exposes a property which I then use when attaching the attribute to a class.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p254code15'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25415"><td class="code" id="p254code15"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> CustomActionAttrbitue <span style="color: #008000;">:</span> ActionFilterAttribute
<span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Id <span style="color: #008000;">&#123;</span>get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnActionExecuting<span style="color: #008000;">&#40;</span>ActionExecutingContext filterContext<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Do some work here.</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>and in attaching this attribute to a class:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p254code16'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p25416"><td class="code" id="p254code16"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>CustomAction<span style="color: #008000;">&#40;</span>Id <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> MyController  <span style="color: #008000;">:</span> Controller
<span style="color: #008000;">&#123;</span>
&nbsp;
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Like I said above, once you know that the parameter is a property of the action filter, it seems obvious. Hope this helps someone else looking for this information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamie-dixon.co.uk/uncategorized/passing-parameters-to-an-actionfilter-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twitter 101 &#8211; Open for business</title>
		<link>http://www.jamie-dixon.co.uk/uncategorized/twitter-101-open-for-business/</link>
		<comments>http://www.jamie-dixon.co.uk/uncategorized/twitter-101-open-for-business/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 16:52:39 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jamie-dixon.co.uk/?p=107</guid>
		<description><![CDATA[Over the past couple of years we&#8217;ve seen a huge uptake in people using Twitter. Now the company has decided to release a new page on their website called Twitter 101 for Business &#8211; A Special Guide.
The aim of the new information seems to be to educate businesses on how Twitter can work for them. [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of years we&#8217;ve seen a huge uptake in people using Twitter. Now the company has decided to release a new page on their website called <a href="http://business.twitter.com/twitter101/"><em>Twitter 101 for Business &#8211; A Special Guide</em></a>.</p>
<p>The aim of the new information seems to be to educate businesses on how Twitter can work for them. This is probably a good thing since most people I talk to about Twitter, who don&#8217;t use it, usually reply with &#8220;I just don&#8217;t get it. Why would anyone care what I&#8217;m doing?&#8221; and it&#8217;s a fair point too.</p>
<p>Now there&#8217;s a place business owners can go to find out exactly what Twitter is for and why people might care. All in all I think Twitter have made a good decision doing this. Let&#8217;s see how it affects the way more businesses do business in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamie-dixon.co.uk/uncategorized/twitter-101-open-for-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

