Closed mcdis closed 6 years ago
Related to https://github.com/ipjohnson/Grace/issues/131
Let's look to ILocatorService:
public interface ILocatorService { //... T Locate<T>(); object Locate(Type type); }
And let's compare to implementation InjectionScope:
public class InjectionScope : ... { public T Locate<T>() { return (T) this.Locate(typeof (T)); // <--call ILocatorService Locate(Type) } }
So we can shrink ILocatorService, remove T Locate<T>() and replace it to extension method to ILocatorService like:
T Locate<T>()
public static class ILocatorServiceExtensions { public static T Locate<T>(this ILocatorService _this)=>(T) _this.Locate(typeof (T)); }
LocateOrDefault and other methods can be removed from interface and start live in extension form.
So work in this way the Grace interface will stay more cleaner and smaller and lighter
Just so you are aware I don't envision starting work on changing the interfaces any time soon. If it does happen it will be a year plus out as I have other things I'm interested in working on.
Related to https://github.com/ipjohnson/Grace/issues/131
Let's look to ILocatorService:
And let's compare to implementation InjectionScope:
So we can shrink ILocatorService, remove
T Locate<T>()
and replace it to extension method to ILocatorService like:LocateOrDefault and other methods can be removed from interface and start live in extension form.
So work in this way the Grace interface will stay more cleaner and smaller and lighter