PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/SampleLibrary/IOC/BugFixes/MyFactory.cs

http://github.com/philiplaureano/LinFu
C# | 29 lines | 19 code | 5 blank | 5 comment | 1 complexity | 5c61cce4a8ced801e3b1f474c8e7e52d MD5 | raw file
 1using System;
 2using LinFu.IoC.Configuration;
 3using LinFu.IoC.Interfaces;
 4
 5namespace SampleLibrary.IOC.BugFixes
 6{
 7    [Factory(typeof(MyClass<string>))]
 8    public class MyFactory :
 9        //IFactory<MyClass<string>>
10        IFactory
11    {
12        public object CreateInstance(IFactoryRequest request)
13        {
14            if (string.IsNullOrEmpty(request.ServiceName))
15                throw new ArgumentNullException("ServiceName");
16
17            var myClass = new MyClass<string>();
18            myClass.Value = request.ServiceName;
19
20            return myClass;
21        }
22
23
24        //MyClass<string> IFactory<MyClass<string>>.CreateInstance(IFactoryRequest request)
25        //{
26        //    return (MyClass<string>)CreateInstance(request);
27        //}
28    }
29}