waoywssy / linfu

Automatically exported from code.google.com/p/linfu
0 stars 0 forks source link

IFactory<T> not working with 2.0.3.1 #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With LF 2.0.3.1, factories that implement IFactory<T> are not recognized.

I initialize a ServiceContainer as follows:

ServiceContainer container = new ServiceContainer();
container.AddDefaultServices();
container.LoadFrom(/*MyAssemblyGoesHere*/);

I have a service with a factory:

[Factory(typeof(ISomething))]
public class SourceControlFactoryFactory :
    IFactory<ISomething>
{
    ...
}

and another service that takes an instance of ISomething as an argument.

[Implements(typeof(ISomethingElse))]
internal class SomethingElse :
    ISomethingElse
{
    public SomethingElse(ISomething something) {}

    ...
}

ISomethingElse x = container.GetService<ISomethingElse>();

fails with an exception indicating that the ISomething service cannot be found.

If I change IFactory<ISomething> to IFactory it works fine.

Original issue reported on code.google.com by ran...@gmail.com on 19 Feb 2009 at 10:42

GoogleCodeExporter commented 9 years ago
Fixed. The bug was caused by the LazyFactory class--it was not properly calling 
the
registered IFactory<T> instance every time a service was being requested.

Original comment by Philip.L...@gmail.com on 25 Feb 2009 at 1:56

GoogleCodeExporter commented 9 years ago
The fix is available in revision 364.

Original comment by Philip.L...@gmail.com on 25 Feb 2009 at 1:57