It is a bug in the kernel
On Fri, Nov 14, 2008 at 10:45 PM, Jason Meckley <[EMAIL PROTECTED]>wrote:
>
> So is the problem the use of the kernel, the kernel itesefl?
> Is there a work around, or patch to resolve this; either Windsor or
> Igloo?
>
> if I took a shot at patching what would need to be done?
>
> thank you for looking into this scenario.
>
> On Nov 14, 11:05 am, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > That is actually my fault :-)
> >
> > This is the problem:
> >
> > protected object ResolveComponent(IHandler handler, Type service,
> > IDictionary additionalArguments)
> > {
> > bool createdContext = currentCreationContext == null;
> > CreationContext context = currentCreationContext ??
> > CreateCreationContext(handler,
> > service, additionalArguments);
> > currentCreationContext = context;
> > try
> > {
> > object instance = handler.Resolve(context);
> >
> > // ReleasePolicy.Track(instance, handler);
> >
> > return instance;
> > }
> > finally
> > {
> > if(createdContext)
> > currentCreationContext = null;
> > }
> > }
> >
> > I added this to ensure that recursively calling the container during
> resolve
> > will not get a stack overflow, but it breaks this scenario, because you
> are
> > building a non generic type, and then a generic type, but the context is
> not
> > recreated.
> >
> > On Thu, Nov 6, 2008 at 6:35 PM, Jason Meckley <[EMAIL PROTECTED]
> >wrote:
> >
> >
> >
> > > I've found a bug in the entity injection and for the life of me I
> > > can't fix it.
> >
> > > here's the scenario.
> > > i want to resolve the repository and then invoke either findone or get
> > > depending on certain criteria
> > > so I created a test to make sure I can resolve the repository
> > > correctly
> >
> > > Type type = typeof(IRepository<>).MakeGenericType(typeof(AnEntity));
> > > object repository = IoC.Resolve(type);
> > > object entity = type.GetMethod("Get").Invoke(repository, new object[]
> > > {id});
> >
> > > and this works.
> >
> > > So now I implement this in RhinoIglooFacility.InjectEntities
> >
> > > Type repositoryType =
> > > typeof(IRepository<>).MakeGenericType(property.PropertyType);
> > > object repository = kernel.Resolve(repositoryType);
> > > entity = repositoryType
> > > .GetMethod("Get")
> > > .Invoke(repository, new object[] { id });
> >
> > > but this throws an ArgumentException "type has 1 generic parameter,
> > > but 0 where supplied" at kernel.Resolve
> > > the problem starts here:
> > >
> Castle.MicroKernel.Handlers.DefaultGenericHandler.Resolve(CreationContext)
> >
> > > this doesn't make sense to me. Why would the original test pass, but
> > > code within the facility fail?
> >
> > > however if I use this code in RhinoIglooFacility, it works.
> >
> > > object entity =
> >
> > >
> UnitOfWork.GetCurrentSessionFor(property.PropertyType).Get(property.PropertyType,
> > > id);
> > > however don't want to pull straight from session and the repositories
> > > could be decorated and that functionality is required.
> >
> > > my final goal is to create 3 strategies for entity retrieval.
> > > 1. Repository.Get (originally used AR moderator.Get)
> > > 2. Repository.FindOne with IFetchingStrategy<>
> > > 3. Repository.FindOne with EagerLoad (original functionality)
> >
> > > any ideas where to go from here?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---