<?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>Sam Beauvois &#187; .NET</title>
	<atom:link href="http://www.sambeauvois.be/blog/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sambeauvois.be/blog</link>
	<description>general dev, .net and other stuff</description>
	<lastBuildDate>Fri, 03 Sep 2010 14:11:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Debugging ADO.NET Datatables</title>
		<link>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/</link>
		<comments>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/#comments</comments>
		<pubDate>Fri, 14 May 2010 13:32:54 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=246</guid>
		<description><![CDATA[Do you ever had the famous error message :
&#8220;Failed to enable constraints. One or more rows  contain values violating non-null, unique, or foreign-key  constraints.&#8221;
when using ADO.NET Datasets ?
Tthis is an incredibly useful message isn&#8217;t it ?
So what can you do to spare you some headaches ? Retrieve a more useful message sure !
You have to [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever had the famous error message :</p>
<blockquote><p>&#8220;Failed to enable constraints. One or more rows  contain values violating non-null, unique, or foreign-key  constraints.&#8221;</p></blockquote>
<p>when using ADO.NET Datasets ?</p>
<p>Tthis is an incredibly useful message isn&#8217;t it ?</p>
<p>So what can you do to spare you some headaches ? Retrieve a more useful message sure !</p>
<p>You have to know that a Datatable object have a &#8220;HasError&#8221; property, this property allows you to know if the datatable has one ore more rows in error.</p>
<p>When HasError is true, you can retrieve the rows havin an error with the DataTable&#8217;s &#8220;GetErrors()&#8221; method wich return an array with all datarow having an error.</p>
<p>The &#8220;in errror&#8221; rows can inform you about errors with the &#8220;RowError&#8221; property.</p>
<p>Here is a simple helper class which can be used to debug a single DataTable or an entire DataSet:</p>
<pre class="brush: csharp;">
using System;
using System.Data;

public class DataSetErrorRevealer
{

   /// &lt;summary&gt;
   /// Get errors on rows of a DataTable
   /// &lt;/summary&gt;
   /// &lt;param name=&quot;errorDataTable&quot;&gt;The DataTable to be checked&lt;/param&gt;
   public static void RevealTableErrors(DataTable errorDataTable)
   {
      if (errorDataTable == null)
      {
         Console.WriteLine(&quot;The provided DataTable object is null&quot;);
         return;
      }

      if (errorDataTable.HasErrors)
      {
         DataRow[] rowsInError = errorDataTable.GetErrors();
         if (rowsInError.Length &lt;= 0)
         {
            Console.WriteLine(&quot;There is no problem with table {0}&quot;, errorDataTable.TableName);
         }
         else
         {
            foreach (DataRow errorRow in rowsInError)
            {
               Console.WriteLine(errorRow.RowError);
            }
         }
      }
   }

   /// &lt;summary&gt;
   /// Get errors on row for all tables of a DataSet
   /// &lt;/summary&gt;
   /// &lt;param name=&quot;errorDataSet&quot;&gt;The Dataset to be checked&lt;/param&gt;
   public static void RevealDataSetErrors(DataSet errorDataSet)
   {
         if (errorDataSet == null)
         {
            Console.WriteLine(&quot;The provided DataSet is null&quot;);
            return;
         }

         foreach (DataTable errorTable in errorDataSet.Tables)
         {
            RevealTableErrors(errorTable);
         }
      }
   }
</pre>
<p>Use it this way :</p>
<pre class="brush: csharp;">

   TestDataSet dataset = new TestDataSet();
   try
   {
      using (SqlConnection sqlCon = new SqlConnection(&quot;MyConnectionString&quot;))
      {
         SqlCommand sqlComm = sqlCon.CreateCommand();
         sqlComm.CommandType = CommandType.StoredProcedure;
         sqlComm.CommandText = &quot;Select Stored procedure&quot;;
         SqlDataAdapter sqlDa = new SqlDataAdapter(sqlComm);
         sqlDa.Fill(dataset);
      }
   }
   catch (Exception ex)
   {
   // Will provide the error message :
   // &quot;Failed to enable constraints. One or more rows
   // contain values violating non-null, unique,
   // or foreign-key  constraints.&quot;
   Console.WriteLine(&quot;Error : {0}&quot;, ex);

   // will provide a more helpful message
   DataSetErrorRevealer.RevealDataSetErrors(dataset);
   }
</pre>
<p>If you prefer, you can use an extension method :</p>
<pre class="brush: csharp;">

using System.Data;
using System;

public static class DataSetExtensions
{
   public static void RevealErrors(this DataSet errorDataSet)
   {
      if (errorDataSet == null)
      {
         Console.WriteLine(&quot;The provided DataSet is null&quot;);
         return;
      }

      foreach (DataTable errorTable in errorDataSet.Tables)
      {
         errorTable.RevealErrors();
      }
   }

   public static void RevealErrors(this DataTable errorDataTable)
   {
      if (errorDataTable == null)
      {
         Console.WriteLine(&quot;The provided DataTable object is null&quot;);
         return;
      }

      if (errorDataTable.HasErrors)
      {
         DataRow[] rowsInError = errorDataTable.GetErrors();
         if (rowsInError.Length &lt;= 0)
         {
            Console.WriteLine(&quot;There is no problem with table {0}&quot;, errorDataTable.TableName);
         }
         else
         {
            foreach (DataRow errorRow in rowsInError)
            {
               Console.WriteLine(errorRow.RowError);
            }
         }
      }
   }
}
</pre>
<p>use :</p>
<pre class="brush: csharp;">

catch (Exception ex)
{
   // will provide an helpful message
   dataset.RevealErrors();
}
</pre>
<p>Hope this helps !</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 211px; width: 1px; height: 1px; overflow: hidden;">using System;<br />
using System.Data;public class DataSetErrorRevealer<br />
{</p>
<p>/// &lt;summary&gt;<br />
/// Get errors on rows of a DataTable<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&#8221;errorDataTable&#8221;&gt;The DataTable to be checked&lt;/param&gt;<br />
public static void RevealTableErrors(DataTable errorDataTable)<br />
{<br />
if (errorDataTable == null)<br />
{<br />
Console.WriteLine(&#8221;The provided DataTable object is null&#8221;);<br />
return;<br />
}</p>
<p>if (errorDataTable.HasErrors)<br />
{<br />
DataRow[] rowsInError = errorDataTable.GetErrors();<br />
if (rowsInError.Length &lt;= 0)<br />
{<br />
Console.WriteLine(&#8221;There is no problem with table {0}&#8221;, errorDataTable.TableName);<br />
}<br />
else<br />
{<br />
foreach (DataRow errorRow in rowsInError)<br />
{<br />
Console.WriteLine(errorRow.RowError);<br />
}<br />
}<br />
}<br />
}</p>
<p>/// &lt;summary&gt;<br />
/// Get errors on row for all tables of a DataSet<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&#8221;errorDataSet&#8221;&gt;The Dataset to be checked&lt;/param&gt;<br />
public static void RevealDataSetErrors(DataSet errorDataSet)<br />
{<br />
if (errorDataSet == null)<br />
{<br />
Console.WriteLine(&#8221;The provided DataSet is null&#8221;);<br />
return;<br />
}</p>
<p>foreach (DataTable errorTable in errorDataSet.Tables)<br />
{<br />
RevealTableErrors(errorTable);<br />
}<br />
}<br />
}</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FreeImage and x64 projects : Yes you can !</title>
		<link>http://www.sambeauvois.be/blog/2010/05/freeimage-and-x64-projects-yes-you-can/</link>
		<comments>http://www.sambeauvois.be/blog/2010/05/freeimage-and-x64-projects-yes-you-can/#comments</comments>
		<pubDate>Fri, 14 May 2010 07:02:23 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CPP]]></category>
		<category><![CDATA[Libs]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/2010/05/freeimage-and-x64-projects-yes-you-can/</guid>
		<description><![CDATA[A few words about FreeImage
According to the website, FreeImage (http://freeimage.sourceforge.net) is an Open Source library project for developers who would like to support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by today&#8217;s multimedia applications.
FreeImage is easy to use, fast, multithreading safe, compatible with all 32-bit versions of Windows, and [...]]]></description>
			<content:encoded><![CDATA[<h3>A few words about FreeImage</h3>
<p>According to the website, FreeImage (<a href="http://freeimage.sourceforge.net" target="_blank" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net?referer=');">http://freeimage.sourceforge.net</a>) is an Open Source library project for developers who would like to support popular graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by today&#8217;s multimedia applications.</p>
<p>FreeImage is easy to use, fast, multithreading safe, compatible with all <strong><span style="color: #ff0000; font-size: medium;">32-bit</span></strong> versions of Windows, and cross-platform (works both with Linux and Mac OS X).</p>
<p>FreeImage is written in C++ but can be used in .NET by using a wrapper (which is provided on the site in the download section)</p>
<h3>Using FreeImage in a .NET project</h3>
<p>To use FreeImage with a .NET project, you have to include the native C++ library (<span style="text-decoration: underline;"><strong>FreeImage.dll</strong></span>) in the same folder as the executable or in a folder contained in the PATH variable (“%WINDIR%\System32” can be a good choice).<br />
A good way to include the FreeImage dll in the executable’s folder is to add it to your visual studio projet, and set the Build Action property to “none” and the Copy to Output Directory property to “Copy always”</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb.png" border="0" alt="image" width="484" height="216" /></a></p>
<p>You have to add a reference to the wrapper library too, which is “<strong>FreeImageNET.dll</strong>”.</p>
<p>Now, using the library is easy.</p>
<p>Add an using directive:</p>
<pre class="brush: csharp;">using FreeImageAPI;</pre>
<p>Check if the library is available :</p>
<pre class="brush: csharp;">
if (!FreeImage.IsAvailable())
{
   Console.WriteLine(&quot;FreeImage.dll seems to be missing. Aborting&quot;);
   return;
}
</pre>
<p>Do something with your pictures:</p>
<pre class="brush: csharp;">

FIBITMAP myImage= new FIBITMAP();
myImage= FreeImage.Load( [parameters] );

// some smart actions
</pre>
<p>Don’t forget to dispose your images when finished to use them</p>
<pre class="brush: csharp;">
if (!myImage.IsNull
{
   FreeImage.Unload(myImage);
}
myImage.SetNull();
</pre>
<p>Well, this is nice but it still has a problem with that library (there is always one):</p>
<h3>And with a x64 project ?</h3>
<p>The executable you build has to be the same architecture as the library. The library is x86 so you can use it for win32 applications. What if you have (for some reasons) to build an x64 application?</p>
<p>In that case, you have to rebuild the library to target X64 architectures.</p>
<p>Here is how to do that with Visual Studio 2010 (I assume that it’s more or less the same procedure with other visual studio versions).</p>
<p>Grab the latest FreeImage sources on  the download site (go to the <a href="http://freeimage.sourceforge.net/download.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net/download.html?referer=');">http://freeimage.sourceforge.net/download.html</a> page and click to the link in the Source Distribution section. Once you have the sources, unzip the archive (obvious but&#8230;)</p>
<p>In the FreeImage folder there is a visual studio 2005 and a visual studio 2003 solutions, pick the 2005.</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb1.png" border="0" alt="image" width="484" height="337" /></a></p>
<p>Convert the solution</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb2.png" border="0" alt="image" width="484" height="465" /></a><br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image3.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb3.png" border="0" alt="image" width="484" height="465" /></a><br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image4.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb4.png" border="0" alt="image" width="484" height="465" /></a><br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image5.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb5.png" border="0" alt="image" width="484" height="465" /></a><br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image6.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb6.png" border="0" alt="image" width="484" height="290" /></a></p>
<p>Notice the compilation configuration</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image7.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb7.png" border="0" alt="image" width="484" height="68" /></a></p>
<p>By default, Win32 is set : we don’t want that !</p>
<p>Go to the Configuration Manager</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image8.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb8.png" border="0" alt="image" width="484" height="124" /></a><br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image9.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb9.png" border="0" alt="image" width="484" height="352" /></a></p>
<p>As you can see, all FreeImage libs are set to target the Win32 platform, we want 64 bits !</p>
<p>Add a new solution platform</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb10.png" border="0" alt="image" width="484" height="352" /></a></p>
<p>Choose to target the x64 platform</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image11.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb11.png" border="0" alt="image" width="484" height="363" /></a></p>
<p>Just select x64 then click OK</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image12.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb12.png" border="0" alt="image" width="484" height="352" /></a></p>
<p>Close the manager</p>
<p>Build the solution (keyboard shortcut : ctrl-shift-B).</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image13.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb13.png" border="0" alt="image" width="484" height="176" /></a></p>
<p>And at this point you will see that there is a problem, yes, you don’t really think it would be that easy <img src='http://www.sambeauvois.be/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image14.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb14.png" border="0" alt="image" width="484" height="103" /></a></p>
<p>It seems that the compilation encounters a problem especially with the “LibOpenJpeg” project</p>
<p>So, to be sure, try to compile the library one at the same time</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb15.png" border="0" alt="image" width="437" height="484" /></a></p>
<p>We see that it is the LibOpenJPEG the big source of problems :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image16.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb16.png" border="0" alt="image" width="484" height="95" /></a></p>
<p>A quick Google search allows to find a post on the Google user group for OpenJPEG that helps:<br />
<a href="http://groups.google.com/group/openjpeg/browse_thread/thread/64b89cdb1a44bb3b/fd4db2f74c76db87?lnk=gst&amp;q=x64#fd4db2f74c76db87" target="_blank" onclick="pageTracker._trackPageview('/outgoing/groups.google.com/group/openjpeg/browse_thread/thread/64b89cdb1a44bb3b/fd4db2f74c76db87?lnk=gst_amp_q=x64_fd4db2f74c76db87&amp;referer=');">http://groups.google.com/group/openjpeg/browse_thread/thread/64b89cdb1a44bb3b/fd4db2f74c76db87?lnk=gst&amp;q=x64#fd4db2f74c76db87</a></p>
<p>The problematic file is the “opj_include.h” wich use a keyword non supported by the x64 architecture (the &#8220;_asm” keyword if you want to know. It’s because the c++ compiler does not support inline x64 assembly)</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image17.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb17.png" border="0" alt="image" width="170" height="484" /></a></p>
<p>We have to change :</p>
<pre class="brush: cpp;">
/* MSVC does not have lrintf */
#ifdef _MSC_VER
static INLINE long lrintf(float f){
 int i;

 _asm{
 fld f
 fistp i
 };

 return i;
}
#endif
</pre>
<p>to</p>
<pre class="brush: cpp;">
/* MSVC does not have lrintf */
#ifdef _MSC_VER
static INLINE long lrintf(float f){
#ifdef _M_X64
	return (long)((f&gt;0.0f) ? (f + 0.5f):(f -0.5f));
#else
	int i;

	_asm{
		fld f
		fistp i
	};

	return i;
#endif
}
#endif
</pre>
<p>Now compile</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image18.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/05/image_thumb18.png" border="0" alt="image" width="484" height="385" /></a></p>
<p>The project compiles pretty well, there is some remaining warnings . . . but it works.</p>
<p>Now you can use that library (mine can be downloaded at  <a href="http://www.sambeauvois.be/Demos/FreeImage/x64/FreeImageX64.zip" target="_blank">http://www.sambeauvois.be/Demos/FreeImage/x64/FreeImageX64.zip</a>) in your x64 applications</p>
<p>Attention anyway : the library will be slower !</p>
<h4>Additional links :</h4>
<p>FreeImage download page : <a title="http://freeimage.sourceforge.net/download.html" href="http://freeimage.sourceforge.net/download.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net/download.html?referer=');">http://freeimage.sourceforge.net/download.html</a><br />
FreeImage API documentation: <a href="http://freeimage.sourceforge.net/fnet/Index.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net/fnet/Index.html?referer=');">http://freeimage.sourceforge.net/fnet/Index.html</a></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 8091px; width: 1px; height: 1px; overflow: hidden;"><!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG /> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>FR-BE</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:EnableOpenTypeKerning /> <w:DontFlipMirrorIndents /> <w:OverrideTableStyleHps /> </w:Compatibility> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val="&#45;-" /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-520092929 1073786111 9 0 415 0;} @font-face 	{font-family:Consolas; 	panose-1:2 11 6 9 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:modern; 	mso-font-pitch:fixed; 	mso-font-signature:-520092929 1073806591 9 0 415 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page WordSection1 	{size:612.0pt 792.0pt; 	margin:70.85pt 70.85pt 70.85pt 70.85pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.WordSection1 	{page:WordSection1;} --><!--[if gte mso 10]> <mce:style><!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: green;" lang="EN-US">/* MSVC does not have lrintf */</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">#ifdef</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> _MSC_VER</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">static</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> INLINE <span style="color: blue;">long</span> lrintf(<span style="color: blue;">float</span> f){</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">#ifdef</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> _M_X64</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span><span style="color: blue;">return</span> (<span style="color: blue;">long</span>)((f&gt;0.0f) ? (f + 0.5f):(f -0.5f));</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">#else</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span><span style="color: blue;">int</span> i;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span><span style="color: blue;">_asm</span>{</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span>fld f</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span>fistp i</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span>};</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"><span> </span><span style="color: blue;">return</span> i;</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">#endif</span><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas;" lang="EN-US">}</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;" lang="EN-US">#endif</span></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/05/freeimage-and-x64-projects-yes-you-can/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The IX509CertificateRequestPkcs10 InitializeFromTemplateName adventure</title>
		<link>http://www.sambeauvois.be/blog/2010/04/the-ix509certificaterequestpkcs10-initializefromtemplatename-adventure/</link>
		<comments>http://www.sambeauvois.be/blog/2010/04/the-ix509certificaterequestpkcs10-initializefromtemplatename-adventure/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 16:54:31 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Certificate]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/2010/04/the-ix509certificaterequestpkcs10-initializefromtemplatename-adventure/</guid>
		<description><![CDATA[This week has been researches, tests and headaches to be able to make request on a Certificate Authority server from a web application.
My client has a Win server 2008 CA server for my developments
On this server I have a certificate template named “User Template”

My assignment was to request a certificate via an ASP.NET application.
After researches [...]]]></description>
			<content:encoded><![CDATA[<p>This week has been researches, tests and headaches to be able to make request on a Certificate Authority server from a web application.</p>
<p>My client has a Win server 2008 CA server for my developments</p>
<p>On this server I have a certificate template named “User Template”</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/Certificate_server_templates.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Certificate_server_templates" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/Certificate_server_templates_thumb.png" border="0" alt="Certificate_server_templates" width="484" height="297" /></a></p>
<p>My assignment was to request a certificate via an ASP.NET application.</p>
<p>After researches on how to do that, I found this blog post that helped me a lot : <a title="http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-create-a-certificate-request-with-certenroll-and-net-c.aspx" href="http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-create-a-certificate-request-with-certenroll-and-net-c.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/blogs.msdn.com/alejacma/archive/2008/09/05/how-to-create-a-certificate-request-with-certenroll-and-net-c.aspx?referer=');">http://blogs.msdn.com/alejacma/archive/2008/09/05/how-to-create-a-certificate-request-with-certenroll-and-net-c.aspx</a></p>
<p>In my development environment, I create a request for a certificate by using  this code</p>
<pre class="brush: csharp;">
 CERTENROLLLib.CX509CertificateRequestPkcs10Class request = new CERTENROLLLib.CX509CertificateRequestPkcs10Class();
 string templateName = &quot;User Template&quot;;
 try
 {
    request.InitializeFromTemplateName(CERTENROLLLib.X509CertificateEnrollmentContext.ContextUser, templateName);
 }
 catch (Exception ex)
 {
   log.DebugFormat(&quot;Error InitializeFromTemplateName : message {0}, inner : {1}, stack : {2}, source : {3}, target : {4} &quot;,
    ex.Message,
    ex.InnerException,
    ex.StackTrace,
    ex.Source,
    ex.TargetSite);
 }
</pre>
<p>And it worked just fine !</p>
<p>Then we moved the published solution to the staging environment, and the problems arrived . . .</p>
<p>It didn’t worked !</p>
<p>The error message said:</p>
<p>&#8220;CertEnroll::CX509CertificateRequestPkcs10::InitializeFromTemplateName: The requested certificate template is not supported by this CA. 0&#215;80094800 (-2146875392)&#8221;</p>
<p>stack :</p>
<p>&#8220;at CERTENROLLLib.CX509CertificateRequestPkcs10Class.InitializeFromTemplateName(X509CertificateEnrollmentContext Context, String strTemplateName)&#8221;</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/cererror.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="cererror" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/cererror_thumb.png" border="0" alt="cererror" width="484" height="294" /></a></p>
<p>We checked the security everywhere ( CA server, Certificate templates, IIS Account, …), give access to everyone on the CA, on the template, … without any success</p>
<p>Then, after days and hours of search and tests, I decided to re-read the method documentation : <a title="http://msdn.microsoft.com/en-us/library/aa377533%28v=VS.85%29.aspx" href="http://msdn.microsoft.com/en-us/library/aa377533%28v=VS.85%29.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/aa377533_28v=VS.85_29.aspx?referer=');">http://msdn.microsoft.com/en-us/library/aa377533%28v=VS.85%29.aspx</a></p>
<p>And I noticed the second parameter description:</p>
<blockquote>
<dt><em>strTemplateName</em> [in] </dt>
<dd>Pointer to a <strong>BSTR</strong> variable that contains the Common Name (CN) of the template as it appears in Active Directory or the dotted decimal <a href="http://msdn.microsoft.com/en-us/library/ms721599%28v=VS.85%29.aspx#_security_object_identifier_gly" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ms721599_28v=VS.85_29.aspx_security_object_identifier_gly?referer=');"><em>object identifier</em></a>.</p>
</dd>
</blockquote>
<p>I had never tried using the dotted decimal object identifier, so i give it a shot.</p>
<p>I retrieved the object identifier on a certificate previously created with the “User Template”</p>
<p>On the CA server, I had a certificate request with the template “User Template”, so I right-click on it, go to All Tasks and click on the “View attributes/Extensions. . .” menu item.</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image14.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb14.png" border="0" alt="image" width="484" height="304" /></a></p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image15.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb15.png" border="0" alt="image" width="484" height="103" /></a></p>
<p>A property windows opened, I go to the Extensions tab and click on the “Certificate Template Information” item.</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image16.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb16.png" border="0" alt="image" width="425" height="484" /></a></p>
<p>In the information panel, I can see the famous dotted decimal object identifier between brackets.</p>
<p>I copy-paste this identifier in my code :</p>
<pre class="brush: csharp;">
 CERTENROLLLib.CX509CertificateRequestPkcs10Class request = new CERTENROLLLib.CX509CertificateRequestPkcs10Class();
 string templateName = &quot;1.3.6.1.4.1.311.21.8.3531346.8488945.6374567.164989.5001604.52.12582268.10747996&quot;;
 try
 {
    request.InitializeFromTemplateName(CERTENROLLLib.X509CertificateEnrollmentContext.ContextUser, templateName);
 }
 catch (Exception ex)
 {
    log.DebugFormat(&quot;Error InitializeFromTemplateName : message {0}, inner : {1}, stack : {2}, source : {3}, target : {4} &quot;,
      ex.Message,
      ex.InnerException,
      ex.StackTrace,
      ex.Source,
      ex.TargetSite);
 }
</pre>
<p>I compiled, I tried in the development environment and it worked !!</p>
<p>(note: there is just a minimal change in my code since I put the “templateName” in a configuration file in order to be able to modify it)</p>
<p>So we moved the published solution to the staging environment,</p>
<p>retrieve the dotted decimal object identifier corresponding to the “User Template” on the staging CA server,</p>
<p>copy-pasted this identifier in the configuration file,</p>
<p>executed a “IISRESET” command and try to execute the application.</p>
<p>And it worked !</p>
<p>We can&#8217;t figured out why it worked in the development environment but not in the staging one while both are equals. So If anyone knows about it, please let me know.</p>
<p>So, don’t trust the template name and use the object identifier !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/04/the-ix509certificaterequestpkcs10-initializefromtemplatename-adventure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visual Studio Default Key binding posters</title>
		<link>http://www.sambeauvois.be/blog/2010/04/visual-studio-default-key-bindings-posters/</link>
		<comments>http://www.sambeauvois.be/blog/2010/04/visual-studio-default-key-bindings-posters/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 07:57:59 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=320</guid>
		<description><![CDATA[The visual studio 2010 keybinding poster is available since a few weeks.
Visual C# 2010 default key bindings preview :


Shortcuts are grouped by category (debuging, refactoring, editing,  navigation, &#8230;)
Here is the Visual Studio Keyboard shortcuts posters for C#:
Visual Studio 2010

Download the pdf
Go to the msdn page

Visual Studio  2008

Download the pdf
Go to the msdn page

Visual Studio [...]]]></description>
			<content:encoded><![CDATA[<p>The visual studio 2010 keybinding poster is available since a few weeks.</p>
<p>Visual C# 2010 default key bindings preview :</p>
<p style="text-align: center;"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/VS2010CsharpKeyBinding1.png" target="_blank"><img class="aligncenter" title="VS2010CsharpKeyBinding1" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/VS2010CsharpKeyBinding1-300x149.png" alt="VS2010CsharpKeyBinding1" width="300" height="149" /></a></p>
<h3><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/VS2010CsharpKeyBinding2.png" target="_blank"><img class="aligncenter" title="VS2010CsharpKeyBinding2" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/VS2010CsharpKeyBinding2-300x149.png" alt="VS2010CsharpKeyBinding2" width="300" height="149" /></a></h3>
<p>Shortcuts are grouped by category (debuging, refactoring, editing,  navigation, &#8230;)</p>
<h4>Here is the Visual Studio Keyboard shortcuts posters for C#:</h4>
<h4>Visual Studio 2010</h4>
<ul>
<li>Download <a href="http://www.sambeauvois.be/Docs/Microsoft/VS2010CSharp.pdf">the pdf</a></li>
<li>Go to the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=92ced922-d505-457a-8c9c-84036160639f" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.microsoft.com/downloads/details.aspx?displaylang=en_amp_FamilyID=92ced922-d505-457a-8c9c-84036160639f&amp;referer=');">msdn page</a></li>
</ul>
<h4>Visual Studio  2008</h4>
<ul>
<li>Download <a href="http://www.sambeauvois.be/Docs/Microsoft/VS2008CSharp.pdf">the pdf</a></li>
<li>Go to the <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=e5f902a8-5bb5-4cc6-907e-472809749973" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.microsoft.com/downloads/details.aspx?displaylang=en_amp_FamilyID=e5f902a8-5bb5-4cc6-907e-472809749973&amp;referer=');">msdn page</a></li>
</ul>
<h4>Visual Studio 2005</h4>
<ul>
<li>Download <a href="http://www.sambeauvois.be/Docs/Microsoft/VS2005CSharp.pdf">the pdf</a></li>
<li>Go to the<a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=c15d210d-a926-46a8-a586-31f8a2e576fe" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.microsoft.com/downloads/details.aspx?displaylang=en_amp_FamilyID=c15d210d-a926-46a8-a586-31f8a2e576fe&amp;referer=');"> msdn page</a></li>
</ul>
<p><span id="result_box"><span style="background-color: #ffffff;" title="profitez en">Enjoy them !<br />
</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/04/visual-studio-default-key-bindings-posters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom paging with Subsonic 3 and ObjectDataSource in ASP.NET</title>
		<link>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/</link>
		<comments>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:34:08 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SubSonic]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=292</guid>
		<description><![CDATA[Here is how I created a paged items list in ASP.NET 3.5 using Subsonic for data access, and ASP.NET Controls for the display.
I use Subsonic 3.0.0.4 with ActiveRecord and ASP.NET 3.5 SP1 webforms.
For this example, we are creating a blog post list and that the DAL is created (the data class we use is &#8220;DAL.BlogPost&#8221;).
The [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how I created a paged items list in ASP.NET 3.5 using Subsonic for data access, and ASP.NET Controls for the display.</p>
<p>I use Subsonic 3.0.0.4 with ActiveRecord and ASP.NET 3.5 SP1 webforms.</p>
<p>For this example, we are creating a blog post list and that the DAL is created (the data class we use is &#8220;DAL.BlogPost&#8221;).</p>
<p>The DAL.BlogPost object has three properties we need : CreatedOn, Subject and Body.</p>
<h4>First step : prepare your data manager class</h4>
<pre class="brush: csharp;">

namespace MyBlog.BLL
{
   public class PostManager
   {
     // ...
   }
}
</pre>
<p>(keep in mind the namespace and the class for the nexts steps)</p>
<p>In this class, two methods are required,</p>
<p>The first returns the total number of items</p>
<pre class="brush: csharp;">

public int GetPostCount()
{
  return DAL.BlogPost.All().Count(x =&gt; x.IsDeleted != true);
}
</pre>
<p>The second one returns the items contained in a defined range (start index and then nomber of elements), so this method needs to know where to start and how many items to get.</p>
<pre class="brush: csharp;">

public PagedList&lt;DAL.BlogPost&gt; GetLastestPosts(int startRowIndex, int maximumRows)
{
   if (startRowIndex != 0)
   {
     startRowIndex =(startRowIndex/maximumRows);
   }

    IOrderedQueryable&lt;DAL.BlogPost&gt; yourQuery = DAL.BlogPost.All().OrderByDescending(x =&gt; x.CreatedOn);
    return new PagedList&lt;DAL.BlogPost&gt;(yourQuery, startRowIndex, maximumRows);
}
</pre>
<p>One important part to remember when using Subsonic is</p>
<pre class="brush: csharp;">

if (startRowIndex != 0)
{
   startRowIndex = startRowIndex / maximumRows;
}
</pre>
<p>This conversion is necessary because subsonic and the ObjectDataSource doesn&#8217;t share the same opinion about the paging method.<br />
Subsonic says</p>
<blockquote><p>&#8220;I want the third page containing five elements&#8221;</p></blockquote>
<p>ObjectDataSource says</p>
<blockquote><p>&#8220;I want the five elements following the third element&#8221;</p></blockquote>
<p>So the conversion is mandatory if you want a correct paging.</p>
<h4>Second step : create the aspx page.</h4>
<p>Declare an ObjectDataSource:</p>
<pre class="brush: xml;">
&lt;asp:ObjectDataSource runat=&quot;server&quot; ID=&quot;postsDataSource&quot;
 TypeName=&quot;Example.BLL.PostManager&quot;
 SelectMethod=&quot;GetLastestPosts&quot;
 EnablePaging=&quot;true&quot;
 SelectCountMethod=&quot;GetPostCount&quot; &gt;
 &lt;/asp:ObjectDataSource&gt;
</pre>
<p>Note the TypeName attribute : the value is the namespace + the class name of our datamanager class.<br />
We set the EnablePaging attribute to true and we specify the SelectCountMethod and the SelectMethod.</p>
<p>We don&#8217;t need any parameters for the paging, by default the MaximumRowsParameterName and StartRowIndexParameterName are set to &#8220;maximumRows&#8221; and &#8220;startRowIndex&#8221;.<br />
If we want other parameters names in our datamanager class, we can define them in the ObjectDataSource with these two parameters.</p>
<p>Add an asp ListView element</p>
<pre class="brush: xml;">
&lt;asp:ListView runat=&quot;server&quot; ID=&quot;postsListview&quot;
     DataSourceID=&quot;postsDataSource&quot;&gt;
 &lt;LayoutTemplate&gt;
    &lt;asp:PlaceHolder ID=&quot;itemPlaceHolder&quot;
         runat=&quot;server&quot; /&gt;
 &lt;/LayoutTemplate&gt;
 &lt;ItemTemplate&gt;
    &lt;h2&gt;&lt;%# Eval(&quot;CreatedOn&quot;,&quot;{0:d}&quot;)%&gt; :
     &lt;%# Eval(&quot;Subject&quot;) %&gt;&lt;/h2&gt;
    &lt;br /&gt;
    &lt;p&gt;
     &lt;%# Eval(&quot;Body&quot;) %&gt;
    &lt;/p&gt;
    &lt;hr /&gt;
 &lt;/ItemTemplate&gt;
&lt;/asp:ListView&gt;
</pre>
<p>Set the DataSourceID attribute to the ObjectDataSource ID parameter.</p>
<p>Define a LayoutTemplate and an ItemTemplate with the elements we want to display.</p>
<p>Then add an asp datapager control in the LayoutTemplate</p>
<pre class="brush: xml;">

&lt;LayoutTemplate&gt;

  &lt;asp:DataPager ID=&quot;postsDataPager&quot; runat=&quot;server&quot;
       PageSize=&quot;3&quot;&gt;
    &lt;Fields&gt;
      &lt;asp:NextPreviousPagerField ButtonType=&quot;Link&quot;
           FirstPageText=&quot;&lt;&lt;&quot; PreviousPageText=&quot;&lt;&quot;
           ShowNextPageButton=&quot;false&quot;
           ShowFirstPageButton=&quot;true&quot; /&gt;
      &lt;asp:NumericPagerField PreviousPageText=&quot;...&quot;
           NextPageText=&quot;...&quot; ButtonCount=&quot;10&quot; /&gt;
      &lt;asp:NextPreviousPagerField ButtonType=&quot;Link&quot;
           LastPageText=&quot;&gt;&gt;&quot; NextPageText=&quot;&gt;&quot;
           ShowPreviousPageButton=&quot;false&quot;
           ShowLastPageButton=&quot;true&quot; /&gt;
     &lt;/Fields&gt;
   &lt;/asp:DataPager&gt;

   &lt;asp:PlaceHolder ID=&quot;itemPlaceHolder&quot; runat=&quot;server&quot; /&gt;
 &lt;/LayoutTemplate&gt;
</pre>
<p>Here is the result :<br />
<a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/blogposts.png" target="_blank"><img class="aligncenter size-medium wp-image-307" title="blogposts" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/blogposts-300x178.png" alt="blogposts" width="300" height="178" /></a></p>
<h4>Remark about the data access method</h4>
<p>It&#8217;s possible to avoid the start index value conversion !</p>
<p>Check the PagedList first constructor code (<a href="http://github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Core/Schema/PagedList.cs" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/subsonic/SubSonic-3.0/blob/master/SubSonic.Core/Schema/PagedList.cs?referer=');">code is available on the subsonic git repository</a>)</p>
<pre class="brush: csharp;">

public PagedList(IQueryable&lt;T&gt; source, int index, int pageSize)
{
   int total = source.Count();
   TotalCount = total;
   TotalPages = total / pageSize;

   if(total % pageSize &gt; 0)
     TotalPages++;

   PageSize = pageSize;
   PageIndex = index;
   AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
}
</pre>
<p>As you can see, Subsonic use the Skip and the Take methods from Linq</p>
<p>So, you can modify the GetLastestPosts method to return a<span id="main" style="visibility: visible;"><span id="search" style="visibility: visible;"> strongly <em> </em></span></span> typed List in place of the PagedList:</p>
<pre class="brush: csharp;">

public List&lt;DAL.BlogPost&gt; GetLastestPosts(int startRowIndex, int maximumRows)
{
   return DAL.BlogPost.All().
          Skip(startRowIndex).
          Take(maximumRows).
          OrderByDescending(x =&gt; x.CreatedOn).
          ToList&lt;DAL.BlogPost&gt;();
}
</pre>
<p>With this method, no more conversion needed</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/04/custom-paging-with-subsonic-3-and-objectdatasource-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First use of Visual Studio 2010 : the installation</title>
		<link>http://www.sambeauvois.be/blog/2010/04/first-use-of-visual-studio-2010-the-installation/</link>
		<comments>http://www.sambeauvois.be/blog/2010/04/first-use-of-visual-studio-2010-the-installation/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 09:20:23 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/2010/04/first-use-of-visual-studio-2010-the-installation/</guid>
		<description><![CDATA[Yesterday I received a visual studio 2010 Ultimate edition from work. 
I&#8217;ve already test the&#160; express edition when it was in beta phase, but it’s not the same …
So, let’s install it ! 
I install it on a Fujitsu Siemens laptop with 4 GB Ram and a Intel Core 2 Duo processor (2,53 GHz) running&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I received a visual studio 2010 Ultimate edition from work. </p>
<p>I&#8217;ve already test the&#160; express edition when it was in beta phase, but it’s not the same …</p>
<h4>So, let’s install it ! </h4>
<p>I install it on a Fujitsu Siemens laptop with 4 GB Ram and a Intel Core 2 Duo processor (2,53 GHz) running&#160; Windows 7 64 bit Ultimate edition.</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb.png" width="484" height="406" /></a> </p>
<p>&#160;</p>
<h4 align="center">Launch the auto run program</h4>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image1.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb1.png" width="484" height="349" /></a></p>
<p align="center">Loading screen</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb2.png" width="484" height="344" /></a></p>
<p align="center">Click Next</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image3.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb3.png" width="484" height="344" /></a> </p>
<p align="center">Read and accept the license terms</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image4.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb4.png" width="484" height="344" /></a> </p>
<p align="center">Choose your installation mode : Full installation (takes more than 6 GB) or Custom installation</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image21.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image21_thumb.png" width="484" height="344" /></a> </p>
<p align="center">I choose Custom</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image24.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image24_thumb.png" width="484" height="344" /></a> </p>
<p align="center">Select the features you want :</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image27.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image27_thumb.png" width="484" height="344" /></a> </p>
<p align="center">(notice that “Microsoft SharePoint Developer Tools” are integrated)</p>
<p align="center">I just don’t want Dotfuscator community to be installed, so I uncheck&#160; it</p>
<p align="center">I keep the rest because I want to test some features</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image30.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image30_thumb.png" width="484" height="344" /></a> </p>
<h4 align="center">Click Install</h4>
<p align="center">Installation running : </p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image34.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image34_thumb.png" width="484" height="344" /></a> </p>
<p align="center">After less than 10 minutes, the installation asked me to restart my computer:</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image66.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image66_thumb.png" width="484" height="344" /></a> </p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image63.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image63_thumb.png" width="484" height="172" /></a> </p>
<p align="center">I click “Restart Now”</p>
<p align="center">&#160;</p>
<p align="center">When restarting, a loading form is showing</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image5.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb5.png" width="484" height="184" /></a> </p>
<p align="center">Then the setup continue</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image6.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb6.png" width="484" height="344" /></a> </p>
<p align="center">After about 45 minutes, the setup is finished</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image7.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb7.png" width="484" height="344" /></a> </p>
<p align="center">You can choose to install the documentation, but I choose to click on the “Finish” button.</p>
<p align="center">&#160;</p>
<p align="center">The installation windows appears :</p>
<p align="center"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image8.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb8.png" width="484" height="349" /></a> </p>
<p align="center">I Click Exit</p>
<h4 align="center">Visual Studio 2010 is now installed</h4>
<p>&#160;</p>
<p>The installation takes me about one hour, and no problem occurred.</p>
<p align="center">Now I can launch the product</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image9.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb9.png" width="238" height="484" /></a></p>
<p>&#160;</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image10.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb10.png" width="484" height="344" /></a> </p>
<p>&#160;</p>
</p>
<p align="center">I choose my default environment settings (I used to choose Visual C# Development settings so I pick this one).</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image11.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb11.png" width="469" height="484" /></a></p>
<p align="center">I Click on “Start Visual Studio”</p>
<p align="center">First time loading form</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image12.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb12.png" width="484" height="178" /></a></p>
<p>&#160;</p>
<p align="center">Visual studio is up and running</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image13.png" target="_blank"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/04/image_thumb13.png" width="484" height="388" /></a></p>
<p>&#160;</p>
<p>Help and documentation are on the start page:</p>
<p>A What’s new section is available on the start page :</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/bb386063(VS.100).aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/bb386063_VS.100_.aspx?referer=');">Visual Studio 2010 Overview</a> </li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms171868(VS.100).aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ms171868_VS.100_.aspx?referer=');">What’s new in .NET Framework 4</a> </li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb383815(VS.100).aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/bb383815_VS.100_.aspx?referer=');">What’s new in Visual C#</a> </li>
</ul>
<p>Some other links are available : </p>
<ul>
<li>Creating application with Visual Studio </li>
<li>Extending Visual Studio </li>
<li>Community and Learning Resources </li>
</ul>
<p>&#160;</p>
<p>Some resources for Windows, Web, Cloud, Office,SharePoint and Data development are accessible too.</p>
<p>&#160;</p>
<p>Next step : migration of a Visual studio 2008 solution !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/04/first-use-of-visual-studio-2010-the-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Mixer</title>
		<link>http://www.sambeauvois.be/blog/2010/02/css-mixer/</link>
		<comments>http://www.sambeauvois.be/blog/2010/02/css-mixer/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=207</guid>
		<description><![CDATA[ Css mixer is a tool I&#8217;ve developped in C# winforms, .NET framework 3.5
You can use it to improve you ASP.NET Themes or your CSS files for all your web projects.
If you have many css files linked to a page, you can group them in a single file with CSS Mixer.
You can also minify CSS files [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cssmixer.codeplex.com/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/cssmixer.codeplex.com/?referer=');"><img class="alignleft size-full wp-image-206" title="CSSmixer128" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/CSSmixer128.png" alt="CSSmixer128" width="128" height="128" /></a> Css mixer is a tool I&#8217;ve developped in C# winforms, .NET framework 3.5</p>
<p>You can use it to improve you ASP.NET Themes or your CSS files for all your web projects.</p>
<p>If you have many css files linked to a page, you can group them in a single file with CSS Mixer.</p>
<p>You can also minify CSS files to save the bandwith.</p>
<p> </p>
<p>To use it, open a folder containing CSS files,</p>
<p style="text-align: center;"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot.png" target="_blank"><img class="aligncenter size-full wp-image-208" title="cssmixer_screenshot" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot.png" alt="cssmixer_screenshot" width="480" /></a></p>
<p>choose an action (simple combine, or combine and minify) then click Save as &#8230;</p>
<p style="text-align: center;"><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot2.png" target="_blank"><img class="aligncenter size-full wp-image-209" title="cssmixer_screenshot2" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/02/cssmixer_screenshot2.png" alt="cssmixer_screenshot2" width="480" /></a></p>
<p>Download the last version of <a href="http://cssmixer.codeplex.com/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/cssmixer.codeplex.com/?referer=');">CSS Mixer on codeplex</a>.</p>
<p>I hope you&#8217;ll find it usefull. please give me feedback on it</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/02/css-mixer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy datatable&#8217;s row to an other datatable&#8217;s row</title>
		<link>http://www.sambeauvois.be/blog/2010/01/copy-datatables-row-to-an-other-datatables-row/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/copy-datatables-row-to-an-other-datatables-row/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 13:35:39 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=156</guid>
		<description><![CDATA[This method perform a row copy with a few checks


public static void CopyRowToAnOther(DataRow row, DataRow anOtherRow)
        {

            if (row == null &#124;&#124; row.Table == null
             [...]]]></description>
			<content:encoded><![CDATA[<p>This method perform a row copy with a few checks</p>
<pre class="brush: csharp;">

public static void CopyRowToAnOther(DataRow row, DataRow anOtherRow)
        {

            if (row == null || row.Table == null
                || anOtherRow == null || anOtherRow.Table == null)
            {
                return;
            }

            foreach (DataColumn colunm in row.Table.Columns)
            {
                if (anOtherRow.Table.Columns.Contains(colunm.ColumnName)
                &amp;&amp; !row.IsNull(colunm.ColumnName)
                &amp;&amp; colunm.DataType == anOtherRow.Table.Columns[colunm.ColumnName].DataType)
                {
                    anOtherRow[colunm.ColumnName] = row[colunm.ColumnName];
                }
            }
        }
</pre>
<div style="overflow: hidden;width: 1px;height: 1px">public static void CopyRowToAnOther(DataRow row, DataRow anOtherRow)</p>
<p>{</p>
<p>if (row == null || row.Table == null || anOtherRow == null || anOtherRow.Table==null)</p>
<p>{</p>
<p>return;</p>
<p>}</p>
<p>foreach (DataColumn colunm in row.Table.Columns)</p>
<p>{</p>
<p>if (anOtherRow.Table.Columns.Contains(colunm.ColumnName)</p>
<p>&amp;&amp; !row.IsNull(colunm.ColumnName)</p>
<p>&amp;&amp; colunm.DataType == anOtherRow.Table.Columns[colunm.ColumnName].DataType)</p>
<p>{</p>
<p>anOtherRow[colunm.ColumnName] = row[colunm.ColumnName];</p>
<p>}</p>
<p>}</p>
<p>}</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/copy-datatables-row-to-an-other-datatables-row/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t repeat your common CSS between your different themes</title>
		<link>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:02:53 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=150</guid>
		<description><![CDATA[To fully understand this article, you need an Asp.Net Themes system knowledge
The case :
You have an application with a CSS layout, and a few themes.
There is just a little change between the different themes, by example you change only the color scheme.
A solution to do that is to repeat all CSS files in all your [...]]]></description>
			<content:encoded><![CDATA[<p>To fully understand this article, you need an Asp.Net Themes system knowledge</p>
<h3>The case :</h3>
<p>You have an application with a CSS layout, and a few themes.<br />
There is just a little change between the different themes, by example you change only the color scheme.</p>
<p>A solution to do that is to repeat all CSS files in all your themes, and change the color part.<br />
The problem with that solution is that if you change one common style in one of your themes, you’ll have to repeat the change in all themes. This is a bad idea, it leads to chaos !</p>
<h3>Then how can you do to avoid the code repetition ?</h3>
<h4>My solution:</h4>
<p>1.) Create a Common Theme.</p>
<p>In the Common theme, you define CCS files with a default color scheme (just in case)</p>
<pre class="brush: css;">
.testclass
{
border:solid 1px #DDDDDD;
background-color:#DDDDAA;
font-size:xx-large;
}
</pre>
<p>2.) Create an other Theme (let say “Green”)</p>
<p>In the Green theme, you define CCS files with only the color information</p>
<pre class="brush: css;">

.testclass
{
background-color:#00FF00;
}
</pre>
<p>2b.) Create an other Theme (let say “Blue”)</p>
<p>In the Green theme, you define CCS files with only the color information</p>
<pre class="brush: css;">

.testclass
{
background-color:#0000FF;
}
</pre>
<p>Your Theme structure has to look like this :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb.png" border="0" alt="image" width="190" height="134" /></a></p>
<p>3.) Create a default page (Default.aspx)</p>
<p>And set the class of a div to “testclass” (define above)</p>
<pre class="brush: xml;">
&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Default.aspx.cs&quot; Inherits=&quot;ThemTests._Default&quot;
%&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head runat=&quot;server&quot;&gt;
 &lt;title&gt;Test with themes&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
 &lt;div&gt;
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut tellus eget turpis semper adipiscing sit amet id odio. Nunc vitae imperdiet tellus. Aenean quis orci metus, vitae placerat leo. Pellentesque luctus, lectus sit amet lacinia tincidunt, mi nibh sagittis nisl, vitae mollis eros nisi sit amet sem. Nunc dictum massa turpis. Etiam nisi mauris, consectetur et tempus id, pharetra in turpis. Nullam pretium ultricies nulla nec gravida. Sed porttitor metus nisl, ac condimentum nunc. Integer id feugiat orci. Maecenas ut lacinia purus. Mauris egestas mattis accumsan. Nunc in justo massa, quis egestas orci. Ut tincidunt, ligula sit amet tempor pharetra, magna mauris gravida mi, sed semper magna justo at velit. Donec vulputate fringilla lacus non sollicitudin. Morbi nulla nibh, pellentesque sed bibendum cursus, malesuada ut nisi.
 &lt;/div&gt;
 &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>4.) Edit the Web.Config file</p>
<p>Go to the “Pages” section, set the styleSheetTheme attribute to “Common” and the theme attribute to “Green”</p>
<pre class="brush: xml;">

&lt;pages styleSheetTheme=&quot;Common&quot; theme=&quot;Green&quot;&gt;
</pre>
<p>Now launch your web application, the result has to be like this :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image1.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb1.png" border="0" alt="image" width="604" height="484" /></a></p>
<p>See in firebug :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image2.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2010/01/image_thumb2.png" border="0" alt="image" width="644" height="252" /></a></p>
<h3>Explanation :</h3>
<p>This works because of the styleSheetTheme and theme attributes.</p>
<p>In fact, ASP.NET applies the styleSheetTheme defined theme first, then applies the page defined styles and at least applies the theme defined theme.</p>
<p>With this technique you can get rid of a few headaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/dont-repeat-your-common-css-between-your-different-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change the style elements of a listview? (the simple way)</title>
		<link>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:14:40 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=141</guid>
		<description><![CDATA[With the ast.net listview control, you can set an AlternatingItemTemplate in order to change the display or what you want.
If you just want to change the backcolor or things like that, you can spare some time by using only the ItemTemplate and applying a diffenrent style depending of the index (use of the Container.DataItemIndex property).
example [...]]]></description>
			<content:encoded><![CDATA[<p>With the ast.net listview control, you can set an <em>AlternatingItemTemplate </em>in order to change the display or what you want.</p>
<p>If you just want to change the backcolor or things like that, you can spare some time by using only the <em>ItemTemplate </em>and applying a diffenrent style depending of the index (use of the <strong>Container.DataItemIndex</strong> property).</p>
<p><em>example</em> : let’s say that your listview generate a &lt;table&gt; and each <em>ItemTemplate</em> generate a row of this table, just do :</p>
<pre class="brush: xml;">
&lt;ItemTemplate&gt;
  &lt;tr class='&lt;%# Container.DataItemIndex % 2 == 0 ? “normal” : “alternating” %&gt;'&gt;
    &lt;td&gt;blah blah&lt;/td&gt;
  &lt;/tr&gt;
&lt;/ItemTemplate&gt;
</pre>
<p><span><span style="background-color: #ffffff" title="c'est tout">that&#8217;s all you need !<br />
</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/how-to-change-the-style-elements-of-a-listview-the-simple-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
