Community Page
- blog.ashmind.com Jump to website »
-
Subscribe -
Community
-
Top Commenters
-
Popular Threads
-
Recent Comments
- Interesting post. Appreciate it as I have seen something new now. Can I use this info on my blog using the direct link to your blog? Thanks in advance
- Well I had crash I think, and that was related to the fact that text was not set -- it required at least "" to be provided. But they have fixed it since, so now everything should work...
- Well, I drop a TextEditor component onto my form, and everhthing crashes. I suppose there is some 'proper' way to use it, but what I would really love is an example, because I could find...
- Ok, what exceptions are you getting? They might have broken something since the version I downloaded, or I could have occasionally set some options that is required by it to work correctly.
- Hi, I saw your post on StackOverflow regarding use of AvalonEdit, so I ended up downloading it and playing with it a bit. Unfortunately, after an hour of exception after exception, I gave up. So I...
Jump to original thread »
Note to RSS users: There are embedded spreadsheets in this posts that Google Reader silently hides. I prefer RSS myself, but for this post Zoho features are very useful and, unfortunately, I see no way to make it usable in Google Reader. Sorry about that.
I have finished the previous po ... Continue reading »
I have finished the previous po ... Continue reading »
9 months ago
Do you know if all containers support registering services/components at any given time?
I know Castle can do that, i'm abusing it a bit in my current project.
9 months ago
9 months ago
If you take a look at the updated version of your test project, you'll notice that LinFu passes every test in both "MustHave" and "ShouldHave" categories--all from an assembly that is only about 94KB in size! :)
If you can, please update your charts accordingly. Thanks!
9 months ago
I think I can't update in-post chart, since it'll require me to update post text as well, and that would mean I have to consider and mention all other framework updates.
I am looking for a way to keep an up-to-date version of charts at the net-ioc-frameworks page of Google Code, I hope to do it soon enough.
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
Thanks for the review.
9 months ago
9 months ago
I have made a custom Castle resolver, however it does not handle complex scenarios like circular reference tracking.
9 months ago
You can use the Container in StructureMap independently of the static ObjectFactory.
IContainer container = new Container(r => {
r.ForRequestedType<Foo>().TheDefaultIsConcreteType<Bar>();
// and so on
});
I'm still not sold on the hierarchical container idea. In StructureMap, I use the "Profile" concept for the same purpose as a hierarchical container in Windsor.
9 months ago
As for hierarchical containers, I do like the disposable lightweight container idea of Autofac.
Also I had a use case for explicitly hierarchical container with Castle, but that was not the only solution in that case.
If I understand your profile idea correctly, it is an ability to switch between registrations sets.
I would prefer an explicit using() {} block to a property in this case, since I always like to see context boundaries.
Also instances are more easier from threading POV.
9 months ago
9 months ago
9 months ago
Btw, do you realize what you've just done? About a month ago, Jeremy Miller talked about an IOC container detente and how there should be a common interface among IoC frameworks:
http://codebetter.com/blogs/jeremy.miller/archi...
I know you wrote the IOC adapters in your test project so that you can test the various IoC frameworks, but what you've effectively done here is unify the more common IoC frameworks under one set of interfaces!
In theory, I could easily swap to and from any one of those frameworks without having to worry about which IoC container I'm actually using. Again, awesome job!
9 months ago
However it would be nice if it actually helps you.
9 months ago
I've been working on my own container (LinFu.IoC 2.0) and it passes all of the 'MustHave' tests, but I can't seem to figure out what the intent was behind the Unregistered Resolution feature.
What makes it interesting is that I can even determine which services exist inside the container and I can instantiate them all at once, like so:
// Instantiate all named services of type 'IMyService'
var services = from info in container.AvailableServices
where info.Name.Length > 0 &&
info.ServiceType == typeof(IMyService)
select container.GetService(info) as IMyService;
You can check it out here:
http://code.google.com/p/linfu/wiki/BuildingLinFu2
Right now, it's still under development, but I'm only two features away from making it available for production usage. Take a look! :)
9 months ago
It is very useful when framework also provides support for additional arguments -- then I can easily build a factory that reuses container dependency resolution.
See http://blog.ashmind.com/index.php/2008/06/23/di... for an example.
I think other solution is to create a quick throwable-out child container like autofac provides, but I have not tried this yet (sounds like a much less performant solution).
I have added you as a project member to the net-ioc-frameworks, so you now probably have access to upload LinFu adapter.
9 months ago
Ahh, I see! Now that you've mentioned it, LinFu *does* support unregistered resolution, but its not implemented quite the same way as other contains would implement it. For example, if I had an unregistered class like:
public class MyClass
{
public MyClass(ISomeService service)
{
// ...
}
}
You can create the unregistered class in LinFu using the following code:
// ...construct the container somewhere here
container.AddService<ISomeService>(new SomeService());
var myClass = (MyClass)container.AutoCreate(typeof(MyClass);
Now the tricky part here is that I've been running LinFu through your battery of tests, and I can't seem to get it to pass the UnregisteredResolution test. Is there anyway to modify the logic so that each library has a way to implement their own unregistered resolution? Clumping it all under a single Adapter.Resolve() call doesn't seem to apply, in this case.
9 months ago
There is already a Create<T> method in the IFrameworkAdapter, but test did not use it.
I have just modified the test to use Create<T> instead of Resolve<T>.
So get the latest version, then implement Create<T> using AutoCreate.
9 months ago
Btw, you might want to add property service list injection as one of the "should haves" for IoC container features. For example, if I have a service instance with a property such as:
[SomeCustomPropertyInjectionAttribute] // This differs with every IoC container
public ISomeServices[] MyServices { get; set; }
It would be nice to have the container automatically instantiate the existing list of ISomeService instances from the container and inject it to the MyServices property. What do you think?
9 months ago
But documenting assumptions this in a testable way is always a good idea. I'll do this.
9 months ago
Wow! It is very interesting to see a methodical approach to this comparison.
Autofac does also support list registrations - but like 'resolve anything' you have to opt-in. See: http://code.google.com/p/autofac/wiki/Collections.
As you've hinted at - like most containers you can change this behaviour by writing custom extensions. In general, you'll find Autofac is very conservative about working absolutely predictably by default.
Cheers,
Nick
9 months ago
You have a very interesting implementation.
I would prefer to have an automatic registration by default, since if I get into situation where I would need more than one ILogger collection, I would probably use some kind of contextual override for a requiring component anyway. But it is a question of preference.
There are only two things that I feel are missing in your implementation -- support for IService[] (since it is simplest way to define collection dependency) and and ability to register collections using non-generic API.
Due to the first one, I can not update tests to pass right now, however, I had fixed the chart and will fix the post text as well.
9 months ago
builder.Register(c => c.Resolve<IEnumerable<X>>().ToArray());
..in order to adapt the default collection type onto an array type.
I'll look into the non-generic collection registrations - may look into that in the future if there is demand.
Thanks for the feedback!
9 months ago
builder.RegisterTypesAssignableTo<object>();
:) Not really recommendable though.
I recently ported some Prism code from Unity to Autofac, and used something similar to:
builder.RegisterTypesMatching(t => t.Name.EndsWith("View"));
--- just to illustrate that there is no need to use tagging interfaces or inheritance in order to work with this feature.
9 months ago
By the way, is it possible to resolve unregistered types in Autofac?
I do not feel that is very important, given hierarchical containers, but I am still interested.
9 months ago
You could always create an extension method ResolveUnregistered() which could check/register first, too.
Not sure what you mean about hierarchical containers relating to this use case - can you clarify a little?
9 months ago
So, if I can create a container in place and then throw it away, it also solves the pollution problem.
9 months ago
8 months ago
6 months ago
6 months ago