<?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>Flyvergrillen</title>
	<atom:link href="http://www.flyvergrillen.dk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flyvergrillen.dk</link>
	<description>Et sted på Amager hvor nørder samles</description>
	<lastBuildDate>Thu, 20 May 2010 10:24:45 +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>TryUpdateModel and unknown model-types</title>
		<link>http://www.flyvergrillen.dk/2010/05/20/tryupdatemodel-and-unknown-model-types/</link>
		<comments>http://www.flyvergrillen.dk/2010/05/20/tryupdatemodel-and-unknown-model-types/#comments</comments>
		<pubDate>Thu, 20 May 2010 10:23:29 +0000</pubDate>
		<dc:creator>Anders Rasmussen</dc:creator>
				<category><![CDATA[Kode]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ExtensionMethod]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/?p=95</guid>
		<description><![CDATA[TryUpdateModel does not work on types not known at compile time. For example when creating an object through the Activator.CreateInstance()
To remedy this use this snippet of code:

public static class ControllerHelpers
&#123;
  public static bool TryUpdateGenericModel&#40;this Controller controller, object model&#41;
  &#123;
    var param = new Type&#91;&#93; &#123; model.GetType&#40;&#41; &#125;;
    [...]]]></description>
			<content:encoded><![CDATA[<p>TryUpdateModel does not work on types not known at compile time. For example when creating an object through the Activator.CreateInstance()</p>
<p>To remedy this use this snippet of code:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> ControllerHelpers
<span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">bool</span> TryUpdateGenericModel<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span> Controller controller, <span style="color: #FF0000;">object</span> model<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    var param <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Type<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> model.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
    var controllerType <span style="color: #008000;">=</span> controller.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    var controllerMethods <span style="color: #008000;">=</span> controllerType.<span style="color: #0000FF;">GetMethods</span><span style="color: #000000;">&#40;</span>BindingFlags.<span style="color: #0000FF;">NonPublic</span> <span style="color: #008000;">|</span> BindingFlags.<span style="color: #0000FF;">Instance</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    var TUMmethod <span style="color: #008000;">=</span> controllerMethods.<span style="color: #0000FF;">First</span><span style="color: #000000;">&#40;</span>x <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span> x.<span style="color: #0000FF;">Name</span>.<span style="color: #0000FF;">StartsWith</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;TryUpdateModel&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span> x.<span style="color: #0000FF;">GetParameters</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    var TUMgeneric <span style="color: #008000;">=</span> TUMmethod.<span style="color: #0000FF;">MakeGenericMethod</span><span style="color: #000000;">&#40;</span>param<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    var result <span style="color: #008000;">=</span> TUMgeneric.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span>controller, <span style="color: #008000;">new</span> <span style="color: #FF0000;">object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> model <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">bool</span><span style="color: #000000;">&#41;</span>result<span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And in your controller when trying to update your model, use it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">var emptyModelObject <span style="color: #008000;">=</span> Activator.<span style="color: #0000FF;">CreateInstance</span><span style="color: #000000;">&#40;</span>modelType<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// whichever way you get it doesn't really matter.</span>
var result <span style="color: #008000;">=</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">TryUpdateGenericModel</span><span style="color: #000000;">&#40;</span>modelObject<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2010/05/20/tryupdatemodel-and-unknown-model-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit testing with Linq to SQL</title>
		<link>http://www.flyvergrillen.dk/2010/02/09/unit-testing-with-linq-to-sql/</link>
		<comments>http://www.flyvergrillen.dk/2010/02/09/unit-testing-with-linq-to-sql/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 12:57:17 +0000</pubDate>
		<dc:creator>Anders Hellerup Madsen</dc:creator>
				<category><![CDATA[Kode]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/?p=53</guid>
		<description><![CDATA[For some time we have been using Microsofts Linq-to-Sql as our ORM for several of our projects. It has some nice features, but it is also very different from just about every other ORM out there, and in a lot of ways it is troublesome and difficult to work with. One of the things that [...]]]></description>
			<content:encoded><![CDATA[<p>For some time we have been using Microsofts Linq-to-Sql as our ORM for several of our projects. It has some nice features, but it is also very different from just about every other ORM out there, and in a lot of ways it is troublesome and difficult to work with. One of the things that have been irritating me about Linq-to-Sql is that it&#8217;s central object, the datacontext, does not implement an interface and therefore it is difficult to unittest code that depends on it. Today I stumpled upon a solution to that problem in this post: <a href="http://www.iridescence.no/post/Linq-to-Sql-Programming-Against-an-Interface-and-the-Repository-Pattern.aspx">http://www.iridescence.no/post/Linq-to-Sql-Programming-Against-an-Interface-and-the-Repository-Pattern.aspx</a></p>
<p>Let&#8217;s start with an example of the problem. We use a repository pattern to encapsulate our Linq our Linq-queries into manageable and reusable componentes. Are repository can look kindof like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> ClipRepository <span style="color: #008000;">:</span> IClipRepository
<span style="color: #000000;">&#123;</span>
    IDataContext _dc<span style="color: #008000;">;</span>
    IDataContext dc
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_dc <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                _dc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PiratDataContext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">return</span> _dc<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> IQueryable getClipsFromSite<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> siteid<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> from sc <span style="color: #0600FF;">in</span> dc.<span style="color: #0000FF;">SiteClips</span>
        where sc.<span style="color: #0000FF;">SiteID</span> <span style="color: #008000;">==</span> siteid
        select sc.<span style="color: #0000FF;">Clip</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The repository implements a IClipRepository interface an all code that depends on the repository is written against the interface instead of the specific implementation. This is great because we can then switch from a database backend-implementation to, say, a cachebackend without changing any of the dependant code. We use a servicelocator to provice simple inversion-of-control and break dependencies, and as a bonus, we can write unittest of code that uses the repository be reconfiguring the servicelocator to return a MockedClipRepository instead of the real one.</p>
<p>However, as mentioned above, the DataContext itself does not implement an interface, so we cannot use the servicelocator to provide the datacontext, and therefore we cannot really unittest our repositories without great difficulty.</p>
<h2>Wrapping the DataContext</h2>
<p>C# is flexible &#8211; with generics we can create a proxy class around a DataContext, and we can make that class implement a suitable interface.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IDataContext
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// Gets the repository for the given type of entities</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;/summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;typeparam name=&quot;T&quot;&amp;gt;The type of the entity&amp;lt;/typeparam&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;returns&amp;gt;The repository of the given type&amp;lt;/returns&amp;gt;</span>
    IQueryable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> GetTable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &amp;lt;summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// Adds a new entity to the repository</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;/summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;typeparam name=&quot;T&quot;&amp;gt;The type of the entity&amp;lt;/typeparam&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;param name=&quot;item&quot;&amp;gt;The entity to add&amp;lt;/param&amp;gt;</span>
    <span style="color: #0600FF;">void</span> Insert<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &amp;lt;summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// Deletes the specified entity from the repository</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;/summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;typeparam name=&quot;T&quot;&amp;gt;The type of the entity&amp;lt;/typeparam&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;param name=&quot;item&quot;&amp;gt;The entity to delete&amp;lt;/param&amp;gt;</span>
    <span style="color: #0600FF;">void</span> Delete<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &amp;lt;summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// Commits the changes to the repository</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;/summary&amp;gt;</span>
    <span style="color: #0600FF;">void</span> Save<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &amp;lt;summary&amp;gt;</span>
    <span style="color: #008080; font-style: italic;">/// Provides access to the modified objects tracked by the system</span>
    <span style="color: #008080; font-style: italic;">/// &amp;lt;/summary&amp;gt;</span>
    ChangeSet GetChangeSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And the wrapper class implementation for LinqToSql datacontexts:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> LinqToSqlDataContext<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t_datacontexttype<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> <span style="color: #008000;">:</span> IDataContext where T_DataContextType <span style="color: #008000;">:</span> DataContext
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">private</span> DataContext _dc<span style="color: #008000;">;</span>
    <span style="color: #0600FF;">private</span> DataContext dc
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_dc <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                _dc <span style="color: #008000;">=</span> Activator.<span style="color: #0000FF;">CreateInstance</span><span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t_datacontexttype<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">return</span> _dc<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> IQueryable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> GetTable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> dc.<span style="color: #0000FF;">GetTable</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Cast</span><span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Insert<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        dc.<span style="color: #0000FF;">GetTable</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">InsertOnSubmit</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Delete<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        dc.<span style="color: #0000FF;">GetTable</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">DeleteOnSubmit</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Save<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        dc.<span style="color: #0000FF;">SubmitChanges</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> ChangeSet GetChangeSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">return</span> dc.<span style="color: #0000FF;">GetChangeSet</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080;">#endregion</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h2>Using the wrapper</h2>
<p>With this wrapper in place, we then change the implementation of the repository above so that instead of creating it&#8217;s datacontext directly it uses the wrapper:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// creating the context</span>
<span style="color: #008080; font-style: italic;">// in the ServiceLocators config, IDataContext is setup to return LinqToSqlDataContext&amp;lt;piratdatacontext&amp;gt;</span>
_dc <span style="color: #008000;">=</span> ServiceLocator.<span style="color: #008000;">New</span><span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>idatacontext<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// using it</span>
<span style="color: #0600FF;">return</span> from sc <span style="color: #0600FF;">in</span> dc.<span style="color: #0000FF;">GetTable</span><span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>siteclip<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
         where sc.<span style="color: #0000FF;">SiteID</span> <span style="color: #008000;">==</span> siteid
         select sc.<span style="color: #0000FF;">Clip</span><span style="color: #008000;">;</span></pre></div></div>

<h2>Unit testing</h2>
<p>With the above setup we can now create a MemoryDataContext, that has the same interface as the LinqToSql context, but does not depend on a database:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> MemoryDataContext <span style="color: #008000;">:</span> IDataContext
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> List<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> _inMemoryDataStore <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IList<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> _Inserts <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IList<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> _Deletes <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IList<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> _Updates <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> MemoryDataContext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> MemoryDataContext<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">params</span> INotifyPropertyChanged<span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> objects<span style="color: #000000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #0600FF;">this</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var obj <span style="color: #0600FF;">in</span> objects<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            _insert<span style="color: #000000;">&#40;</span>obj<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> _insert<span style="color: #000000;">&#40;</span>INotifyPropertyChanged item<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        _inMemoryDataStore.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        item.<span style="color: #0000FF;">PropertyChanged</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> PropertyChangedEventHandler<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>s,e<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span> _Updates.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>s<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> IQueryable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> GetTable<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        var list <span style="color: #008000;">=</span> from objects <span style="color: #0600FF;">in</span> _inMemoryDataStore
                    where <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>T<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">IsAssignableFrom</span><span style="color: #000000;">&#40;</span>objects.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                    select objects <span style="color: #0600FF;">as</span> T<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">return</span> list.<span style="color: #0000FF;">AsQueryable</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Insert<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        _insert<span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        _Inserts.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Delete<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>t<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>T item<span style="color: #000000;">&#41;</span> where T <span style="color: #008000;">:</span> <span style="color: #FF0000;">class</span>, INotifyPropertyChanged
    <span style="color: #000000;">&#123;</span>
        _inMemoryDataStore.<span style="color: #0000FF;">Remove</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        _Deletes.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Save<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>Completed <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Completed<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>, EventArgs.<span style="color: #0000FF;">Empty</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> ChangeSet GetChangeSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        var constructor <span style="color: #008000;">=</span> <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>ChangeSet<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetConstructors</span><span style="color: #000000;">&#40;</span>BindingFlags.<span style="color: #0000FF;">Instance</span> <span style="color: #008000;">|</span> BindingFlags.<span style="color: #0000FF;">NonPublic</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">First</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        var changes <span style="color: #008000;">=</span> constructor.<span style="color: #0000FF;">Invoke</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> <span style="color: #FF0000;">object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008000;">new</span> ReadOnlyCollection<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>_Inserts<span style="color: #000000;">&#41;</span>,
            <span style="color: #008000;">new</span> ReadOnlyCollection<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>_Deletes<span style="color: #000000;">&#41;</span>,
            <span style="color: #008000;">new</span> ReadOnlyCollection<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span>object<span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span><span style="color: #000000;">&#40;</span>_Updates<span style="color: #000000;">&#41;</span>,
        <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #0600FF;">as</span> ChangeSet<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">return</span> changes<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">event</span> EventHandler Completed<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And there &#8211; we can now write unittests of our repository methods like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #000000;">&#91;</span>TestInitialize<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> init<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            var memContext <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MemoryDataContext<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> Clip <span style="color: #000000;">&#123;</span> ID <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>, Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;hest&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> Clip <span style="color: #000000;">&#123;</span> ID <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>, Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;giraf&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> Clip <span style="color: #000000;">&#123;</span> ID <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>, Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;tobis&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> Clip <span style="color: #000000;">&#123;</span> ID <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>, Title <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;laks&quot;</span>, AllowExternalEmbedding <span style="color: #008000;">=</span> <span style="color: #0600FF;">true</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> SiteClip <span style="color: #000000;">&#123;</span> ClipID <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>, SiteID <span style="color: #008000;">=</span> <span style="color: #FF0000;">50</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> SiteClip <span style="color: #000000;">&#123;</span> ClipID <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>, SiteID <span style="color: #008000;">=</span> <span style="color: #FF0000;">50</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> SiteClip <span style="color: #000000;">&#123;</span> ClipID <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>, SiteID <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> SiteClip <span style="color: #000000;">&#123;</span> ClipID <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>, SiteID <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            memContext.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> SiteClip <span style="color: #000000;">&#123;</span> ClipID <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>, SiteID <span style="color: #008000;">=</span> <span style="color: #FF0000;">50</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            ServiceLocator.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>IDataContext<span style="color: #000000;">&#41;</span>, memContext<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>TestMethod<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> getClipsFromSiteTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            ClipRepository target <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ClipRepository<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">3</span>, target.<span style="color: #0000FF;">getClipsFromSite</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">50</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span>, target.<span style="color: #0000FF;">getClipsFromSite</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">4</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Assert.<span style="color: #0000FF;">AreEqual</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, target.<span style="color: #0000FF;">getClipsFromSite</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Count</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2010/02/09/unit-testing-with-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hjælp med test af ny forside</title>
		<link>http://www.flyvergrillen.dk/2010/01/26/hjaelp-med-test-af-ny-forside/</link>
		<comments>http://www.flyvergrillen.dk/2010/01/26/hjaelp-med-test-af-ny-forside/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 20:35:52 +0000</pubDate>
		<dc:creator>Mikkel Munch Mortensen</dc:creator>
				<category><![CDATA[Hjælp os]]></category>
		<category><![CDATA[pirattv]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/?p=40</guid>
		<description><![CDATA[På Pirat TV bruger vi en del flash. Stort set al frontend er bygget i flash, hvilket vi i sin tid fik svenske Doberman til. Og de gjorde det rigtig godt. Desværre har det efterfølgende givet lidt bagslag, da vores egen flashmand har haft alt for travlt til at rette de småfejl vi har fundet [...]]]></description>
			<content:encoded><![CDATA[<p>På Pirat TV bruger vi en del flash. Stort set al frontend er bygget i flash, hvilket vi i sin tid fik <a href="http://www.doberman.se/">svenske Doberman</a> til. Og de gjorde det rigtig godt. Desværre har det efterfølgende givet lidt bagslag, da vores egen flashmand har haft alt for travlt til at rette de småfejl vi har fundet undervejs.</p>
<p>Så for en uges tid siden kastede jeg mig ud i et eksperiment: At bygge Pirat TV&#8217;s forside udelukkende af god, gammeldags HTML, CSS og javascript &#8212; helt uden flash. Jeg er nu nået så langt at jeg har noget der er værd at se på. Det er ikke en færdig erstatning til forsiden. Mere et proof of concept, og jeg kunne derfor godt tænke mig at få noget feedback.</p>
<p>En ting der er vigtig for os, for at vi vil tage skridtet og skrælle noget flash af, er at det ikke må gå ud over brugeroplevelsen. For brugeren skal det ikke føles som en degradering at vi skifter den bagvedliggende teknologi for visningen af vores sider. Og siden <em>er</em> lidt tung. Både med mange billeder, men også med en god portion javascript.</p>
<p>Så derfor: Kig på <a href="http://www.dr.dk/pirattv/">den nuværende forside</a> og <a href="http://www.dr.dk/pirattv/trylle-trylle/">den nye forside uden flash</a>. Kør lidt rundt med musen på dem begge. Prøv at ændre størrelse på vinduet. Hvordan føles det? Hænger det for meget? I hvilke situationer? Prøv meget gerne i forskellige browsere. Jeg har selv testet i de fleste moderne browsere (i Windows), men har ikke haft mulighed for at prøve i en rigtig Internet Explorer 7/8. Skriv om dine observationer og hvad du synes i kommentarfeltet. Fortæl også gerne lige lidt om din computer: Hvor hurtig den er, hvor meget ram den har, hvilket styresystem du bruger, hvilke browsere du har testet i.</p>
<p>Det skal måske lige nævnes at de to forsider ikke er identiske helt ned på pixelniveau. Det behøver de ikke være. Endnu.</p>
<p>På forhånd tak.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2010/01/26/hjaelp-med-test-af-ny-forside/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>nginx as a proxy for Visual Studio</title>
		<link>http://www.flyvergrillen.dk/2010/01/26/nginx-as-a-proxy-for-visual-studio/</link>
		<comments>http://www.flyvergrillen.dk/2010/01/26/nginx-as-a-proxy-for-visual-studio/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 11:36:07 +0000</pubDate>
		<dc:creator>Mikkel Munch Mortensen</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2010/01/26/nginx-as-a-proxy-for-visual-studio/</guid>
		<description><![CDATA[I guess most people doing ASP.NET web development in Visual Studio (VS) have been frustrated by the fact that the development server in VS only wants to serve it&#8217;s content to the local machine. It is inaccessible from other computers on the network and impossible to reach from a Virtual Machine running alternative configurations of [...]]]></description>
			<content:encoded><![CDATA[<p>I guess most people doing ASP.NET web development in Visual Studio (VS) have been frustrated by the fact that the development server in VS only wants to serve it&#8217;s content to the local machine. It is inaccessible from other computers on the network and impossible to reach from a Virtual Machine running alternative configurations of OS/browser. This is a pain in the ass when trying to debug something not working in another version of Internet Explorer than you have on your local machine.</p>
<p>We&#8217;ve been trying different approaches to circumvent this, using SSH tunnels and other similar technologies, without any luck. But this morning I came up with a solution: A local HTTP proxy in front of the development server. This way, anybody can access the proxy, and still all requests to the development server are local. I chose <a href="http://nginx.org/">nginx</a> (pronounced <em>engine x</em>) as the proxy. It&#8217;s free, open source and it only takes a couple minutes to get up and running.</p>
<h3>Download</h3>
<p>Currently, the most recent version of nginx for Windows is 0.8.32, and it is available for <a href="http://nginx.org/en/download.html">download here</a>. It&#8217;s a simple zip file that just needs to be extracted. No installation is needed &#8212; the server runs directly from the uncompressed files.</p>
<h3>Configuration</h3>
<p>In the folder <var>conf</var>, there&#8217;s file called <var>nginx.conf</var>. This is the configuration file for nginx.</p>
<p>Around line 36 it says:</p>
<p><code>listen       80;<br />
server_name  localhost;</code></p>
<p><var>80</var> is the port number nginx is listening to. I have personally chosen to change this to <var>8080</var>, as I already have a local Apache server running on port 80. But you can pick any port number you like, as long as it&#8217;s not in use.</p>
<p>Around line 43 it says:</p>
<p><code>location / {<br />
root   html;<br />
index  index.html index.htm;<br />
}</code></p>
<p>Change this to:</p>
<p><code>location / {<br />
#root   html;<br />
#index  index.html index.htm;<br />
proxy_pass   http://localhost:xxxx;<br />
}</code></p>
<p>Where <var>xxxx</var> is the port on which VS is running it&#8217;s development server. This changes from project to project, and even changes from time to time in a project. So this will need to be changed once in while.</p>
<h3>Start and reload</h3>
<p>nginx is started by double clicking the file <var>nginx.exe</var>, or by opening a command prompt, <code>cd</code> to the nginx folder and run the command <code>start nginx.exe</code>. If everything is fine (i.e. if you didn&#8217;t make any mistakes in the configuration), you will hereafter have 2 new processes (a master and a worker) running, both called <var>nginx.exe</var>.</p>
<p>If you need to reconfigure nginx (e.g. change to a new port VS has chosen to run it&#8217;s server at), afterwards you can reload nginx by running the command <code>nginx -s reload</code> from the nginx folder in command prompt.</p>
<p>Read more about start, reload and stop in the official <a href="http://nginx.org/en/docs/windows.html">documentation</a>.</p>
<h3>Access</h3>
<p>The VS development server is now available &#8212; through nginx &#8212; at <code>http://HOSTNAME:8080</code>, where <var>HOSTNAME</var> is the network name (or IP address) of your computer, and <var>8080</var> is the port you chose to let nginx listen to in the configuration.</p>
<p>Happy external debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2010/01/26/nginx-as-a-proxy-for-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lidt (uofficielle) tal fra MC&#8217;s Fight Night</title>
		<link>http://www.flyvergrillen.dk/2009/10/18/lidt-uofficielle-tal-fra-mcs-fight-night/</link>
		<comments>http://www.flyvergrillen.dk/2009/10/18/lidt-uofficielle-tal-fra-mcs-fight-night/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 14:57:06 +0000</pubDate>
		<dc:creator>Mikkel Munch Mortensen</dc:creator>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[mc's fight night]]></category>
		<category><![CDATA[pirat]]></category>
		<category><![CDATA[statistik]]></category>
		<category><![CDATA[tal]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2009/10/18/lidt-uofficielle-tal-om-mcs-fight-night/</guid>
		<description><![CDATA[I går aftes streamede vi MC&#8217;s Fight Night live på Pirat TV. Det var en stor succes, og vores foreløbige, men uofficielle tal siger at der var nogen forbi mere end 13.000 gange før, under og lidt efter showet. Det er vi ret godt tilfredse med. Showet stod for 27% af vores sidevisninger i går, [...]]]></description>
			<content:encoded><![CDATA[<p>I går aftes <a href="http://www.dr.dk/pirattv/klip/mcs-fight-night-2009-live/">streamede</a> vi <a href="http://www.fightnight.dk/">MC&#8217;s Fight Night</a> live på <a href="http://www.dr.dk/pirattv/">Pirat TV</a>. Det var en stor succes, og vores foreløbige, men uofficielle tal siger at der var nogen forbi mere end 13.000 gange før, under og lidt efter showet. Det er vi ret godt tilfredse med. Showet stod for 27% af vores sidevisninger i går, og derudover har nogle af vores Fight Night-arkivklip også trukket noget trafik.</p>
<p>Kommentarerne bar meget præg af folk i udlandet der ikke kunne se udsendelsen. Men det har i virkeligheden været meget få det var et reelt problem for. Det drejer sig om nogle få hundrede som har siddet udenlands og dermed ikke kunnet se showet på nettet.</p>
<p>En glædelig observation er til gengæld at hip hoppere tilsyneladende har god browsersmag:  45% af de besøgende brugte Firefox og kun 30% brugte Internet Explorer.</p>
<p>Det er næppe sidste gang vi har live-streamet fra den slags begivenheder. Det er fedt at være med til at tilgængeliggøre ungdomskultur der åbenbart er for smal til at kunne finde vej til de traditionelle kanaler.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2009/10/18/lidt-uofficielle-tal-fra-mcs-fight-night/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sig goddag til Pirat TV</title>
		<link>http://www.flyvergrillen.dk/2009/09/01/sig-goddag-til-pirattv/</link>
		<comments>http://www.flyvergrillen.dk/2009/09/01/sig-goddag-til-pirattv/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 08:16:03 +0000</pubDate>
		<dc:creator>Mikkel Munch Mortensen</dc:creator>
				<category><![CDATA[Andet]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[pirattv]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2009/09/01/sig-goddag-til-pirattv/</guid>
		<description><![CDATA[Efter 4-5 måneders udvikling lancerer vi i dag stolt Pirat TV. I virkeligheden lancerede vi allerede for et par måneder siden, men det var lidt i smug. I dag er den store dag med officiel lancering og alt hvad dertil hører.
Kort fortalt er Pirat TV Ungdomsredaktionens bud på en netbaseret platform for moderne og fremtidigt [...]]]></description>
			<content:encoded><![CDATA[<p>Efter 4-5 måneders udvikling lancerer vi i dag stolt <a href="http://www.dr.dk/pirattv/" title="Pirat TV">Pirat TV</a>. I virkeligheden lancerede vi allerede for et par måneder siden, men det var lidt i smug. I dag er den store dag med officiel lancering og alt hvad dertil hører.</p>
<p>Kort fortalt er Pirat TV Ungdomsredaktionens bud på en netbaseret platform for moderne og fremtidigt ungdoms-tv. Vi har droppet at sende på DR1 (vi fik alligevel kun skodsendetider) og koncentrerer os nu om at lave internetvenlige, klipformaterede ting, i troen på at unge fortsat vil rykke mere og mere over på net fra tv.</p>
<p>Bag den overvejende flash-baserede frontend gemmer sig en ASP.NET MVC-applikation som er forberedt til også at servere andre ting end blot Pirat TV. Så vi er klar til WORLD DOMINATION!</p>
<p>Det er vores første  MVC-applikation. MVC er ikke the framework to rule them all &#8211; personligt savner jeg mange ting der er til stede i andre web frameworks &#8211; men vi kan vist roligt sige: NØJ, hvor er det en befrielse fremfor at arbejde med det retarderede Web Forms fra ASP.NET.</p>
<p>På alle klipsider har vi &#8211; ligesom man kender fra fx. YouTube &#8211; en embed-kode liggende som man kan tage og putte ind på sit eget site. Vi er et par steder (<a href="http://www.microformats.dk/2009/06/26/dr-pirat-tvs-underlige-fortolkning-af-ordet-embed/" title="Microformats.dk om vores fortolkning af begrebet ">1</a>, <a href="http://medieblogger.dk/2009/06/26/dr-vil-gerne-lave-youtube-men-kan-ikke-finde-ud-af-det-der-embed/" title="Medieblogger om vores embedding">2</a>) blevet hånet for vores &#8220;fortolkning&#8221; af embed. Og det er delvist fair. For resultatet af embed-koden er blot at der kommer et Pirat TV-logo, en thumbnail fra klippet og klippets titel med et link tilbage til klippet på Pirat TV.</p>
<p>Men kritikken er også lidt unfair. For vi har ikke gjort som vi har gjort fordi vi er inkompetente. Vi kunne sagtens lave rigtig embedding. Men desværre har vi på nuværende tidspunkt ikke rettighederne til at embedde vores indhold eksternt (selvom vi her på redaktionen rigtigt gerne ville). DR tør &#8211; modsat YouTube og andre &#8211; ikke køre efter princippet &#8220;hellere tilgivelse end tilladelse&#8221;. Så der er lige nogle jurasoldater der skal udkæmpe en vigtig krig før vi kan få lov.</p>
<p>Til gengæld er vores embedkode forberedt til at embedde rigtig video den dag vi får lov. Så hermed en opfordring til alle om at bruge embedkoden allerede fra i dag af. Så dukker der flot video op på jeres sites den dag rettighederne er på plads.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2009/09/01/sig-goddag-til-pirattv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Error Handler in IIS7</title>
		<link>http://www.flyvergrillen.dk/2009/04/02/custom-error-handler-in-iis7/</link>
		<comments>http://www.flyvergrillen.dk/2009/04/02/custom-error-handler-in-iis7/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 07:48:15 +0000</pubDate>
		<dc:creator>Anders Rasmussen</dc:creator>
				<category><![CDATA[Kode]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[httpErrors]]></category>
		<category><![CDATA[httpHandler]]></category>
		<category><![CDATA[IHttpHandler]]></category>
		<category><![CDATA[iis 7.0]]></category>
		<category><![CDATA[iis7]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2009/04/02/custom-error-handler-in-iis7/</guid>
		<description><![CDATA[Introduction
During the development of SKUM3 some problems have not manifested themselves while developing for one simple reason: Visual Studio 2008 uses a version of IIS 6 as a development server, but our final setup will be an IIS 7 server. The differences between these two version are significant enough to cause headaches.
One such headache is [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>During the development of SKUM3 some problems have not manifested themselves while developing for one simple reason: Visual Studio 2008 uses a version of IIS 6 as a development server, but our final setup will be an IIS 7 server. The differences between these two version are significant enough to cause headaches.</p>
<p>One such headache is the inability to debug code running on the remote server. This combined with differences in how errors are handled, both in the setup in the web.config file, and in the way a custom error handler is called, produced a very difficult to solve problem. Also a lack in documentation is partly to blame.</p>
<h3>The problem</h3>
<p>web.config differences.</p>
<p><strong>IIS 7 version:</strong></p>
<pre><code>&lt;httpErrors&gt;
    &lt;remove statusCode="404" subStatusCode="-1" /&gt;
    &lt;error statusCode="404" prefixLanguageFilePath=""
        path="/path/to/handlerwebservice"
        responseMode="ExecuteURL" /&gt;
&lt;/httpErrors&gt;</code></pre>
<p><strong> IIS 6 version:</strong></p>
<pre>&lt;customErrors mode="On"&gt;
    &lt;error statusCode="404" redirect="webservices/media/image"/&gt;
&lt;/customErrors&gt;</pre>
<p>With the IIS 6 version all 404 errors are redirected to webservices/media/image?aspxerrorpath=original/path. In IIS 7 though this querystring parameter is missing so what to do?</p>
<h3>The Solution</h3>
<p>Well, microsoft is not very helpful and I tried <a href="http://stackoverflow.com/questions/705934/how-do-i-find-out-which-request-path-is-missing-in-a-404-error-handler-in-iis7" title="stackoverflow question">asking my question to the Internet</a> but as I didn&#8217;t receive any answers I just tried changing</p>
<pre><code>context.Request.Path</code></pre>
<p>to</p>
<pre><code>context.Request.RawUrl</code></pre>
<p>Resulting in this code to handle the differences:</p>
<pre><code>string requestpath;

if(context.Request.QueryString.AllKeys.Contains("aspxerrorpath"))
{
    requestpath = context.Request.QueryString["aspxerrorpath"];
}
else
{
    requestpath = context.Request.RawUrl;
}</code></pre>
<p>This seemed to have the desired effect. The difference between these two are that RawUrl contains the requested path unaltered by redirection or anything else and Path is the Url after any redirection. I had forgotten this minor detail even though I&#8217;ve used it in the breadcrumb method to split an original path up into individual pieces, after the request had been redirected by our UrlRewriter.</p>
<p>If you are getting weird errors about httpErrors being locked down use a cheat code</p>
<pre>%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/httpErrors</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2009/04/02/custom-error-handler-in-iis7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Being trapped in IIS</title>
		<link>http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/</link>
		<comments>http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:35:44 +0000</pubDate>
		<dc:creator>Anders Rasmussen</dc:creator>
				<category><![CDATA[Andet]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/</guid>
		<description><![CDATA[Mikkel has just spend a lot of time trying to get ASP.net MVC to work on a server. During this quest he bumped in to a lot of headache inducing problems the worst of which I will describe here and provide some sort of solution.
The error our dear setup threw at us was:
System.InvalidOperationException:
   [...]]]></description>
			<content:encoded><![CDATA[<p>Mikkel has just spend a lot of time trying to get ASP.net MVC to work on a server. During this quest he bumped in to a lot of headache inducing problems the worst of which I will describe here and provide some sort of solution.</p>
<p>The error our dear setup threw at us was:</p>
<pre>System.InvalidOperationException:
    The SessionStateTempDataProvider requires SessionState to be enabled.</pre>
<p>The only results on google were suggesting to add a line in web.config to tell ISS and ASP.net that sessionState mode should be enabled. Trying this and still getting the same error we found <a href="http://forums.asp.net/p/1395532/3000179.aspx" title="Stupid answer to same problem">this</a>:</p>
<blockquote><p>On the Session State tab in IIS, is it also set to enabled?</p></blockquote>
<p>If you are reading this, you are probably having the some understanding of how the IIS7 management gui works and how it looks. It has no notion of Tabs, and no configuration icons relating to session at all.</p>
<p>Poking around at every concievable way to add SessionState we found that it was possible to add a module named:</p>
<pre>System.Web.SessionState.SessionStateModule</pre>
<p>Adding that module created the following in web.config:</p>
<pre>&lt;system.webServer&gt;
    &lt;modules runAllManagedModulesForAllRequests="true"&gt;
       <strong>&lt;add name="SessionStateModule"
            type="System.Web.SessionState.SessionStateModule" /&gt;</strong></pre>
<p>Rembering to add this:</p>
<pre>&lt;system.web&gt;
   &lt;sessionState mode="InProc" /&gt;
&lt;/system.web&gt;</pre>
<p>made the server happy.</p>
<p>Hopefully someone in the same situation will find this helpful.</p>
<p>ps: If you are getting <a href="http://www.google.dk/search?hl=da&amp;q=web.config+0x80070021&amp;btnG=S%C3%B8g" title="Google søgning på det her lort">weird errors (0&#215;80070021)</a> about system.webServer handlers not being recognized you&#8217;ll need to enable them using <a href="http://forums.iis.net/p/1155232/1893364.aspx#1893364" title="Cool cheatcodes dude :D">the cheatcodes</a>:</p>
<pre>%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers</pre>
<pre>%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/modules</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Typeface.js</title>
		<link>http://www.flyvergrillen.dk/2008/11/11/typefacejs/</link>
		<comments>http://www.flyvergrillen.dk/2008/11/11/typefacejs/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 21:45:26 +0000</pubDate>
		<dc:creator>Anders Rasmussen</dc:creator>
				<category><![CDATA[Kode]]></category>
		<category><![CDATA[Font]]></category>
		<category><![CDATA[Opera]]></category>
		<category><![CDATA[Typeface.js]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2008/11/11/typefacejs/</guid>
		<description><![CDATA[Typeface.js er et rimeligt interessant stykke software. Interessant fordi det uden problemer tillader en at bruge fonte i websites selvom næsten ingen endnu har implementeret @font-face css-reglen.
Jeg skriver at det er uden problemer og det er en sandhed med modifikationer. Det er problemfrit når man bare bruger det som tekst rendering og ikke forventer at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://typeface.neocracy.org/">Typeface.js</a> er et rimeligt interessant stykke software. Interessant fordi det uden problemer tillader en at bruge fonte i websites selvom næsten ingen endnu har implementeret <a href="http://www.w3.org/TR/css3-webfonts/#font-descriptions">@font-face</a> css-reglen.</p>
<p>Jeg skriver at det er uden problemer og det er en sandhed med modifikationer. Det er problemfrit når man bare bruger det som tekst rendering og ikke forventer at det kan redde verden. Det virker i de fleste grade A browsere. Lige netop det at det ikke virker i alle grade A browsere er det som denne artikel handler om.</p>
<p>I Opera virker det nemlig overhovedet ikke. Det påstås heller ikke fra forfatterens side, men det virkede lidt underligt at det ikke skulle virke, for Opera plejer at opføre sig ordentligt det meste af tiden.</p>
<p>Efter en hurtig omgang debugging i typeface kilden med Operas indbyggede debugger værktøj, fandt jeg ud af at Opera opfattede at de elementer som skulle have specielle fonte, skulle renderes med Arial. Det er jo ikke rigtigt til at forstå, eftersom Arial ikke var i stylesheet&#8217;et. Jeg kom frem til at Opera måtte smide specialfonten væk, fordi den ikke kunne finde den, og så bruge det den troede man havde brug for i stedet.</p>
<p>Efter en del søgen på det store Internet fandt jeg et <a href="http://dev.opera.com/forums/topic/244486">indlæg</a> i Operas developer forum om emnet. Det som Operas udvikler svarer er at de har taget en design beslutning og implementeret det på den måde de har. <a href="http://www.w3.org">w3&#8217;s</a> <a href="http://www.w3.org/TR/1998/REC-CSS2-19980512/cascade.html#q1">specifikation</a> på området omkring computed styles (den værdi som der bliver hentet ud i dette tilfælde, og som indeholder beregnede værdier af de værdier som står i stylesheet&#8217;et) er yderst vag, og den beskriver kun at man skal lave pixel beregninger og sørge for at inherit værdier er ændret til de værdier som skal bruges. Mozilla skriver i deres <a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle">developer central wiki</a> at de faktisk har snydt lidt og bruger used styles som resultat af computed styl, men det ændrer ikke ved at de returnerer det rigtige resultat, nemlig en streng som indeholder en kommasepereret liste af de fonte som er i stylesheet&#8217;et. Forhåbentligt går der ikke mange dage før Opera har rettet op på denne fejl. Indlægget blev besvaret i går af en af deres udviklere og han skriver:</p>
<blockquote><p>This was by design but will be &#8220;fixed&#8221; <img src="http://dev.opera.com/community/graphics/smilies/smile.gif" class="smilie" alt=":smile:" height="17" width="17" /></p></blockquote>
<p>Så man har to valg:</p>
<ul>
<li>Vente og se hvornår de får implementeret den nye funktionalitet</li>
<li>Implementere en traversering af tilknyttede stylesheets for at finde de regler som berører netop de elementer man har brug for</li>
</ul>
<p>I dette tilfælde vil det nok være lidt nyttesløst at vælge det sidste, eftersom der ikke er nok der bruger Opera til at det giver mening, derudover er Opera ikke en standardbrowser på nogen platform, så folk der bruger Opera kan se siden i mindst én anden browser.</p>
<p>Hvis man endelig skulle vælge vej nummer 2 og kigge stylesheet&#8217;ene igennem, så skulle man nok implementere et fuldt css bibliotek, som også vil kunne bruges til at udjævne forskelle mellem browsere i forhold til implementationer af nuværende standarder og også i forhold til at implementere kommende standarder, indtil browserne selv gør det. Javascript er jo netop nået et punkt hvor det er gjort så hurtigt at det ikke vil betyde store ventetider at have store scripts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2008/11/11/typefacejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>z-index og ie 6</title>
		<link>http://www.flyvergrillen.dk/2008/11/11/z-index-og-ie-6/</link>
		<comments>http://www.flyvergrillen.dk/2008/11/11/z-index-og-ie-6/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 15:16:47 +0000</pubDate>
		<dc:creator>Anders Rasmussen</dc:creator>
				<category><![CDATA[Kode]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[z-index]]></category>

		<guid isPermaLink="false">http://www.flyvergrillen.dk/2008/11/11/z-index-og-ie-6/</guid>
		<description><![CDATA[Dette er viden som skulle have været ubrugelig for længe siden, men folk er ignorante, og derfor skal vi stadig supportere forældede browsere.
Den browser som givers os flest problemer er jo selvfølgeligt Microsofts Internet Explorer version 6.
En af de utallige bugs vi har haft problemer med er at vi har nogle popup-elementer som sidder på [...]]]></description>
			<content:encoded><![CDATA[<p>Dette er viden som skulle have været ubrugelig for længe siden, men folk er ignorante, og derfor skal vi stadig supportere forældede browsere.</p>
<p>Den browser som givers os flest problemer er jo selvfølgeligt Microsofts Internet Explorer version 6.</p>
<p>En af de utallige bugs vi har haft problemer med er at vi har nogle popup-elementer som sidder på vores brugerprofiler. Det virker som det skal i alle andre browsere, men ie6 synes ikke at det z-index popup-elementet har fået er godt nok og derfor vil den måske kunne skjule det bag andre elementer.</p>
<p>Måden den skjuler elementet på var dog ikke lige til at finde ud af, for det var kun nogen elementer der gemte popup&#8217;en. Efter lidt undersøgelse fandt jeg at de elementer der skjuler popup-elementet var relativt positioneret. og det element som popupen var i også var relativt positioneret. Det viser sig nemlig at ie6 ikke er tilfreds med at hvert element har deres helt eget z-index. I stedet siger den at den boks som elementet er inden i ligger i et lag for sig selv, som ingen andre elementer udefra kan komme imellem.</p>
<p>Dette betyder at man kan komme et hvilket som helst z-index på popup-elementet, det er stadig relativt i forhold til det element det er indeni. Og elementer der kommer umiddelbart efter vil, i kraft af at de kommer senere i dokumentet, overlappe ved &#8220;by-design&#8221; at have et højere z-index (på en måde). For atfå ie6 til at tegne det ordentligt, så bliver man nødt til at sætte z-index&#8217;et på popup-elementets relative parent til et andet højt z-index.</p>
<p>For mere dybdegående information: <a href="http://aplus.rs/lab/z-pos/">http://aplus.rs/lab/z-pos/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flyvergrillen.dk/2008/11/11/z-index-og-ie-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
