<?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>Marcus Bratton&#039;s Blog</title>
	<atom:link href="http://lostechies.com/marcusbratton/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/marcusbratton</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Fri, 17 Sep 2010 05:15:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Contextual Awareness &#8211; Making your container behave intelligently</title>
		<link>http://lostechies.com/marcusbratton/2010/09/17/contextual-awareness-making-your-container-behave-intelligently/</link>
		<comments>http://lostechies.com/marcusbratton/2010/09/17/contextual-awareness-making-your-container-behave-intelligently/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 05:15:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/09/17/contextual-awareness-making-your-container-behave-intelligently.aspx</guid>
		<description><![CDATA[Containers are dumb &#8211; what if they were smart? One of the things I really wanted to do when I set out to create the ServiceLocator in Siege.Requisitions was to create a container that could map an interface to multiple&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2010/09/17/contextual-awareness-making-your-container-behave-intelligently/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Containers are dumb &#8211; what if they were smart?</h2>
<p>One of the things I really wanted to do when I set out to create the ServiceLocator in Siege.Requisitions was to create a container that could map an interface to multiple types, and then at runtime, automatically figure out which one of those types I really wanted. To accomplish this, I put at it&#8217;s core a small rule engine to allow users to create rules that would help the container understand how to pick implementations. It works great &#8212; but there&#8217;s one problem. You have to specifically tell it what you want. That&#8217;s hardly much better than resolving the type directly; you have to program intent directly into your application, and you carry around references to IServiceLocator.</p>
<p>Very ugly.</p>
<p>I keep coming back to the original premise &#8230; I want the container to figure it out for me. I want to explain to the container what I want it to do, and under which conditions. Then I want it to figure it out for itself at runtime by understanding the state of the application, the user session, whatever I have explained to it. I want a <strong>smart</strong>&nbsp;container. But the problem is, most containers are dumb. You map an interface to a type &#8212; thats it. You want multiple types? Register them with names to distinguish them. Register different &#8220;profiles&#8221; to instruct the container to run in certain modes. Create child containers.</p>
<p>I just didn&#8217;t feel like those solutions worked well for me. I want a smart container that can figure it all out. I don&#8217;t want to spend time building families of containers and wiring it all together and telling them how to interact. I don&#8217;t want to have to make my application look up values by a name, or set my container into a certain &#8220;profile mode&#8221;. I want to focus on my application. I want to explain my scenario to the container and move on and not think about my container anymore.</p>
<h2>A practical example</h2>
<p>As I mentioned in my previous post, we encounter this scenario in our every day development at my company. Where I work, we integrate with a lot of partners. There are a lot of commonalities between these vendors and we have abstracted them out dutifully into interfaces with multiple implementations. Basic abstraction and polymorphism. We routinely have scenarios where user input/selections on a UI translates into a vendor call. Ultimately, this means resolving a specific implementation of an interface to send or request data from that vendor.</p>
<p>We have our registrations set up with rules like so:</p>
<p>&nbsp;</p>
<p>
serviceLocator.Register&lt;Singleton&gt;(Given&lt;IExampleService&gt;.When&lt;SelectionType&gt;(selection =&gt; selection == SelectionType.OptionA).Then&lt;OptionAService&gt;();<br />
serviceLocator.Register&lt;Singleton&gt;(Given&lt;IExampleService&gt;.When&lt;SelectionType&gt;(selection =&gt; selection == SelectionType.OptionB).Then&lt;OptionBService&gt;();</p>
<p>&nbsp;</p>
<p>For the sake of this example, SelectionType is an enum representing a vendor we integrate with. Implementations of IExampleService contain code that we use to integrate with those vendors. The registration API allows you to specify the lifestyle with the method call (in this case, singleton). And with those registrations in place, you&#8217;d see controller code like this:</p>
<p>&nbsp;</p>
<p>public class SampleController : Controller<br />{<br />&nbsp;&nbsp; &nbsp; private IServiceLocator serviceLocator;<br />&nbsp;&nbsp; &nbsp;<br />&nbsp;&nbsp; &nbsp; public SampleController(IServiceLocator locator)<br />&nbsp;&nbsp; &nbsp; {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this.serviceLocator = locator;<br />&nbsp;&nbsp; &nbsp; }</p>
<p>&nbsp;&nbsp; &nbsp; public ViewResult Foo(SelectionType selectionType)<br />&nbsp;&nbsp; &nbsp; {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IExampleService service = locator.GetInstance&lt;IExampleService&gt;(new ContextArgument(selectionType));<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //invoke methods on service<br />&nbsp;&nbsp; &nbsp; }&nbsp;<br />}&nbsp;</p>
<p>&nbsp;</p>
<p>Like I said, ugly stuff. In this example, we get a reference to the service locator, pass in some context to help the container identify which rule applies so it knows which type to create. I don&#8217;t want to carry around that reference to IServiceLocator, and I don&#8217;t want my controllers having to understand how to help the container to select the rule that applies based on user input.</p>
<p>Like I said, I want a <strong>smart</strong>&nbsp;container. Turns out the solution was pretty easy to implement, and didn&#8217;t even require me to change how Siege works!</p>
<h2><strong>Introducing Awareness.Of&lt;T&gt;</strong></h2>
<p>Siege simplifies thing for consumers by exposing only one method to do registrations &#8212; I call it Register (novel, I know). Register takes in instances of IRegistration, or Action&lt;IServiceLocator&gt;. There are several different syntaxes available to help you do registrations &#8230; Given&lt;T&gt;, which helps you register individual types &#8230; Using.Convention&lt;TConvention&gt; which allows you bundle registrations together for reuse, and now &#8230; Awareness.Of&lt;T&gt;, which tells the container how to figure out the things it needs to evaluate its rules on its own. </p>
<p>This abstraction allows consumers to extend the Service Locator easily &#8212; by providing your own implementation of IRegistration, the container understands how to handle your new and unique registration type. To prove this premise, I add all new functionality to Siege.Requisitions.Extensions without extending the core framework. It is completely pluggable. But, that&#8217;s a tangent, and I&#8217;ll cover it more in some other post.</p>
<p>With <strong>Awareness</strong>, we have a smart container, which can identify the rules associated with a requested type and use its own awareness to determine validity of those rules.</p>
<h2>How does it work?</h2>
<p>Awareness.Of&lt;T&gt; works like this: When you resolve a type, the container looks up all rules associated with that type. In our example, it receives rules based on<strong>&nbsp;SelectionType</strong>. If the container is &#8220;Aware&#8221; of SelectionType, it will automatically use that awareness to find the current SelectionType value and then give it to the rule engine to evaluate. It continues this process until either a rule is satisfied or no rules match.</p>
<p>Awareness.Of&lt;T&gt; takes a delegate as an argument. This delegate is a Func&lt;T&gt; which tells the container how to get an instance of T to use in rule evaluation. For our MVC applications, we have used Awareness.Of&lt;T&gt; to make our container aware of the Model Binding mechanism in ASP.NET MVC, which it uses to pull data into an object like model binding for controller actions done (form data, query string data, etc), to make our container aware of any configuration files, to make it aware of the session, to make it aware of a wide variety of things. The container becomes more intelligent the more aware it becomes; Your other processes cease to depend on the container at all and cease to have to explicitly direct the container to make decisions.</p>
<p>It all happens naturally, and intuitively.</p>
<h2>Making your container contextually aware</h2>
<p>To make your container aware is very easy. To follow with our example, I will show you how we&#8217;ve made our container aware of the model binding system in ASP.NET MVC. This registration is from code in the Siege.Requisitions.Web.dll file. It&#8217;s very simple, just provide a registration like this:</p>
<p>&nbsp;</p>
<p>serviceLocator.Register(Awareness.Of(ModelBinding.For&lt;SelectionType&gt;().UsingDefaultBinder());</p>
<p>&nbsp;</p>
<p>This registration instructs the service locator to use the default model binder to pull create a SelectionType object. There are also methods on ModelBinding.For&lt;T&gt; which allow you to specify a custom binder (if, for example, you need to look an object up by ID before evaluating it with a rule).&nbsp;</p>
<h2>Our example, revisited with Awareness.</h2>
<p>So here&#8217;s what the whole thing looks like with awareness. I will also use controller action injection, as I covered in my last post.</p>
<p>&nbsp;</p>
<p>//from global.asax.cs, or wherever you initialize the container</p>
<p>
serviceLocator.Register&lt;Singleton&gt;(Given&lt;IExampleService&gt;.When&lt;SelectionType&gt;(selection =&gt; selection == SelectionType.OptionA).Then&lt;OptionAService&gt;();<br />serviceLocator.Register&lt;Singleton&gt;(Given&lt;IExampleService&gt;.When&lt;SelectionType&gt;(selection =&gt; selection == SelectionType.OptionB).Then&lt;OptionBService&gt;();<br />
serviceLocator.Register(Awareness.Of(ModelBinding.For&lt;SelectionType&gt;().UsingDefaultBinder());&nbsp;</p>
<p>&nbsp;</p>
<p>public class SampleController : Controller<br />{<br />&nbsp;&nbsp; &nbsp; public SampleController()<br />&nbsp;&nbsp; &nbsp; {<br />&nbsp;&nbsp; &nbsp; }</p>
<p>&nbsp;&nbsp; &nbsp; public ViewResult Foo(IExampleService service)<br />&nbsp;&nbsp; &nbsp; {<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //invoke methods on service<br />&nbsp;&nbsp; &nbsp; }&nbsp;<br />}</p>
<p>&nbsp;</p>
<p>Looks much cleaner, don&#8217;t you think? All properly decoupled and automatically done for you. The best part is &#8212; it works with whatever container you&#8217;re already using. One of the other priorities I had when I started Siege was to be a value-added proposition for existing containers. If you use Windsor, StructureMap, Unity, whatever&#8230; Siege integrates seamlessly with them and makes them <strong>smarter</strong>. It adds additional abilities to what those containers can already do.</p>
<p>&nbsp;</p>
<p>Happy Coding!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/09/17/contextual-awareness-making-your-container-behave-intelligently/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Dependency Injection into Controller Actions in ASP.NET MVC</title>
		<link>http://lostechies.com/marcusbratton/2010/09/17/dependency-injection-into-controller-actions-in-asp-net-mvc/</link>
		<comments>http://lostechies.com/marcusbratton/2010/09/17/dependency-injection-into-controller-actions-in-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 05:11:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/09/17/dependency-injection-into-controller-actions-in-asp-net-mvc.aspx</guid>
		<description><![CDATA[&#160; Dependency Injection into Controller Actions in ASP.NET MVC Where I work, we use Siege for all of our new (and most of our existing) web applications, taking advantage of it&#8217;s contextual resolution capabilities to focus on programming our applications&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2010/09/17/dependency-injection-into-controller-actions-in-asp-net-mvc/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<div>
<h2>Dependency Injection into Controller Actions in ASP.NET MVC</h2>
<p>Where I work, we use Siege for all of our new (and most of our existing) web applications, taking advantage of it&#8217;s contextual resolution capabilities to focus on programming our applications and less on making them compatible with our container by generating types and interfaces specifically for distinction by the container. One of the things that we came to realize was that for several of our controllers, the constructor dependencies were growing a little out of hand.</p>
<p>The problem is that for some of our dependencies, they are really only used in one controller action. It turned out that while there were a few core dependencies shared throughout our controller, there were also a lot of one-off dependencies that were being injected to the constructor for specific actions.&nbsp;</p>
<p>&nbsp;</p>
<h2>Injecting Directly into the Action</h2>
<p>In some cases, the answer was to decompose the controller so as to&nbsp;separate&nbsp;out the dependencies a little better. However, in many instances, it made sense to leave the controller together, but to move the dependency from the constructor to the action method. We accomplished this through a minor extension to Siege&#8217;s asp.net mvc integration library, which was very simple to do. If you&#8217;re using Siege and the ASP.NET MVC integration library, it&#8217;s very simple &#8212; just update to the latest version and start adding injectable dependencies to your controller actions like so:</p>
<p>&nbsp;</p>
<p>public ActionResult Foo(IBarService service)<br />{<br />&nbsp;&nbsp; //put your code here&nbsp;<br />}</p>
<p>&nbsp;</p>
<p>If you&#8217;re not currently using Siege, but want to start &#8212; just go to the&nbsp;<a href="http://www.dotsiege.net/intel/Downloads.ashx">Download Page</a>&nbsp;and get Siege.Requisitions.Web and one of the adapters (if you aren&#8217;t using an IoC but want to start, I suggest the SiegeAdapter!)</p>
<p>Then, in your global.asax.cs file, simply inherit your GlobalApplication from ServiceLocatorHttpApplication et voila! You should be good to go.</p>
<p>&nbsp;</p>
<h2>But wait, there&#8217;s more!</h2>
<p>Straight dependency injection into controller actions is nice, but Siege.Requisitions actually enables you to conditionally inject implementations based on behavior from the user. In one of our scenarios where I work, we integrate with multiple vendors and in some of our administrative applications, users choose vendors to send information to by selecting specific options from a drop down. Not only are we able to inject the dependency directly into the controller action, but we are additionally able to have our container automatically pick an implementation by understanding which selection the user has chosen on the form.</p>
<p>This all happens automatically, without any need for the developer to write controller code to resolve anything, or any code really, other than expressing this through additional registrations. How does that work, and what does it look like? I&#8217;ll cover that in the next post, which is all about Contextual Awareness: How the Container infers your intent by observing the system.</p>
<p><a href="http://www.dotsiege.net/intel/Downloads.ashx">Siege Download Page</a><br /><a href="http://github.com/MarcusTheBold/Siege">Siege on GitHub</a><br /><a href="http://twitter.com/MarcusTheBold">Follow me on Twitter for Siege updates</a>&nbsp;</p>
<p>&nbsp;</p>
<p>Happy Coding!</p>
</div>
<p>&nbsp;</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/09/17/dependency-injection-into-controller-actions-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting Started with MonoTouch</title>
		<link>http://lostechies.com/marcusbratton/2010/08/13/getting-started-with-monotouch/</link>
		<comments>http://lostechies.com/marcusbratton/2010/08/13/getting-started-with-monotouch/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 06:08:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[MonoTouch]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/08/13/getting-started-with-monotouch.aspx</guid>
		<description><![CDATA[Recently, I bought an iPad and decided to try my hand at objective-C. It was a pretty fun experience but as I began to think of apps that I&#8217;d actually want to write, I knew of a lot of open-source&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2010/08/13/getting-started-with-monotouch/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<p>Recently, I bought an iPad and decided to try my hand at objective-C. It was a pretty fun experience but as I began to think of apps that I&#8217;d actually want to write, I knew of a lot of open-source tools (either written by me or others) that I&#8217;d want to use. I definitely didn&#8217;t want to try re-writing them in objective-c. I had remembered a coworker of mine mentioning MonoTouch to me in the past as a C# compiler for the iPhone so I decided to check it out. Sure enough, they target both the iPhone and iPad. So I decided to download it and give it a try.</p>
<p><strong>This guide is intended to help you get started with a project you can deploy to your device. If you want to simply develop with the simulator, not all of these steps will apply to you. You can simply scroll down to &#8216;Your first Monotouch application&#8217; and read from there.</strong></p>
<h2>Before We Get Started</h2>
<p>There has been a fair amount of concern and discussion regarding the apple developer agreement for iPhone OS 4.0. This had put me off for a while as I didn&#8217;t want to spend a lot of time working on an app that ultimately wouldn&#8217;t be approved. Having monitored the community for a few months, it appears that people are still getting their apps approved with regular frequency. This isn&#8217;t to say that Apple won&#8217;t one day decide to start rejecting apps &#8212; but it is a promising sign nonetheless. The people at MonoTouch certainly don&#8217;t think this is the end for their platform, but it&#8217;s up to you to decide if you want to take the risk. I plan to, not only because I like writing code in C#, but because I want to be able to take advantage of several .NET features supported by MonoTouch &#8212; WCF and Reflection, for example, and because I want to be able to use certain technologies like an IoC container.</p>
<h2>Getting Started (what will I need?)</h2>
<ul>
<li>A mac</li>
<li>XCode</li>
<li>MonoDevelop (http://monodevelop.com/Download)</li>
<li>MonoTouch (http://monotouch.net/DownloadTrial)</li>
<li>An Apple Developer Key (http://developer.apple.com/iphone/index.action)</li>
</ul>
<p>Once you&#8217;ve downloaded MonoDevelop and MonoTouch and installed them, it&#8217;s time to get your Apple Developer key. Follow the above link and begin enrollment &#8212; you&#8217;ll need to select &#8220;iPhone Developer Program&#8221; as your development program. You&#8217;ll also need to enter the pertinent required information (billing/contact information). Agree to their developer terms (&#8220;I agree to sell my soul to Apple&#8230;&#8221;) and head to their checkout process. The privilege of being an apple developer runs about $99 (plus tax), so be prepared to fork over some money if you want to do anything more than develop on a iPhone or iPad simulator, and if you ever want to put your app on the market. Once you&#8217;ve placed your order, wait for your e-mail to arrive. For me, this took a couple of hours. They say it can take up to 24, so try to be patient.</p>
<p>But to be honest, the process wasn&#8217;t painless for me. I got my activation code, tried to verify and got this dreadful message:</p>
<h4>&#8220;We are unable to activate your Apple Developer Program membership.&#8221;</h4>
<p>Unfortunately that set this post back a few days while I waited through the weekend to be able to call up their support number and get things settled. Luckily they said they could resolve it on their side and everything got worked out for me. So, now that I have my key, things can move forward!</p>
<h2>Provisioning your apps</h2>
<p>Before you can deploy with MonoTouch to your iPhone or iPad, you have to provision your environment for deployment. Apple&#8217;s process requires a lot of manual work, which I will walk you through below. They also include videos on their site to walk you through it. This will install the necessary keys on your machine that will be used to sign and deploy your code. To begin this process, you will need to go to the iphone developer center (developer.apple.com) and request a certificate. To do this, you first need to make a certificate request from the keychain on your mac.</p>
<h3>How to create a certificate request</h3>
<p>Go to Finder, then Applications, then Keychain Access. Once this comes up, we&#8217;ll need to check the preferences. In the menu, go to Keychain Access, and then Preferences. Click the Certificates tab and ensure that both Online Certificate Status Protocol and Certificate Revocation List are set to &#8216;off&#8217;. Once this is done, close the preferences window. Now, in the menu, go to Keychain Access, and then Certificate Assistant, and then Request a Certificate from a Certificate Authority. We will use this application to generate a certificate request to submit to Apple.</p>
<p>Put in the e-mail address that you used to sign up for the developer program, and put in your name. Select &#8220;save to disk&#8221; and &#8220;Let me specify key pair information&#8221;. Click continue and select a location to save the request to. In the next menu, ensure the key size is 2048 bits using the RSA algorithm. Click continue to finish the process.</p>
<h3>Requesting a certificate from Apple</h3>
<p>Go to the developer portal and select the &#8216;Certificates&#8217; menu option on the left. You should see an empty list in the &#8216;Development Tab&#8217; and a &#8216;Request Certificate&#8217; button. Click the button, and upload the certificate request you generated before. You will be e-mailed a notification from Apple once you have done this. After a short amount of time, your request should be approved. Once it has been approved you should be able to download the certificate from apple. Once you have done this, open the certificate to have it automatically added to your keychain in the Keychain Access program.</p>
<p><strong>Adding your device for deployment and debugging</strong></p>
<p>After you have gotten your certificate approved and added to your keychain, we will need to set up your device for deployment. Attach your iPod, iPad or iPhone to your mac and open iTunes. In the &#8216;Devices&#8217; section, select your device to view the summary for it. Click the &#8216;Serial Number&#8217; label to reveal your identifier, which we will need to enter into the apple portal. Once you have revealed it, select the &#8216;copy&#8217; option in the edit menu.&nbsp;Go to the developer portal and select the &#8216;Devices&#8217; link in the left menu. Once the &#8216;Devices&#8217; page has loaded, click the &#8216;Add Device&#8217; button in the upper left. Enter a name for your device, and then paste the identifier we copied from iTunes. Click submit to add the device.&nbsp;</p>
<p>After you have added your device, you will need to generate an app ID for your application. App IDs are used for a few different purposes (communicating with hardware, supporting in-app purchases, etc), and is a required part of your application setup. Click on the &#8216;App IDs&#8217; link on the left menu, and then click the &#8216;New App ID&#8217; button. &nbsp;You will need to add a decription and then put in your app id suffix. Apple recommend you do a reverse domain setup. Fill in the required fields and click &#8216;submit&#8217;.</p>
<p>Once you have completed these steps, you&#8217;ll be ready to create a provisioning profile. Click the &#8216;provisioning&#8217; menu option on the left menu and then &#8216;New Profile&#8217; when the page loads. Enter a profile name and then select your certificate, appID and device and click submit. You will be taken back to the provisioning page where you can then download your profile. If the status says &#8216;in progress&#8217;, give it a minute and refresh the page. Download the profile to your mac.</p>
<p>&nbsp;</p>
<h2>Setting up MonoTouch and your Application for Deployment</h2>
<p>Now that you have all the requisite parts, you are ready to set up MonoTouch to deploy to your device. First, you will need to install the provisioning profile you just created. Double-click the profile to open it in XCode. It should automatically be installed from there, and you can close XCode once that is complete.&nbsp;</p>
<h3>Your first MonoTouch application</h3>
<p>Until this point we&#8217;ve focused on the logistics of getting everything set up. While this was not strictly necessary if you only wanted to do development with the simulator, it is necessary if you want to deploy your application to your device. Open MonoDevelop and start a new project. Expand the C# section, and select the iPhone and iPad node. Select either the iPhone or iPad window based project (I am using the iPad project). Name your application &#8212; I am naming mine Test Application &#8212; and click the &#8216;Ok&#8217; button.</p>
<p>Once your project is set up, you can double-click the MainWindow.xib file to bring up the interface builder. I&#8217;m not going to go into too much detail here, but basically you will want to put something on the view to show that your application is starting and displaying correctly. I put a label on the page with &#8220;Hello World!&#8221; as the text. To run this in the simulator, go to the &#8216;Run&#8217; menu item and select &#8216;Run&#8217;. It will compile and run the application in the simulator. Cool, huh?</p>
<h3>Deploying your app to your device</h3>
<p>This is all good and fine, but lets get it deployed on your device! Luckily, MonoTouch should automatically pick up the required information now that it is installed on your mac. But if it doesn&#8217;t, follow these steps:</p>
<p>Go to the &#8216;Project&#8217; menu item, and select your projects options. For me, this is called Test Application Options. If you named your solution differently, it will be different. The options window will open, and under the &#8216;Build&#8217; section, click the &#8216;iPhone Bundle Signing&#8217; item. Select the identity you set up with apple from the &#8216;Identity&#8217; drop down and then select the provisioning profile you set up with apple from the &#8216;Provisioning profile&#8217; drop down and click the &#8216;OK&#8217; button.</p>
<p>Finally, you will need to set the build configuration to debug|iPhone. This will direct MonoTouch to build and deploy your application. Go to the &#8216;Run&#8217; menu option and select &#8216;Run&#8217;.&nbsp;You may get a message that says &#8216;codesign wants to sign using key (key name) in your keychain&#8217; &#8230; select &#8216;Always Allow&#8217;. Once it completes, you will get a window that says the app has been built and deployed to your device. Close this window, and start your device. Scroll to the app and touch it. It should start, and once started, you should see a &#8216;Hello World!&#8217; message.</p>
<p>Getting started with MonoTouch is very easy and I am very pleased with how well they integrate MonoDevelop with the interface builder, the device simulator, and the device deployment process. Setting up with Apple is a very tedious process, but I am glad to see they did not carry this over into MonoDevelop or MonoTouch.&nbsp;</p>
<p>&nbsp;</p>
<p>If you have any questions or problems, please leave a comment and I will do my best to help out.</p>
<p>Happy coding!</p>
</div>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/08/13/getting-started-with-monotouch/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Boiling the Ocean [Siege Update]</title>
		<link>http://lostechies.com/marcusbratton/2010/08/09/boiling-the-ocean-siege-update/</link>
		<comments>http://lostechies.com/marcusbratton/2010/08/09/boiling-the-ocean-siege-update/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 03:45:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/08/08/boiling-the-ocean-siege-update.aspx</guid>
		<description><![CDATA[It&#8217;s been several months since I&#8217;ve posted an update on Siege.ServiceLocation. I&#8217;ve not been dormant over these last few months, but rather very active. I have a few updates I want to share with you guys. These have been a&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2010/08/09/boiling-the-ocean-siege-update/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been several months since I&#8217;ve posted an update on Siege.ServiceLocation. I&#8217;ve not been dormant over these last few months, but rather very active. I have a few updates I want to share with you guys. These have been a long time brewing. First and foremost&#8230;</p>
<h2>Siege.ServiceLocation is now Siege.Requisitions!</h2>
<p>Going with a more &#8220;Siege-like&#8221; theme in naming, I&#8217;ve decided to rename this project and others (we&#8217;ll get into that in a moment). This update is much, much more than a name change, however. The entire service location api has been streamlined and simplified. Siege is more than just a simple abstraction over IoC syntax, though it retains that quality. As a furtherance of previous posts, it has become a complete Type-Selection Framework, bundling all the requisite rules and algorithms for managing type mapping and selecting the corresponding type for a request. This is the cornerstone of the framework and will remain its focus.</p>
<p>However, there is more news.</p>
<h2>What is this again?</h2>
<p>I don&#8217;t blame you if you don&#8217;t recall &#8212; it has been a long time since my last post after all. So in short, Siege.Requisitions is a framework whose goal is to provide a simple and intuitive interface for using IoC frameworks. Its intent is to abstract away the majority of commonly used syntax to a single and consistent API. Its intent is to allow users to specify multiple implementations of a single interface and depend on the container to intelligently and intuitively select between them at runtime. Its intent is to leverage the existing functionality exposed by IoC frameworks will extending all of them with additional functionality. Its intent is not to prevent users from leveraging the abilities of whatever IoC they want to use.</p>
<p>In short, Siege.Requisitions is a Type-Selection framework that uses a very simple and streamlined API to abstract away other IoC frameworks to a single line of code, allowing users to swap between them seamlessly, or to migrate from one to another easily, all while leveraging the strength of each framework while enriching it with additional functionality, without preventing users from harnessing the power of whatever IoC they choose to use.</p>
<h2>Siege.Requisitions IS an Inversion of Control framework</h2>
<p>Or at least, it can be. True to our design philosophy, we have focused each component to its specific problem domain. I truly believe that existing IoC frameworks overstep their boundaries by tightly-coupling their registration, selection and resolution responsibilities. Siege.Requisitions splits these responsibilities up between its components and allows consumers to provide their own implementations and rules for each area of responsibility. By doing this, Siege.Requisitions can function completely as a simple type-selection framework that extends other IoC frameworks, or it can act as a standalone IoC framework. Siege.Requisitions provides its own type-resolver, optimized for use with our framework and extremely performant versus other resolution containers.&nbsp;</p>
<p>Our focus has always been and continues to be simplicity, understandability, usability and consumability for our users.</p>
<h2>Siege has its own website</h2>
<p>The address is <a href="http://www.dotsiege.net/">http://www.dotsiege.net/</a>&nbsp;and the repository is at&nbsp;<a href="http://github.com/MarcusTheBold/Siege">http://github.com/MarcusTheBold/Siege</a></p>
<p>I will continue to make periodic updates about Siege at Los Techies but will be more active on the Siege website, which will be extended beyond what it is now (just a wiki). I don&#8217;t want my sole focus here to be this project. I have a lot of other things I&#8217;m working on and want to share, first and foremost, the work I do using MonoTouch. Which brings me to &#8230;</p>
<h2>Siege.Requisitions is fully functional on the MonoTouch framework</h2>
<p>I have enjoyed working with MonoTouch so much that I wanted to build support for it. When using Siege as an IoC, with its own Type Resolver, special support has been added to work specifically with MonoTouch. New development on Siege is&nbsp;targeting&nbsp;the .NET 4.0 framework but I will continue to support the .NET 3.5 framework with bug fixes and specific functionality for MonoTouch. I am serious about providing framework support for this awesome tool and cannot speak highly enough about it. I consider it just as important to support as the .NET framework itself.</p>
<h2>Other Siege Projects!</h2>
<p>I&#8217;m pleased to share a few other project-related updates. On the Siege Website you will notice two new projects.</p>
<ul>
<li>Siege.Foundry &#8211; This is an abstraction over IL that allows consumers to define algorithms by which types can be dynamically created. You can define the type you want, name it, add constructors and define their behaviors and add methods and define their behaviors. Support is there for&nbsp;inheritance&nbsp;and overriding of methods. This is currently in alpha but I am switching focus to flesh this out much more. Siege (and some of my other unreleased projects) use this framework for several different purposes.</li>
<li>Siege.Arsenal &#8211; This is a framework that proxies objects, currently based on decoration by attributes. This is also in alpha and will also be extended much more (as it uses Siege.Foundry for its proxying duties)</li>
</ul>
<h2>Looking Ahead</h2>
<p>Siege.Requisitions will continue to receive periodic updates from me. I&#8217;d love to hear feedback from you guys, so feel free to contact me via e-mail or twitter if you have any feedback. There is a roadmap for this project, which is on the website, and I will continue to post there and here about updates and progress as it is made.&nbsp;There have been a host of additional features and improvements too numerous to mention here. So go to the website and check it out. .NET 4.0 assemblies are hosted on the download page (.NET 3.5 downloads will be added soon!)&nbsp;</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/08/09/boiling-the-ocean-siege-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hallmarks of Good Framework Design</title>
		<link>http://lostechies.com/marcusbratton/2010/01/19/hallmarks-of-good-framework-design/</link>
		<comments>http://lostechies.com/marcusbratton/2010/01/19/hallmarks-of-good-framework-design/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 22:55:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/01/19/hallmarks-of-good-framework-design.aspx</guid>
		<description><![CDATA[lol Post Footer automatically generated by Add Post Footer Plugin for wordpress.]]></description>
			<content:encoded><![CDATA[<p>lol</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/01/19/hallmarks-of-good-framework-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A philosophical discussion about Inversion of Control frameworks</title>
		<link>http://lostechies.com/marcusbratton/2010/01/10/a-philosophical-discussion-about-inversion-of-control-frameworks/</link>
		<comments>http://lostechies.com/marcusbratton/2010/01/10/a-philosophical-discussion-about-inversion-of-control-frameworks/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 21:19:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2010/01/10/a-philosophical-discussion-about-inversion-of-control-frameworks.aspx</guid>
		<description><![CDATA[I had a short conversation with Chad Myers today over twitter (a very challenging medium to have a conversation of any substance over, and frustrating). Basically, it was about my effort with Siege.ServiceLocation. I thought I would clear up some&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2010/01/10/a-philosophical-discussion-about-inversion-of-control-frameworks/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had a short conversation with Chad Myers today over twitter (a<br />
very challenging medium to have a conversation of any substance over,<br />
and frustrating). Basically, it was about my effort with Siege.ServiceLocation. I thought I would clear up some misconceptions.</p>
<p>&nbsp;</p>
<p><b>Siege.ServiceLocation isn&#8217;t an abstraction, it&#8217;s a decoupling.<br /></b></p>
<p>Siege.ServiceLocation isn&#8217;t just about contextual<br />
registration/resolution (though that was the initial impetus). It&#8217;s not<br />
about resolution at all. It&#8217;s about expressing registration. It&#8217;s about<br />
adding functionality to ALL containers. There are a few things that I<br />
am trying to accomplish with this library. First, I want to decouple<br />
registration from resolution. That&#8217;s not to say I want to abstract how<br />
each container&#8217;s registration is performed; <b>I want them decoupled completely. </b>Second, I want my library to be functionally compatible with existing frameworks (see <a href="/blogs/marcus_bratton/archive/2009/12/06/introducing-siege.aspx">Siege Design Philosophy</a><br />
for more details). This means whatever Siege.ServiceLocation can do,<br />
all the frameworks it integrates with can do. Third, I want it to be<br />
easy. Outside of Ninject (which I think is a wonderfully built IoC), I<br />
think the others fail the third criteria. I&#8217;ve worked with them all. I<br />
know the differences. They each have distinct problems. And I don&#8217;t<br />
think it has to be that way.</p>
<p>&nbsp;</p>
<p><b>Inversion of Control containers should be about resolving types</b></p>
<p>Not about registering types. Registration is a way of instructing an<br />
IoC how to resolve a type. It&#8217;s not what the IoC is built for, it&#8217;s a<br />
way of expressing what the IoC needs to do. Each IoC has a different<br />
way of accomplishing the same thing. I&#8217;ve been told that choosing an<br />
IoC is about evaluating the strengths and weaknesses of each framework<br />
and picking the one that suits your needs.</p>
<p>What? If an IoC is there to resolve types and their dependencies, to<br />
provide a mechanism to help you decouple your code, then how can there<br />
be strengths and weaknesses in each framework? Is it in terms of how<br />
efficiently they perform the task? Is it in terms of they internally<br />
manage resolution?</p>
<p>Or is it in terms of what their registration syntax allows you to<br />
do? Is it in terms of how you express your goal? Is it in terms of the<br />
instructions the container understands when it tries to resolve a type?</p>
<p>These are all rhetorical questions. The point is to look at the<br />
problem differently than has been traditionally done. To my mind, there<br />
is a clear seperation of concerns between the responsibility of<br />
registering types and the responsibility of resolving types. I think an<br />
IoC should specialize in resolving types and their dependencies, not<br />
specialize in expressing how to resolve types and their dependencies.</p>
<p>&nbsp;</p>
<p><b>Siege.ServiceLocation is not an IoC</b></p>
<p>It&#8217;s a coordination mechanism for an IoC container. Think &#8220;one level<br />
above&#8221; the container. Rather than instructing an IoC container how to<br />
resolve your type, you instruct Siege.ServiceLocation. It then in turn<br />
knows how to interact with the underlying framework to get what you<br />
want. It tracks the conditions and criteria. It makes all the requests<br />
necessary through the underlying framework to get your objects<br />
constructed. Think of it as a proxy with an adapter. The goal is to<br />
track runtime conditions to facilitate the selection of an appropriate<br />
interface. To enable this functionality WITHOUT having to force you to<br />
use a specific framework. Where the IoC container specializes in<br />
resolution, Siege.ServiceLocation specializes in registration and<br />
communicating requests to the IoC container.</p>
<p>The reason that each IoC framework has strengths and weaknesses is<br />
because each IoC has it&#8217;s own way of trying to go about describing how<br />
they want things resolved. That means that some of them can interpret<br />
certain resolution instructions. Others interpret their own resolution<br />
instructions. That&#8217;s not the point of an IoC, and it&#8217;s no wonder they<br />
all do it differently and each has their own strengths and weaknesses. </p>
<p>If we move the registration expression above the container that<br />
performs resolution, we can decouple these two concepts. Then, as long<br />
as the component that understands registration can express instructions<br />
to the component that performs resolution, all containers can suddenly<br />
benefit from these collective strengths. We remove the need for<br />
containers to worry about these concerns. We remove the need for<br />
developers to do an analysis of what &#8220;features&#8221; a container supports.<br />
We remove the need for people to make trade-offs on what strengths they<br />
gain, what weaknesses they are burdened with and what features they<br />
lose out on when choosing an IoC framework.</p>
<p><b><br /></b></p>
<p><b>The Least Common Denominator</b></p>
<p>In my brief conversation with Chad, he pointed out that most<br />
abstraction attempts only manage to accomplish the Least Common<br />
Denominator of all frameworks and wind up gutting the potential of each<br />
of the frameworks they integrate with. I understand his point, but I<br />
think this is fundamentally different. The desire is NOT to limit you<br />
to what all frameworks have in common, but to allow people to use<br />
functionality that may NOT exist in all frameworks. A primary example<br />
of this is contextual resolution. Several IoCs can do this to some<br />
extent or another, based on very narrow criteria. Some of them can&#8217;t do<br />
it at all. None of them can respond to evolving runtime conditions when<br />
selecting an implementation of a requested type.</p>
<p>When combining these containers with Siege, suddenly all of them<br />
gain this ability. This is because Siege understands both how to<br />
accomplish what you are requesting (it&#8217;s specialty is in extensible<br />
registration) and how to communicate with a container to achieve it&#8217;s<br />
goal (for example, when condition a is met, request type a. when<br />
condition b is met, request type b). On top of that, it instructs the<br />
container on how to call back to Siege for <b>each dependency</b> that a container has to resolve for additional instructions on how to perform resolution.</p>
<p>This means that by using Siege you can gain functionality that your<br />
selected container doesn&#8217;t natively support. And as Siege&#8217;s use cases<br />
grow, ALL containers functionality will grow. A rising tide lifts all<br />
boats. If the strengths of each container were built as registration<br />
expressions into Siege, <b>all containers</b> would gain this<br />
strength. You would would sacrifice nothing, make no trade-offs and not<br />
be required to learn multiple distinct ways to express how you want a<br />
type resolved.</p>
<p>&nbsp;</p>
<p><b>Limiting your choices</b></p>
<p>One of the design philosophies behind this project is NOT to limit<br />
your choices. It&#8217;s to expand them. If Siege doesn&#8217;t support something<br />
that a specific container does, use that container with Siege. Do their<br />
specialized registration to configure the container and then give it to<br />
Siege to do whatever additional registration expressions you need to.<br />
With this approach, we avoid any LCD philosophy, we avoid limiting the<br />
your choices as a developer. Alternatively, you can easily extend the<br />
framework to accomplish what you want so you don&#8217;t have to change<br />
containers or feel constrained to a specific one. On top of that, we<br />
deliver functionality that you would not have otherwise. And hopefully,<br />
as the framework grows and evolves, you won&#8217;t have to learn 5 different<br />
ways of registering and resolving types. You&#8217;ll only have to learn one,<br />
and no matter which underlying framework you use, all of them will<br />
support your system fully. But, that&#8217;s down the road from where we are<br />
today, which is why I made it an important design decision to be sure<br />
we didn&#8217;t rob any underlying IoC of it&#8217;s functionality.</p>
<p>&nbsp;</p>
<p><b>Evolution</b></p>
<p>I&#8217;ll be the first to admit, this wasn&#8217;t the direction that I was<br />
going when I first started working on this. I wanted to do an 80/20.<br />
But my point of view has evolved over the last month and my efforts<br />
have gone towards supporting the idea that functionality can and will<br />
be introduced to all containers through Siege. Some of the things I&#8217;ve<br />
had to say in this post contradict what I&#8217;ve said in previous posts<br />
(perhaps I should update them?) But that comes with an evolving point<br />
of view. It&#8217;s organic. Things will grow and change. And I want to thank<br />
Chad for challenging me and making me think more in depth about how to<br />
articulate where I&#8217;m going and what I&#8217;m doing so I could put up a post<br />
like this.</p>
<p>Let each framework specialize and do what it does best. I don&#8217;t<br />
expect the existing framework teams to embrace this idea. There will<br />
always be new features introduced to them. There will always be<br />
features in Siege that none of the others will have. That&#8217;s the nature<br />
of the beast.</p>
<p>But my goal is to give you more options and to not take any away. I<br />
hope that clears up any confusion around what the intent is here.</p>
<p>&nbsp;</p>
<p>Happy coding!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2010/01/10/a-philosophical-discussion-about-inversion-of-control-frameworks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Introducing Siege.ServiceLocation.Extensions: FactoryMethod Support, Dependency Resolution based on type injected into added</title>
		<link>http://lostechies.com/marcusbratton/2009/12/27/introducing-siege-servicelocation-extensions-factorymethod-support-dependency-resolution-based-on-type-injected-into-added/</link>
		<comments>http://lostechies.com/marcusbratton/2009/12/27/introducing-siege-servicelocation-extensions-factorymethod-support-dependency-resolution-based-on-type-injected-into-added/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 17:43:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/27/introducing-siege-servicelocation-extensions-factorymethod-support-dependency-resolution-based-on-type-injected-into-added.aspx</guid>
		<description><![CDATA[Introduction For anyone wanting to follow The Siege Project, I routinely post updates on twitter (MarcusTheBold). Feel free to follow. I did some refactoring and clean up. I&#8217;ll address the specifics in a moment. First, I&#8217;ll list the files for&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2009/12/27/introducing-siege-servicelocation-extensions-factorymethod-support-dependency-resolution-based-on-type-injected-into-added/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>For anyone wanting to follow The Siege Project, I routinely post updates on twitter (MarcusTheBold). Feel free to follow.</p>
<p>I did some refactoring and clean up. I&#8217;ll address the specifics in a moment. First, I&#8217;ll list the files for download for anyone interested:</p>
<p><b>Siege.ServiceLocation library</b>:</p>
<p><a title="Siege.ServiceLocation.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.zip">Siege.ServiceLocation.zip</a><br /><a title="Siege.ServiceLocation.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.Extensions.zip">Siege.ServiceLocation.Extensions.zip<br /></a></p>
<p>&nbsp;</p>
<p><b>ASP.NET MVC Integration</b>:</p>
<p><a title="Siege.ServiceLocation.HttpIntegration.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.HttpIntegration.zip">Siege.ServiceLocation.HttpIntegration.zip</a></p>
<p>&nbsp;</p>
<p><b>IoC Framework Adapters</b>:</p>
<p><a title="Siege.ServiceLocation.AutofacAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.AutofacAdapter.zip">Siege.ServiceLocation.AutofacAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.NinjectAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.NinjectAdapter.zip">Siege.ServiceLocation.NinjectAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.StructureMapAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.StructureMapAdapter.zip">Siege.ServiceLocation.StructureMapAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.UnityAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.UnityAdapter.zip">Siege.ServiceLocation.UnityAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.WindsorAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.WindsorAdapter.zip">Siege.ServiceLocation.WindsorAdapter.zip</a></p>
<p>&nbsp;</p>
<p><b>Quick Start</b>:</p>
<p><a title="SiegeMVCQuickStart.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/SiegeMVCQuickStart.zip">SiegeMVCQuickStart.zip</a></p>
<p>&nbsp;</p>
<p>A few people have asked me about contributing and extending the Siege.ServiceLocation library. My preference is to keep the Siege.ServiceLocation namespace itself as the main engine for enabling a wide variety of syntaxes and not grow the default syntax beyond what comes pre-packaged (the given-when-then syntax). However, I do want the project to grow and expand to meet the needs of anyone that uses it. Therefore, I&#8217;ve added a new project to the Siege.ServiceLocation umbrella: Siege.ServiceLocation.Extensions</p>
<p>Users can download this as an optional library that works in conjunction with Siege.ServiceLocation. Contributors can contribute to this library to create new syntax and new use cases to enable users to solve problems. The only restrictions I will put on this is that it should only reference Siege.ServiceLocation and not any particular IoC or external framework. If you want to integrate with a specific IoC, or another specific framework, I do encourage you to do so &#8212; only in a seperate project. I want to make sure that people consuming this framework don&#8217;t have to add dependencies to frameworks and systems they do not intend to use.</p>
<p>As these particular cases come up we will address them as necessary.</p>
<p>&nbsp;</p>
<h3>So what changed?</h3>
<p>Not a whole lot. There were some assumptions in the system around conditions and how they were evaluated that I changed to defer through an implementation via interface. What that means is that anyone extending the framework can now determine on their own how a conditions should be determined as valid for a particular use case rather than explicitly comparing against context. Additionally, I extended the framework to track the types it has been resolving. Finally, I simplified some interfaces, particularly around supporting new IoC containers. I expect that I will make a few more modifications before releasing a 1.0 version &#8212; the execution context is a primary candidate, as right now it is fairly immature in it&#8217;s implementation. The other change I anticipate is to enable the IoC to work with other cross-cutting steps during resolution. Specifically, I&#8217;ve been working on incorporating AOP support into Siege.ServiceLocation and it&#8217;s almost complete, but I&#8217;m still pondering how to incorporate it. It may require a slight refactory, it may not. We&#8217;ll see.</p>
<p>Once I have made these two changes I expect I&#8217;ll do a feature freeze for Siege.ServiceLocation and release it as a 1.0 version.</p>
<p>&nbsp;</p>
<h3>New Features in Siege.ServiceLocation.Extensions</h3>
<p>Included already in this project are two new types of usages: Factory Methods and the ability to resolve dependencies based on the resolution hierarchy. That is to say, you can conditionally specify types to be used when the container has already decided to use other types. As always, you can additionally refer to the unit tests for detailed examples.</p>
<p><span style="text-decoration: underline"><br />Factory Methods:</span></p>
<p>You can now specify a factory method to be used when constructing an object, both by default or when a condition is met. This works nearly identically to your standard Given-When-Then functionality, except instead of &#8220;Then&#8221; you use &#8220;ConstructWith&#8221;, making it a Given-ConstructWith or Given-When-ConstructWith syntax.</p>
<p><span style="text-decoration: underline"><br />Type Resolution based on parent types</span></p>
<p>I&#8217;m not really sure what to call this. The syntax is like this &#8211; Given&lt;BaseType&gt;.WhenInjectingInto&lt;ParentType&gt;.Then&lt;ImplementingType&gt;. Basically it works like this: if you have &#8216;BaseType1&#8242; which has a constructor dependency &#8216;IDependency&#8217; and is implemented by &#8216;TypeA&#8217; and &#8216;TypeB&#8217;, you can say &#8220;When you decide to resolve as &#8216;TypeA&#8217;, use the &#8216;DependencyA&#8217; implementation of &#8216;IDependency&#8217;, otherwise use the default (if one is specified).&#8221;</p>
<p>By combining this with normal contextual resolution, you can set up rules for your types to be resolved based on arbitrary context and for their dependencies to be resolved either based on arbitrary context as well, or resolved based on which type is currently being resolved, or a combination thereof. It is important to note that when you specify multiple satisfiable criteria for resolution &#8212; for example arbitrary context that is satisfied AND resolution based on a type being resolved that is ALSO true, the system will choose the first applicable use case (the first one registered). Additionally, factory method support is compatible with the aforementioned case of resolving dependencies based on the parent&#8217;s type. You can tell it to use a factory when the &#8216;WhenInjectionInto&lt;T&gt;&#8217; scenario is satisfied. </p>
<p>&nbsp;</p>
<h3>In Closing</h3>
<p>The goal with this system was to be able to quickly and easily extend it to support new syntaxes and usages. When I added these new syntaxes, each of them took me roughly 30 minutes from beginning to all tests passing at the end. While I am the author of this system, I expect that the barrier for other users would not be too much higher given a very basic understanding of the interfaces involved. For example, the amount of code to support Factory Methods was maybe all told about 100 lines of code between syntax and implementation while the amount of code to support dependency resolution based on the type its injected into was less than 150 lines.</p>
<p>&nbsp;</p>
<p>Until next time, Happy Coding!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2009/12/27/introducing-siege-servicelocation-extensions-factorymethod-support-dependency-resolution-based-on-type-injected-into-added/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Added support for Unity, Autofac to Siege.ServiceLocation</title>
		<link>http://lostechies.com/marcusbratton/2009/12/23/added-support-for-unity-autofac-to-siege-servicelocation/</link>
		<comments>http://lostechies.com/marcusbratton/2009/12/23/added-support-for-unity-autofac-to-siege-servicelocation/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 17:23:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/23/added-support-for-unity-autofac-to-siege-servicelocation.aspx</guid>
		<description><![CDATA[&#8230;plus, some other house-cleaning items. Last night I put together adapters for Autofac and Unity. The process turned out to be rather straightforward; I think all told for both it took me about an hour from adding the projects to&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2009/12/23/added-support-for-unity-autofac-to-siege-servicelocation/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&hellip;plus, some other house-cleaning items.</p>
<p>Last night I put together adapters for Autofac and Unity. The process turned out to be rather straightforward; I think all told for both it took me about an hour from adding the projects to all tests passing. I may have a final tweak for this project around how adapters work &ndash; there is one method that I think doesn&rsquo;t need to be placed where it is, so I&rsquo;ll probably move it. After that, I don&rsquo;t anticipate many (if any) major changes to how it works &hellip; I&rsquo;ll just put out a Siege.ServiceLocation.Extensions project to house more things (an auto-register, factory method support, things like that). It&rsquo;ll be a good chance to prove out how extensible this really is.</p>
<p>Other than that I did some tweaks to namespaces to bring everything into one common scheme for namespacing. Nothing new beyond those items; I updated all the downloadable items with the latest versions. Here are the links:</p>
<p>&nbsp;</p>
<p><b>Siege.ServiceLocation library</b>:</p>
<p><a title="Siege.ServiceLocation.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.zip">Siege.ServiceLocation.zip</a>     </p>
<p>&nbsp;</p>
<p><b>ASP.NET MVC Integration</b>:</p>
<p><a title="Siege.ServiceLocation.HttpIntegration.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.HttpIntegration.zip">Siege.ServiceLocation.HttpIntegration.zip</a></p>
<p>&nbsp;</p>
<p><b>IoC Framework Adapters</b>:</p>
<p><a title="Siege.ServiceLocation.AutofacAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.AutofacAdapter.zip">Siege.ServiceLocation.AutofacAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.NinjectAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.NinjectAdapter.zip">Siege.ServiceLocation.NinjectAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.StructureMapAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.StructureMapAdapter.zip">Siege.ServiceLocation.StructureMapAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.UnityAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.UnityAdapter.zip">Siege.ServiceLocation.UnityAdapter.zip</a>     <br /><a title="Siege.ServiceLocation.WindsorAdapter.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.WindsorAdapter.zip">Siege.ServiceLocation.WindsorAdapter.zip</a></p>
<p>&nbsp;</p>
<p><b>Quick Start</b>:</p>
<p><a title="SiegeMVCQuickStart.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/SiegeMVCQuickStart.zip">SiegeMVCQuickStart.zip</a>     </p>
<p>&nbsp;</p>
<p>For convenience the main library is bundled with the HttpIntegration zip as well as each of the Adapter zip files.</p>
<p>Have a Happy Holidays!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2009/12/23/added-support-for-unity-autofac-to-siege-servicelocation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Siege Project: Siege.ServiceLocation Part 5 – A guide to getting started with Siege.ServiceLocation</title>
		<link>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation/</link>
		<comments>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 06:24:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation.aspx</guid>
		<description><![CDATA[The Siege Project Introduction Siege.ServiceLocation Part 1 &#8211; Introduction and General Use Siege.ServiceLocation Part 2 &#8211; Contextual Registration and Resolution Siege.ServiceLocation Part 3 &#8211; Extending the container with custom use cases Siege.ServiceLocation Part 4 &#8211; Integrating Siege.ServiceLocation with ASP.NET MVC&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>The Siege Project </h3>
<ul>
<li><a href="/blogs/marcus_bratton/archive/2009/12/06/introducing-siege.aspx">Introduction</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/06/the-siege-project-siege-servicelocation.aspx">Siege.ServiceLocation Part 1 &#8211; Introduction and General Use</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx" target="_blank">Siege.ServiceLocation Part 2 &ndash; Contextual Registration and Resolution</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/10/the-siege-project-siege-servicelocation-part-3-extending-the-container-with-custom-use-cases.aspx" target="_blank">Siege.ServiceLocation Part 3 &ndash; Extending the container with custom use cases</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc.aspx" target="_blank">Siege.ServiceLocation Part 4 &ndash; Integrating Siege.ServiceLocation with ASP.NET MVC</a> </li>
<li>Siege.ServiceLocation Part 5 &ndash; A guide to getting started with Siege.ServiceLocation </li>
</ul>
<p>&nbsp;</p>
<h3>The Quick Start</h3>
<p>I&rsquo;ve put together a quickstart project. You can look through the files in this project to see how everything is put together. You can get the quick start project here:</p>
<p><a title="http://cloud.github.com/downloads/MarcusTheBold/Siege/SiegeMVCQuickStart.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/SiegeMVCQuickStart.zip">http://cloud.github.com/downloads/MarcusTheBold/Siege/SiegeMVCQuickStart.zip</a></p>
<p>&nbsp;</p>
<p>Things to look at in this project:</p>
<ul>
<li>Global.asax.cs &ndash; uses SiegeHttpApplication and shows how to hook up your ServiceLocatorAdapter (the quickstart uses Ninject) and shows where to configure the SiegeContainer.</li>
<li>ServiceLocatorExtensions.cs &ndash; shows how to do registrations with the SiegeContainer, both default and contextual. Also, shows how to do context on a variety of conditions, and shows how to register pre-configured instances with the UserFinder class.</li>
<li>AccountController &ndash; contrived, but shows an example of to work with IContextStore</li>
<li>The other controllers/services &ndash; basic classes that build up how the app works together</li>
</ul>
<p>&nbsp;</p>
<p>This is a purely contrived app that doesn&rsquo;t really do anything. There are 4 users &ndash; Webmaster, AdminUser, TrialUser and PaidUser. For all accounts, the password is pass123. As you login as different users you should see things start happening contextually based on attributes associated with the particular user you are associated with. The different views have text explaining how they work and what to expect. </p>
<p>Hopefully this will give a concrete example of how things work together. As always, if you have questions, feel free to leave a comment and I will respond.</p>
<p>&nbsp;</p>
<p>Happy coding!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Siege Project: Siege.ServiceLocation, Part 4 – Integrating Siege.ServiceLocation with ASP.NET MVC</title>
		<link>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc/</link>
		<comments>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:10:00 +0000</pubDate>
		<dc:creator>Marcus Bratton</dc:creator>
				<category><![CDATA[IoC]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Siege]]></category>

		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc.aspx</guid>
		<description><![CDATA[The Siege Project Introduction Siege.ServiceLocation Part 1 &#8211; Introduction and General Use Siege.ServiceLocation Part 2 &#8211; Contextual Registration and Resolution Siege.ServiceLocation Part 3 &#8211; Extending the container with custom use cases Siege.ServiceLocation Part 4 &#8211; Integrating Siege.ServiceLocation with ASP.NET MVC&#160;&#8230; <a href="http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc/">Continue&#160;reading&#160;<span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>The Siege Project </h3>
<ul>
<li><a href="/blogs/marcus_bratton/archive/2009/12/06/introducing-siege.aspx">Introduction</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/06/the-siege-project-siege-servicelocation.aspx">Siege.ServiceLocation Part 1 &#8211; Introduction and General Use</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx" target="_blank">Siege.ServiceLocation Part 2 &ndash; Contextual Registration and Resolution</a> </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/10/the-siege-project-siege-servicelocation-part-3-extending-the-container-with-custom-use-cases.aspx" target="_blank">Siege.ServiceLocation Part 3 &ndash; Extending the container with custom use cases</a> </li>
<li>Siege.ServiceLocation Part 4 &ndash; Integrating Siege.ServiceLocation with ASP.NET MVC </li>
<li><a href="/blogs/marcus_bratton/archive/2009/12/18/the-siege-project-siege-servicelocation-part-5-a-guide-to-getting-started-with-siege-servicelocation.aspx">Siege.ServiceLocation Part 5 &ndash; A guide to getting started with Siege.ServiceLocation</a> </li>
</ul>
<p>&nbsp;</p>
<p>Get the library used to integrate with ASP.NET MVC by downloading the binaries here: <a title="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.HttpIntegration.zip" href="http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.HttpIntegration.zip">http://cloud.github.com/downloads/MarcusTheBold/Siege/Siege.ServiceLocation.HttpIntegration.zip</a>     <br />Alternatively, you can get the source code here: <a title="http://github.com/MarcusTheBold/Siege" href="http://github.com/MarcusTheBold/Siege">http://github.com/MarcusTheBold/Siege</a> </p>
<h3>&nbsp;</h3>
<h3>Combining Siege.ServiceLocation and ASP.NET MVC</h3>
<p>By combining Siege.ServiceLocation with ASP.NET MVC, everything starts to come together. You get more than just the ability to abstract away your dependency on an individual IoC framework (and thereby allowing you to change implementations at the drop of a hat), you get the ability to react to changing conditions in your application and the individual user sessions. When resolving controllers, you have the ability to use views linked to either the contextually resolved controller, or linked to the base type that was requested. Integrating these two frameworks, it turns out, is incredibly simple to do.</p>
<p>&nbsp;</p>
<h3>SiegeHttpApplication</h3>
<p>SiegeHttpApplication is the main component that enables you to integrate with ASP.NET MVC. Inherit your Global application in the Global.asax.cs file from this class in order to turn your regular ASP.NET MVC application into a Siege enabled application. This abstract class forces you to implement only a handful of methods and offers you the ability to override several others (not actual implementation).</p>
<div style="border: 1px solid silver;margin: 20px 0px 10px;padding: 4px;overflow: auto;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 97.5%;font-family: 'Courier New',courier,monospace;direction: ltr;font-size: 8pt;cursor: text">
<div style="border-style: none;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt"><span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> SiegeHttpApplication : HttpApplication</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">{</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">public</span> IContextualServiceLocator ServiceLocator;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">abstract</span> IServiceLocatorAdapter GetServiceLocatorAdapter();</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> RegisterRoutes(RouteCollection routes) { }</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> IContextStore GetContextStore()</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    {</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    }</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> OnApplicationStarted()</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    {</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    }</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> OnApplicationStopped()</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    {</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    }</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">&nbsp;</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">void</span> OnApplicationError(Exception exception)</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    {</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: white;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">    }</pre>
<p><!--CRLF--></p>
<pre style="border-style: none;margin: 0em;padding: 0px;overflow: visible;text-align: left;line-height: 12pt;background-color: #f4f4f4;width: 100%;font-family: 'Courier New',courier,monospace;direction: ltr;color: black;font-size: 8pt">}</pre>
<p><!--CRLF--></div>
</div>
<p>The only method you must implement is GetServiceLocatorAdapter(). This instructs the SiegeHttpApplication what underlying IoC framework you wish to use. Other than this method, you have the ability to override the default IContextStore used by the SiegeContainer (by default the HttpSessionStore is used). OnApplicationStarted, OnApplicationStopped and OnApplicationError give you extension points to provide additional logic by which you can add custom logic for your own application.</p>
<p>&nbsp;</p>
<h3>HttpSessionStore</h3>
<p>By default, SiegeHttpApplication uses an implementation of IContextStore with the SiegeContainer called HttpSessionStore. This class stores items on the session of the user navigating your website, allowing you to control resolution on a user-by-user basis over the life of the user session. Developers can change this to any other implementation of IContextStore &ndash; GlobalContextStore to make your entire application change implementations based on context (for responding to global conditions) or to a custom implementation, if you need finer control over how context is stored and used in the resolution process.</p>
<p>&nbsp;</p>
<h3>And that&rsquo;s it!</h3>
<p>That&rsquo;s all it takes to use Siege.ServiceLocation with ASP.NET MVC. I have put together a quick start application that shows in detail how all these parts work together. </p>
<p>Happy Coding!</p>
<p><font color="#B4B4B4" size="-2">Post Footer automatically generated by <a href="http://www.freetimefoto.com/add_post_footer_plugin_wordpress" style="color: #B4B4B4; text-decoration:underline;">Add Post Footer Plugin</a> for wordpress.</font></p>
]]></content:encoded>
			<wfw:commentRss>http://lostechies.com/marcusbratton/2009/12/18/the-siege-project-siege-servicelocation-part-4-integrating-siege-servicelocation-with-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
