<?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>C.M. Jackson .Net &#187; Chris Jackson</title>
	<atom:link href="http://www.cmjackson.net/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cmjackson.net</link>
	<description>Web Design, Programming, Tutorials</description>
	<lastBuildDate>Tue, 18 May 2010 22:43:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up Structure Map</title>
		<link>http://www.cmjackson.net/2010/05/14/setting-up-structure-map/</link>
		<comments>http://www.cmjackson.net/2010/05/14/setting-up-structure-map/#comments</comments>
		<pubDate>Fri, 14 May 2010 14:34:20 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[StructureMap]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=388</guid>
		<description><![CDATA[StructureMap If you haven&#8217;t heard about dependency injection, it is something you should definitely look into. It can save tons of time when coding. StructureMap is a dependency injection framework that makes it easy to create new instances of objects and even cache an instance of an object so various references to the object use the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>StructureMap<br />
</strong>If you haven&#8217;t heard about dependency injection, it is something you should definitely look into. It can save tons of time when coding.</p>
<p>StructureMap is a dependency injection framework that makes it easy to create new instances of objects and even cache an instance of an object so various references to the object use the same instance. This is very useful with objects such as database connections.</p>
<p>You can download the library from <a href="http://structuremap.github.com/structuremap/index.html">the StructureMap Home Page</a>. The example used in this post is using StructureMap 2.6.1.  I&#8217;m also using Visual Basic.  I had a tough time finding information on how to use StructureMap with Visual Basic, so hopefully, this will help someone else.</p>
<p><strong>Setting Up MVC<br />
</strong>When using StructureMap with ASP.NET MVC 1.0, I&#8217;ve found it works best if a folder is created in each project; Main, Data, and Service; where the StructureMap files are stored. This keeps them organized and makes them easy to find as you need to update them. A reference to the StructureMap DLL will need to be added to each project as well.</p>
<p>In the main project&#8217;s StructureMap folder, the following files are needed:</p>
<p><strong>StructureMapControllerFactory</strong></p>
<pre class="brush: vb;">
Imports System.Web.Mvc
Imports StructureMap

Public Class StructureMapControllerFactory
    Inherits DefaultControllerFactory

    Protected Overrides Function GetControllerInstance(ByVal controllerType As System.Type) As System.Web.Mvc.IController

        Return ObjectFactory.GetInstance(controllerType)

    End Function

End Class</pre>
<p>This class sets up a factory class to get an instance of the StructureMap factory. It will be used to replace MVC&#8217;s default controller factory so that StructureMap will be in charge of creating our controllers.</p>
<p><strong>BootStrapper</strong></p>
<pre class="brush: vb;">
Imports StructureMap
Imports YourProject.Data
Imports YourProject.Services

Public Class BootStrapper

    Public Shared Sub ConfigureStructureMap()

        ObjectFactory.Initialize(AddressOf StructureMapRegistry)

    End Sub

    Private Shared Sub StructureMapRegistry(ByVal x As IInitializationExpression)

        x.AddRegistry(New MainRegistry())
        x.AddRegistry(New DataRegistry( _ ConfigurationManager.ConnectionStrings(&quot;iSeries&quot;).ConnectionString, _ ConfigurationManager.ConnectionStrings(&quot;Interbase&quot;).ConnectionString))
        x.AddRegistry(New ServiceRegistry())
        x.Scan(AddressOf StructureMapScanner)

    End Sub

    Private Shared Sub StructureMapScanner(ByVal scanner As StructureMap.Graph.IAssemblyScanner)

        scanner.Assembly(&quot;YourProjectNamespace&quot;)
        scanner.Assembly(&quot;YourProjectNamespace.Data&quot;)
        scanner.Assembly(&quot;YourProjectNamespace.Services&quot;)
        scanner.WithDefaultConventions()

    End Sub
End Class</pre>
<p>This class is where StructureMap is configured. Within the StructureMapRegistry method, each AddRegistry call is made to include each of our project&#8217;s registry files, which have yet to be created. We will get to that in a moment, but notice that the DataRegistry is accepting values for connection strings. This is how information can be passed into a class being created by StructureMap when you would like to keep the configuration settings within the Web.config file.</p>
<p>Also, within the StructureMapScanner method, an entry needs to be made to scan each project&#8217;s namespace.</p>
<p><strong>MainRegistry</strong></p>
<pre class="brush: vb;">
Imports DCS.Data
Imports StructureMap.Configuration.DSL

Public Class MainRegistry
    Inherits Registry

    Public Sub New()

        [For](Of IWebContext)() _
            .Use(Of WebContext)()

    End Sub

End Class</pre>
<p>Each project will have its own registry file where you can specify that Interface-A should create an instance of Class-A. In the example above, I want StructureMap to create an instance of WebContext (from the main project) when it comes across a reference to IWebContext. </p>
<p>In the Data project&#8217;s StructureMap folder you will need:</p>
<p><strong>DataRegistry</strong></p>
<pre class="brush: vb;">
Imports StructureMap.Configuration.DSL
Imports Spartan.DAO.Database

Public Class DataRegistry
    Inherits Registry

    Public Sub New(ByVal iSeriesConnectionString As String, ByVal interbaseConnectionString As String)

    'Data Connections.
    [For](Of YourDataContext)() _
        .HybridHttpOrThreadLocalScoped _
        .Use(Function() New YourDataContext())

    [For](Of DB2Connection)() _
        .HybridHttpOrThreadLocalScoped _
        .Use(Function() New DB2Connection(iSeriesConnectionString))

    [For](Of InterbaseConnection)() _
        .HybridHttpOrThreadLocalScoped _
        .Use(Function() New InterbaseConnection(interbaseConnectionString))

    'Repositories.
    [For](Of IShiftRepository)() _
        .Use(Of ShiftRepository)()

    End Sub

End Class</pre>
<p>The DataRegistry is interesting because we are passing in two connection strings from the Web.config file. The first data connection is for Microsoft SQL, the second for DB2 and the third for Interbase. The second and third are using the DB2Connection  and InterbaseConnection classes which are home grown database connection class that I wrote.  All three of these database connections are being cached by using the .HybridHttpOrThreadLocalScoped property. Using this will make the database cached instance work for both your live program and your unit testing.</p>
<p>The entry under repositories is what all remaining entries would look like within the registry class. Since the data project contains our repositories, they would all be listed here.</p>
<p>And, in the Service project&#8217;s StructureMap folder you will need:</p>
<p><strong>ServiceRegistry</strong></p>
<pre class="brush: vb;">
Imports StructureMap.Configuration.DSL

Public Class ServiceRegistry
    Inherits Registry

    Public Sub New()

        [For](Of IShiftService)() _
        .Use(Of ShiftService)()

    End Sub

End Class</pre>
<p>The service registry is similar to that of the main project. All service classes found in the service project would be listed here.</p>
<p><strong>Changes to the Global.asax</strong></p>
<p>The last thing to do is setup the Global.asax file to load StructureMap.  Make the following changes to the Application_Start method:</p>
<pre class="brush: vb;">
Sub Application_Start()

    RegisterRoutes(RouteTable.Routes)

    'StructureMap
    BootStrapper.ConfigureStructureMap()
    ControllerBuilder.Current.SetControllerFactory(New StructureMapControllerFactory())

End Sub</pre>
<p>Now, the default controller factory used by MVC will be overridden by our StructureMapControllerFactory. When a controller is created, it will now use StructureMap.</p>
<p>So, how do you use this when creating a class? This is the easy part.</p>
<p>StructureMap will use the greediest constructor from your controller, meaning, if you have two constructors, the one with the most parameters will be used. Each parameter references an Interface and sets a class variable for the object.  StructureMap uses the registry classes that we setup to map an interface to a real object.</p>
<p><strong>Example Controller</strong></p>
<pre class="brush: vb;">
Imports YourProject.Data
Imports YourProject.Services
Imports StructureMap

Public Class ExampleController
    Inherits System.Web.Mvc.Controller

    Private _shiftService As IShiftService
    Private _webContext As IWebContext

    Public Sub New( _
        ByVal shiftService As IShiftService, _
        ByVal webContext As IWebContext)

        _shiftService = shiftService
        _webContext = webContext

        'Initialize service classes.
        _shiftSummaryService.Initialize(New ModelStateWrapper(Me.ModelState))

    End Sub

    ...</pre>
<p>All that you need to do is create a constructor, pass in all the interface references you need for the controller, then store them in a class variable. If you need to use the ModelState for validation within your service class, the best way I&#8217;ve found to do this is use an Initialize function in your service class to pass in the ModelState. This is because the ModelState is not yet created by MVC when the service classes are created by StructureMap.</p>
<p>When StructureMap creates the instance of the ShiftService, it will look at the greediest constructor from that class to create instances for any required parameters. This continues for all classes that are referenced.</p>
<p>Once the solution has been configured to use StructureMap, the only thing you&#8217;ll need to maintain will be the registry files as you add new classes and interfaces to your project. Don&#8217;t forget to add a registry entry or you will recieve an exception.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/05/14/setting-up-structure-map/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using the Linq IQueryable Toolkit</title>
		<link>http://www.cmjackson.net/2010/02/10/using-the-linq-iqueryable-toolkit/</link>
		<comments>http://www.cmjackson.net/2010/02/10/using-the-linq-iqueryable-toolkit/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 19:14:45 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[IQToolkit]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=385</guid>
		<description><![CDATA[The IQToolkit provides you with a framework for building your own LINQ providers. The toolkit comes with providers for Microsoft SQL, Microsoft SQL CE, Access, MySQL, and SQLite. This post will show you how to use the toolkit to talk to Microsoft SQL. Later, I&#8217;ll be attempting to write my own providers for DB2 and [...]]]></description>
			<content:encoded><![CDATA[<p>The IQToolkit provides you with a framework for building your own LINQ providers. The toolkit comes with providers for Microsoft SQL, Microsoft SQL CE, Access, MySQL, and SQLite.</p>
<p>This post will show you how to use the toolkit to talk to Microsoft SQL. Later, I&#8217;ll be attempting to write my own providers for DB2 and Interbase 7.1.</p>
<p><strong>Download the toolkit</strong><br />
First thing to do is <a href="http://www.codeplex.com/IQToolkit">download the IQToolkit</a> (version 0.16a as of this posting).</p>
<p><strong>Reference the toolkit</strong><br />
I setup a console project to test the toolkit. Within your project, create a reference to the IQToolkit.Data.dll and the IQToolkit.dll. Then, add a reference to the dll for the provider you wish to use. In this case, we are using the IQToolkit.Data.SqlClient.dll for Microsoft SQL.</p>
<p><strong>Table objects</strong><br />
Next, you will need to create a class object for each table you need to work with in the database. I have a table that has two fields: PLCID and SummaryProdMode. Create a class object to hold these properties and then use the Column attribute to bind the property to the table column.</p>
<pre class="brush: vb;">
Imports IQToolkit.Data.Mapping

Public Class Machine

    Private _id As Integer
    Private _mode As Boolean

    &lt;Column(IsPrimaryKey:=True)&gt; _
    Public Property PLCID() As Integer
        Get
            Return _id
        End Get
        Set(ByVal value As Integer)
            _id = value
        End Set
    End Property

    &lt;Column()&gt; _
    Public Property SummaryProdMode() As Boolean
        Get
            Return _mode
        End Get
        Set(ByVal value As Boolean)
            _mode = value
        End Set
    End Property

End Class
</pre>
<p><strong>DataContext</strong><br />
The data context contains read only properties for each database table being used. In this case, I&#8217;m dealing with the DCM_Machines table.</p>
<pre class="brush: vb;">
Imports IQToolkit
Imports IQToolkit.Data.Mapping
Imports System.Linq

Public Class MachineDataContext

    Private _provider As IEntityProvider

    Public Property EntityProvider() As IEntityProvider
        Get
            Return _provider
        End Get
        Set(ByVal value As IEntityProvider)
            _provider = value
        End Set
    End Property

    &lt;Table()&gt; _
    Public ReadOnly Property Machines() As IEntityTable(Of Machine)
        Get
            Return EntityProvider.GetTable(Of Machine)(&quot;DCM_Machines&quot;)
        End Get
    End Property

    Public Sub New(ByVal provider As IEntityProvider)

        _provider = provider

    End Sub

End Class
</pre>
<p><strong>Using the provider</strong><br />
Use the following code to setup and use the provider with LINQ.</p>
<pre class="brush: vb;">
Imports IQToolkit.Data

Module Module1

    Sub Main()

        Dim provider = DbEntityProvider.From( _
            &quot;IQToolkit.Data.SqlClient&quot;, _
            &quot;YOUR_CONNECTION_STRING&quot;, _
            &quot;Machine&quot;)
        Dim db = New MachineDataContext(provider)

        Dim machs = (From m In db.Machines _
                    Select m).ToList()

        For Each m In machs

            Console.WriteLine(&quot;id=&quot; &amp; m.PLCID)

        Next

        Console.ReadLine()

    End Sub

End Module
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/02/10/using-the-linq-iqueryable-toolkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC &#8211; Organizing your solution</title>
		<link>http://www.cmjackson.net/2010/02/04/asp-net-mvc-organizing-your-solution/</link>
		<comments>http://www.cmjackson.net/2010/02/04/asp-net-mvc-organizing-your-solution/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 14:16:25 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[organization]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=379</guid>
		<description><![CDATA[Keeping your project files organized will help you navigate through your projects and help you find what you are looking for to make changes faster. Here are some tips that I use to help keep my ASP.NET MVC solutions organized: Use multiple projects to separate sections of the program. Use folders to group interfaces, classes, and factories [...]]]></description>
			<content:encoded><![CDATA[<p>Keeping your project files organized will help you navigate through your projects and help you find what you are looking for to make changes faster.</p>
<p>Here are some tips that I use to help keep my ASP.NET MVC solutions organized:</p>
<ol>
<li>Use multiple projects to separate sections of the program.</li>
<li>Use folders to group interfaces, classes, and factories that deal with an object.</li>
<li>If objects can be used by other programs, put them in their own class library project.</li>
</ol>
<p><strong>Option 1</strong><br />
When beginning a new program, I usually start by creating an ASP.NET MVC solution with 4 projects:</p>
<ul>
<li><span style="text-decoration: underline;">The main project</span> &#8211; which contains the MVC components of the application such as Controllers, Views, CSS, and JavaScript files.</li>
<li><span style="text-decoration: underline;">The unit testing project</span> &#8211; which contains all of the requirements for the application along with any fake repositories used for testing.</li>
<li><span style="text-decoration: underline;">The data project</span> &#8211; which contains the repositories and domain objects used by the application.</li>
<li><span style="text-decoration: underline;">The services project</span> &#8211; which contains the service objects that are the middle-man between the Controller and the Repository.</li>
</ul>
<p><strong>Option 2</strong><br />
Folders are used within the projects to further organize the code files within. The data project could have a domain object called Operation.  Domain objects are placed in a folder with the same name as the object.  Interfaces, Repositories, and Factories that deal with the object are also placed in the domain object folder.</p>
<p>The service project is organized similar to the data project.</p>
<p>The unit test project is slightly modified from the default to create a folder which contains all fake repository objects and another folder to contain requirement tests. Depending on the detail of unit testing you wish to utilize, you may have unit tests that verify application requirements and/or unit tests that further verify other parts your code.</p>
<p>In my opinion, you can write application requirements that detail exactly what the program should do and as long as you unit test these requirements, you don&#8217;t need to waste time trying to unit test 100% of your program. If a bug is found later, it will most likely be because it was not an application requirement. Then, add a new requirement, write a unit test, and make the application pass the new test.</p>
<p><strong>Option 3</strong><br />
Where I work, we have various databases that we need to communicate with. We wanted a way to use these databases the same way every time without having to remember all of the different objects and names that needed to be used by each. So, I developed a parent wrapper class around the basic database functionality and then individual wrappers around each database object that inherited from the parent wrapper. Now, we can call up any of the database connections and work with them in exactly the same way, the only difference between them is the call to the factory when creating the instance.</p>
<p>These database wrappers were added to their own separate project so that in future applications, we could continue to reuse them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/02/04/asp-net-mvc-organizing-your-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Balloon rocket</title>
		<link>http://www.cmjackson.net/2010/02/03/balloon-rocket/</link>
		<comments>http://www.cmjackson.net/2010/02/03/balloon-rocket/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 14:27:39 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[children's projects]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=376</guid>
		<description><![CDATA[Yesterday, I spent the day with my daughter at her preschool class helping out with the kids. She was excited to bring daddy to school. The day had a space theme and the kids had fun learning about rockets and space shuttles. On of the activities the teacher had setup for them was a balloon [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I spent the day with my daughter at her preschool class helping out with the kids. She was excited to bring daddy to school.</p>
<p>The day had a space theme and the kids had fun learning about rockets and space shuttles. On of the activities the teacher had setup for them was a <a href="http://www.sciencebob.com/experiments/balloonrocket.php">balloon rocket</a> that the kids could blow up and shoot from one side of the room to the other.</p>
<p>Each kid also received a balloon rocket kit to take home. My daughter loved this. We had to go home and setup her rocket in the living room.</p>
<p>If you have a preschool aged child, they&#8217;ll love the balloon rocket.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/02/03/balloon-rocket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music Digital DNA Search for your PC</title>
		<link>http://www.cmjackson.net/2010/02/01/music-digital-dna-search-for-your-pc/</link>
		<comments>http://www.cmjackson.net/2010/02/01/music-digital-dna-search-for-your-pc/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 14:00:55 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=373</guid>
		<description><![CDATA[In the past few years, we&#8217;ve had the ability to search for music by letting our cell phones scan the sound of a song and use its digital DNA to tell you the song title and direct you to where you can buy that song online. Now you can do the same from your PC [...]]]></description>
			<content:encoded><![CDATA[<p>In the past few years, we&#8217;ve had the ability to search for music by letting our cell phones scan the sound of a song and use its digital DNA to tell you the song title and direct you to where you can buy that song online.</p>
<p>Now you can do the same from your PC with <a href="http://www.wildbits.com/tunatic/">Tunatic</a>.</p>
<p>Tunatic uses your computer&#8217;s microphone to listen to the song and then checks their song database for a match. You can click a link that directs you to the Tunatic website where you are provided with links where you can buy the song.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/02/01/music-digital-dna-search-for-your-pc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selecting the last item of a collection using Linq-to-sql</title>
		<link>http://www.cmjackson.net/2010/01/29/selecting-the-last-item-of-a-collection-using-linq-to-sql/</link>
		<comments>http://www.cmjackson.net/2010/01/29/selecting-the-last-item-of-a-collection-using-linq-to-sql/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 14:00:00 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linq To SQL]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=367</guid>
		<description><![CDATA[Today I had some problems with Linq-To-SQL. I needed to get the last item from a collection and only return items where the date was older than two weeks from now. Data Tables The main items that I want to return from Linq are Revision records. A Revision has a collection of Document_History records that [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had some problems with Linq-To-SQL. I needed to get the last item from a collection and only return items where the date was older than two weeks from now.</p>
<p><strong>Data Tables</strong><br />
The main items that I want to return from Linq are Revision records. A Revision has a collection of Document_History records that keep track of updates to the revision. The Document_History record has a Date field that is the date and time when the history entry was inserted, or when the revision was modified.</p>
<p><strong>The Problem</strong><br />
When using the data objects that Linq generates, you are allowed to perform some functions, such as Last and Reverse on the collection of items.</p>
<pre class="brush: plain;">Revision.Document_History.Last.Date</pre>
<p>The above code would return the most recent date, or the last time a revision was updated.</p>
<p>But, when you try to use the Last method within a Linq statement, Visual Studio throws an error.</p>
<p><strong>The Fix</strong><br />
To get around this error, I figured out that you can select the latest date using a sub query and the Max method. Below is an example of the Linq-To-SQL code that worked for me.</p>
<pre class="brush: plain;">
Dim revs As List(Of Revision) = From r In dbcontext.Revisions _
                      Where (From h In r.Document_History _
                             Select h.Date).Max &lt;= cutoffDate _
                             Select r
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/01/29/selecting-the-last-item-of-a-collection-using-linq-to-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring IIS 6 and ASP.NET MVC</title>
		<link>http://www.cmjackson.net/2010/01/28/configuring-iis-6-and-asp-net-mvc/</link>
		<comments>http://www.cmjackson.net/2010/01/28/configuring-iis-6-and-asp-net-mvc/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 14:00:09 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[IIS 6.0]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=363</guid>
		<description><![CDATA[By default, IIS 6 does not work with ASP.NET MVC and needs to be configured to use wild-card mapping to get MVC&#8217;s routing and clean URLs to work correctly. Unfortunately, IIS 6 does take a performance hit because all requests are processed by ASP.NET. Static files, such as images, CSS, and JavaScript are processed as [...]]]></description>
			<content:encoded><![CDATA[<p>By default, IIS 6 does not work with ASP.NET MVC and needs to be configured to use wild-card mapping to get MVC&#8217;s routing and clean URLs to work correctly. Unfortunately, IIS 6 does take a performance hit because all requests are processed by ASP.NET. Static files, such as images, CSS, and JavaScript are processed as a dynamic page instead of a static one.</p>
<p><strong>Install ASP.NET MVC</strong><br />
Follow the first two steps of the instructions for <a href="http://www.cmjackson.net/2010/01/15/installing-asp-net-mvc/">installing ASP.NET MVC</a>. The third step can be ignored since Visual Studio will not be installed on the server.</p>
<p><strong>Configuring ASP.NET 2.0</strong><br />
First thing to do is open the IIS Manager -&gt;expand your server -&gt;Web Service Extensions folder. Right-click on the white space under the list of Web Service Extensions and select to Add a new Web service extension&#8230;</p>
<p>The New Web Service Extension window will pop open. Enter &#8220;ASP.NET v2.0.50727&#8243; as the Extension Name and click the Add button.  Browse to the C:\Windows\Microsoft.Net\Framework\v2.0.50727 folder and select the aspnet_isapi.dll file. Make sure to check the &#8220;Set extension status is Allowed&#8221; button before clicking OK.</p>
<p>This will allow your programs to run ASP.NET 2.0, 3.0, and 3.5 versions of the .NET framework.</p>
<p><strong>Configuring Your Web Application</strong><br />
The next thing to do is open the properties of the Web Site where your web application is. Select the ASP.NET tab and select 2.0.50717 in the ASP.NET version drop down box.</p>
<p>Next, click on the Home Directory tab. Click on the Configuration button. Under the Wild-card application maps area, click the Insert button. Browse to the C:\Windows\Microsoft.Net\Framework\v2.0.50727 folder and select the aspnet_isapi.dll file. Uncheck the &#8220;Verify that file exists&#8221; before clicking OK. Save your changes and your site should now be able to run ASP.NET MVC and use the routes setup by your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/01/28/configuring-iis-6-and-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dependency Injection</title>
		<link>http://www.cmjackson.net/2010/01/27/dependency-injection/</link>
		<comments>http://www.cmjackson.net/2010/01/27/dependency-injection/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 14:33:10 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Object Oriented Programming]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=358</guid>
		<description><![CDATA[Dependency Injection is a design pattern that is used in Object Oriented Programming to create a relationship between two objects without object A depending on object B. Instead, through the use of an Interface, a place-holder for object B can be referenced in object A. Then, object B can be passed into object A where it is [...]]]></description>
			<content:encoded><![CDATA[<p>Dependency Injection is a design pattern that is used in Object Oriented Programming to create a relationship between two objects without object A depending on object B. Instead, through the use of an Interface, a place-holder for object B can be referenced in object A. Then, object B can be passed into object A where it is utilized. If there is an object C that uses the same interface as object B, it may also be passed into object A.</p>
<p><strong>A Tightly Coupled Relationship</strong><br />
Below is an example of two classes that are tightly coupled, meaning that if we want to replace object B with another class, we must change the code of object A. Object A is dependent on object B to execute.</p>
<pre class="brush: vb;">
Public Class ObjectA

  Private _obj As ObjectB

  Public Sub New(ByVal obj As ObjectB)

    _obj = obj

  End Sub

  Public Sub RunB()

    _obj.Run()

  End Sub

End Class
</pre>
<p> </p>
<pre class="brush: vb;">
Public Class ObjectB

  Public Sub Run()

    Console.WriteLine(&quot;Run from objectB&quot;)

  End Sub

End Class
</pre>
<p><strong>A Loosely Coupled Relationship</strong><br />
Now, let&#8217;s look at a better approach that will allow us to replace ObjectB with another class using the same interface or replace it with a child class of ObjectB.</p>
<p>Below, the ObjectB class now implements the IObjectB interface and the references to ObjectB in ObjectA have been replaced with a reference to the interface IObjectB instead.</p>
<pre class="brush: vb;">
Public Interface IObjectB

  Sub Run()

End Interface
</pre>
<pre class="brush: vb;">
Public Class ObjectA

  Private _obj As IObjectB

  Public Sub New(ByVal obj As IObjectB)

    _obj = obj

  End Sub

  Public Sub RunB()

    _obj.Run()

  End Sub

End Class
</pre>
<pre class="brush: vb;">
Public Class ObjectB
  Implements IObjectB

  Public Sub Run() Implements IObjectB.Run

    Console.WriteLine(&quot;Run from objectB&quot;)

  End Sub

End Class
</pre>
<p>Now, ObjectA can execute no matter if we pass into it a copy of ObjectB or another class that implements the IObjectB interface. The Interface ensures that all objects that implement it will have a subroutine called Run. That is all that ObjectA needs to know. This breaks ObjectA&#8217;s dependency on ObjectB.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/01/27/dependency-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Repository Pattern</title>
		<link>http://www.cmjackson.net/2010/01/26/the-repository-pattern/</link>
		<comments>http://www.cmjackson.net/2010/01/26/the-repository-pattern/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 14:00:42 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[design patterns]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=354</guid>
		<description><![CDATA[The repository pattern is a design pattern that creates repositories of data that talk to a data source. These repositories are used to segregate the code that talks to a data source from the rest of your program. For example, your code that communicates to a database connection is stored within a repository class. Communication [...]]]></description>
			<content:encoded><![CDATA[<p>The repository pattern is a design pattern that creates repositories of data that talk to a data source. These repositories are used to segregate the code that talks to a data source from the rest of your program. For example, your code that communicates to a database connection is stored within a repository class. Communication between your program and the database is all funnelled through the repository class.</p>
<p>In <a href="http://en.wikipedia.org/wiki/Domain_driven_design">Domain Driven Design</a>, you create data objects that are logical representations of the data stored within a data source; such as a database. These data objects may not mimic the design of a database, but instead be a more logical grouping of properties and methods. The repository pattern can be used to create a repository class for each data object, where that object can then be created, read,  updated, or deleted (CRUD) from the data source.</p>
<p>Using the repository pattern with <a href="http://en.wikipedia.org/wiki/Dependency_injection">Dependency Injection</a> allows for the repository class to be mocked during testing, where a more controlled and faster repository can be created. Also, if the data source changes to a XML file or another database, the repository class can be replaced.</p>
<p>The Repository pattern is one of the design patterns that I use to build a more maintainable and flexible application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/01/26/the-repository-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vector class for Lotus Script</title>
		<link>http://www.cmjackson.net/2010/01/25/vector-class-for-lotus-script/</link>
		<comments>http://www.cmjackson.net/2010/01/25/vector-class-for-lotus-script/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 14:18:23 +0000</pubDate>
		<dc:creator>Chris Jackson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Lotus Script]]></category>

		<guid isPermaLink="false">http://www.cmjackson.net/?p=351</guid>
		<description><![CDATA[The following is a script library written in Lotus Script to allow programmers to use a vector in their Lotus Script code. Option Declare Option Base 0 Public Class Vector 'Private data members Private vArray As Variant Private vCapacity As Integer Private vSize As Integer Public Sub New() 'Initialize variables Call SetCapacity(0) Call SetSize(0) Call [...]]]></description>
			<content:encoded><![CDATA[<p>The following is a script library written in Lotus Script to allow programmers to use a vector in their Lotus Script code.</p>
<pre class="brush: vb;">
Option Declare
Option Base 0

Public Class Vector

	'Private data members
	Private vArray    As Variant
	Private vCapacity As Integer
	Private vSize     As Integer

	Public Sub New()

		'Initialize variables
		Call SetCapacity(0)
		Call SetSize(0)
		Call Reserve(10)

	End Sub

	Public Sub Delete()

		Call EraseAll()

		'Clear the array
		Set vArray = Nothing

	End Sub

	Private Sub SetCapacity(newCapacity As Integer)

		vCapacity = newCapacity

	End Sub

	Public Function Capacity() As Integer

		Capacity = vCapacity

	End Function

	Private Sub SetSize(newSize As Integer)

		vSize = newSize

	End Sub

	Public Function Size() As Integer

		Size = vSize

	End Function

	Public Function Empty() As Boolean

		'Declare variables
		Dim valid As Boolean

		'Get the size
		If (Size() = 0) Then

			valid = True

		Else

			valid = False

		End If

		'Return if the vector is empty
		Empty = valid

	End Function

	Public Sub Reserve(minCapacity As Integer)

		'Declare variables
		Dim openElements As Integer
		Dim newCapacity As Integer

		'Initialize variables
		openElements = Capacity() - Size()
		newCapacity = Capacity()

		'Check if there are any open slots remaining
		If (openElements = 0) Then

			newCapacity = (Capacity() * 1.5)

		End If

		'Make sure that the minimum capacity is stored
		If (newCapacity &lt; minCapacity) Then

			newCapacity = minCapacity

		End If

		'Check if a change to the capacity is being made
		If (Not(Capacity() = newCapacity)) Then

			'Check the size to determine if the array's contents need to be
			'saved while redimensioning the array
			If (Size() = 0) Then

				'Nothing stored yet, perform redim
				Redim vArray(newCapacity)

			Else

				'Keep the array's contents while extending its boundaries
				Redim Preserve array(newCapacity)

			End If

			'Update the capacity
			Call SetCapacity(newCapacity)

		End If

	End Sub

	Public Sub PushBack(newItem As Variant)

		'Check if the passed item/items is actually an array or a list
		If ((Not(Isarray(newItem))) And (Not(Islist(newItem)))) Then

			'Add the single item
			Call AddItem(newItem)

		Else

			'Add multiple items
			Forall item In newItem

				Call AddItem(item)

			End Forall

		End If

	End Sub

	Private Sub AddItem(newItem As Variant)

		'Declare variables
		Dim newSize As Integer

		'Initialize variables
		newSize = Size() + 1

		'Make sure there is enough capacity in the vector
		Call Reserve(newSize)

		'Insert the item into the vector
		If (Isobject(newItem)) Then

			Set vArray(Size()) = newItem

		Else

			vArray(Size()) = newItem

		End If

		'Increment the vector size
		Call SetSize(newSize)

	End Sub

	Public Function At(index As Integer) As Variant

		'Check the vector's index boundaries
		If ((index &lt; 0) Or (index =&gt; Size())) Then Error 2000, _
		&quot;[Vector Class]:(Function: At): Index out of bounds.&quot;

		'Check if the item is an object
		If (Isobject(vArray(index))) Then

			Set At = vArray(index)

		Else

			At = vArray(index)

		End If

	End Function

	Public Sub Erase(index As Integer)

		'Check if the index is out of bounds
		If ((index &lt; 0) Or (index =&gt; Size())) Then Error 2000, _
		&quot;[Vector Class]:(Function: Erase): Index out of bounds.&quot;

		'Declare variables
		Dim newArray As Variant
		Dim x As Integer
		Dim y As Integer

		'Initialize variables
		y = 0

		'Make a new array with the same capacity
		Redim newArray(Capacity())

		'Loop through each element of the vector
		For x = 0 To Size() - 1

			'Check if the current index is the one to remove
			If ((x &lt;&gt; index) And (Not(y &gt; Size()))) Then

				'Check if the item is an object
				If (Isobject(vArray(x))) Then

					Set newArray(y) = vArray(x)

				Else

					newArray(y) = vArray(x)

				End If

				'Increment the index counter
				y = y + 1

			End If

		Next x

		'Subtract one from the vector size
		Call SetSize(Size() - 1)

		'Set the new array as the vector
		vArray = newArray

	End Sub

	Public Function BeginIndex() As Integer

		BeginIndex = 0

	End Function

	Public Function EndIndex() As Integer

		EndIndex = Size() - 1

	End Function

	Public Sub EraseAll()

		'Declare variables
		Dim x As Integer

		'Loop through each element of the array
		For x = BeginIndex() To EndIndex()

			'Delete each element of the arra
			'Check if the item is an object
			If (Isobject(vArray(x))) Then

				Set vArray(x) = Nothing

			End If

		Next

		'Reset the size.
		Call SetSize(0)

	End Sub

End Class
</pre>
<p>Copy the above code and paste into a script library for the database where you would like to use a vector. Then, you can use the example below to use the vector class.</p>
<pre class="brush: vb;">
Use &quot;libVector&quot;

Dim vector As New Vector()
dim obj As String

obj = &quot;hello&quot;

'Load any object into the vector.
Call vector.PushBack(obj)
Call vector.PushBack(obj)

'Loop through the vector to retrieve objects.
For i = vector.BeginIndex() To vector.EndIndex()

  Print &quot;Item: &quot; &amp; i &amp; &quot; &quot; &amp; vector.At(i)

Next
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cmjackson.net/2010/01/25/vector-class-for-lotus-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
