<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: The Siege Project: Siege.ServiceLocation, Part 2 &#8211; Contextual Registration and Resolution</title>
	<atom:link href="http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Mon, 07 May 2012 07:05:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-44</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Wed, 09 Dec 2009 23:02:42 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-44</guid>
		<description>Interesting!

For #1 yes, context is tracked per user session. Turns out that what you&#039;re asking for on #2 is possible with this framework (I&#039;ll be covering areas like this in the next post, and I&#039;ll post a comment afterward explaining how it applies to your scenario).</description>
		<content:encoded><![CDATA[<p>Interesting!</p>
<p>For #1 yes, context is tracked per user session. Turns out that what you&#8217;re asking for on #2 is possible with this framework (I&#8217;ll be covering areas like this in the next post, and I&#8217;ll post a comment afterward explaining how it applies to your scenario).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: azaslow</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-43</link>
		<dc:creator>azaslow</dc:creator>
		<pubDate>Wed, 09 Dec 2009 22:40:52 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-43</guid>
		<description>For #1 I don&#039;t think that I expressed my question well.  What you&#039;re saying is interesting, but not what I was thinking.

What I&#039;m thinking about is something which addresses the need that I think the httpSessionStore is trying to achive (i.e. providing different context values depending on the active user or other varying context).  I assume that your httpSessionStore returns different values based on the active session.  What I was asking was for was actually using different context stores of the same type with the same container (or with multiple containers which use the same registration catalog).

The way that I implemented this is that I have a root container which has no context and where everything is registered.  Later when a context is created  a child container is created from the root container using the given context.  This child container inherits the registrations from the root container.  Once the child container is created its context cannot be changed (although I probably could allow changing the context with a little work).

For #2 I started to write a scenario and then I realized that what I&#039;m asking goes beyond what you&#039;re trying to do.  I think that what I&#039;m looking for is simply to specify a factory to build the object  and for the container (and context store) to be passed to the factory so that the factory can utilize the container to build the required object.

Thanks for your response.  I think that what you&#039;re trying to do is something many people would like.</description>
		<content:encoded><![CDATA[<p>For #1 I don&#8217;t think that I expressed my question well.  What you&#8217;re saying is interesting, but not what I was thinking.</p>
<p>What I&#8217;m thinking about is something which addresses the need that I think the httpSessionStore is trying to achive (i.e. providing different context values depending on the active user or other varying context).  I assume that your httpSessionStore returns different values based on the active session.  What I was asking was for was actually using different context stores of the same type with the same container (or with multiple containers which use the same registration catalog).</p>
<p>The way that I implemented this is that I have a root container which has no context and where everything is registered.  Later when a context is created  a child container is created from the root container using the given context.  This child container inherits the registrations from the root container.  Once the child container is created its context cannot be changed (although I probably could allow changing the context with a little work).</p>
<p>For #2 I started to write a scenario and then I realized that what I&#8217;m asking goes beyond what you&#8217;re trying to do.  I think that what I&#8217;m looking for is simply to specify a factory to build the object  and for the container (and context store) to be passed to the factory so that the factory can utilize the container to build the required object.</p>
<p>Thanks for your response.  I think that what you&#8217;re trying to do is something many people would like.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-42</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Wed, 09 Dec 2009 19:24:22 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-42</guid>
		<description>@azaslow - #1 is something I&#039;ve been thinking about for a while but wasn&#039;t sure I wanted to complicate things. I think my instinct right now is to leave it down to specific implementations of an IContextStore to determine how to manage it. But I&#039;m not sure that&#039;s enough.

If I were to do a Per-Request, Per-Session, Per-Instance model, with three context stores (for example), would I predetermined a precedence for how I check? Would it be RequestContext before SessionContext before ApplicationContext? Would that force a user into a specific model (something I don&#039;t want to do).

Or could I allow users to add more than one context store? If I do that, do I need to allow users to specify a precedence between them? How do I make sure the correct store is looked at first for resolutions if multiple contexts are able to satisfy a use case, but they ultimately resolve to different types?

Those are the questions I&#039;ve been debating. So in the end I&#039;ve settled that until a better way is pointed out, I&#039;ll put the burden on the consumer to define an implementation of IContextStore that satisfies their needs. Maybe someone will create a ComplexContextStore that has an internal list of IContextStores for different scopes, and can it determine how to return its items in the correct fashion to the SiegeContainer. I dunno. I&#039;m open to ideas.

For #2... I hadn&#039;t really considered that idea. Right now I suspect an object has to exist in context for it to be evaluated. I agree that it is more robust, but what I&#039;m curious to see is a scenario where you&#039;d do this. That will help me understand better what the goal is behind it.  :)</description>
		<content:encoded><![CDATA[<p>@azaslow &#8211; #1 is something I&#8217;ve been thinking about for a while but wasn&#8217;t sure I wanted to complicate things. I think my instinct right now is to leave it down to specific implementations of an IContextStore to determine how to manage it. But I&#8217;m not sure that&#8217;s enough.</p>
<p>If I were to do a Per-Request, Per-Session, Per-Instance model, with three context stores (for example), would I predetermined a precedence for how I check? Would it be RequestContext before SessionContext before ApplicationContext? Would that force a user into a specific model (something I don&#8217;t want to do).</p>
<p>Or could I allow users to add more than one context store? If I do that, do I need to allow users to specify a precedence between them? How do I make sure the correct store is looked at first for resolutions if multiple contexts are able to satisfy a use case, but they ultimately resolve to different types?</p>
<p>Those are the questions I&#8217;ve been debating. So in the end I&#8217;ve settled that until a better way is pointed out, I&#8217;ll put the burden on the consumer to define an implementation of IContextStore that satisfies their needs. Maybe someone will create a ComplexContextStore that has an internal list of IContextStores for different scopes, and can it determine how to return its items in the correct fashion to the SiegeContainer. I dunno. I&#8217;m open to ideas.</p>
<p>For #2&#8230; I hadn&#8217;t really considered that idea. Right now I suspect an object has to exist in context for it to be evaluated. I agree that it is more robust, but what I&#8217;m curious to see is a scenario where you&#8217;d do this. That will help me understand better what the goal is behind it.  <img src='http://lostechies.com/marcusbratton/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: azaslow</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-41</link>
		<dc:creator>azaslow</dc:creator>
		<pubDate>Wed, 09 Dec 2009 16:33:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-41</guid>
		<description>I am working on something similar to but not as elegant as what you&#039;re describing.  I have two questions about what you&#039;re doing:

1) Is there a way to use different context store objects with a single container or is there a way to share registrations between containers?

I have found that it is very useful to be able to perform all of the registrations once and then use those common registrations under different contexts at the same time (in my case I create multiple containers each with its own context and each using a single shared registration).

For instance on a web server which is receiving multiple requests from different users you want to resolve using different contexts for each request but you don’t want to have to re-register everything for each request.

2) In the “When” part of the registration can only objects which are part of the context store be resolved or are the resolved objects registered with the container itself?

For instance, in your example where you are getting VendorStatus, must VendorStatus be an object in the context store or can it be any object which is retrieved from the container?  I think that being able to make a decision based on an object in the container is more robust than limiting decisions to items in the context store alone.
</description>
		<content:encoded><![CDATA[<p>I am working on something similar to but not as elegant as what you&#8217;re describing.  I have two questions about what you&#8217;re doing:</p>
<p>1) Is there a way to use different context store objects with a single container or is there a way to share registrations between containers?</p>
<p>I have found that it is very useful to be able to perform all of the registrations once and then use those common registrations under different contexts at the same time (in my case I create multiple containers each with its own context and each using a single shared registration).</p>
<p>For instance on a web server which is receiving multiple requests from different users you want to resolve using different contexts for each request but you don’t want to have to re-register everything for each request.</p>
<p>2) In the “When” part of the registration can only objects which are part of the context store be resolved or are the resolved objects registered with the container itself?</p>
<p>For instance, in your example where you are getting VendorStatus, must VendorStatus be an object in the context store or can it be any object which is retrieved from the container?  I think that being able to make a decision based on an object in the container is more robust than limiting decisions to items in the context store alone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mbratton</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-40</link>
		<dc:creator>mbratton</dc:creator>
		<pubDate>Wed, 09 Dec 2009 15:16:42 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-40</guid>
		<description>@Mihai: There were two reasons I didn&#039;t implement an AutofacAdapter or a UnityAdapter. First, I&#039;ve never used them, so I&#039;d have to learn them (not a big deal). Secondly, I felt that if this project had enough support from the community, and people wanted a Unity or Autofac adapter, one would be put together. Maybe I should put together a post on how to make an adapter?</description>
		<content:encoded><![CDATA[<p>@Mihai: There were two reasons I didn&#8217;t implement an AutofacAdapter or a UnityAdapter. First, I&#8217;ve never used them, so I&#8217;d have to learn them (not a big deal). Secondly, I felt that if this project had enough support from the community, and people wanted a Unity or Autofac adapter, one would be put together. Maybe I should put together a post on how to make an adapter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mihai</title>
		<link>http://lostechies.com/marcusbratton/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution/#comment-39</link>
		<dc:creator>Mihai</dc:creator>
		<pubDate>Wed, 09 Dec 2009 11:32:54 +0000</pubDate>
		<guid isPermaLink="false">/blogs/marcus_bratton/archive/2009/12/09/the-siege-project-siege-servicelocation-part-2-contextual-registration-and-resolution.aspx#comment-39</guid>
		<description>Looks pretty interesting. One argument I&#039;d like to leave is that you should implement an adapter for UnityContainer.

The reason for a UnitContainerAdapter is simple, most firms have the firm belief that if it&#039;s from Microsoft than it is better than anything else. So as a developer you won&#039;t be able to propose the use of X or Y unless it&#039;s from Microsoft. 
</description>
		<content:encoded><![CDATA[<p>Looks pretty interesting. One argument I&#8217;d like to leave is that you should implement an adapter for UnityContainer.</p>
<p>The reason for a UnitContainerAdapter is simple, most firms have the firm belief that if it&#8217;s from Microsoft than it is better than anything else. So as a developer you won&#8217;t be able to propose the use of X or Y unless it&#8217;s from Microsoft. </p>
]]></content:encoded>
	</item>
</channel>
</rss>
