Using<GetFillupById>().Execute(id);
never saw such syntax.
definition of Using is:
protected T Using<T>() where T : class
{
var handler = serviceLocator.GetInstance<T>();
if (handler == null)
{
throw new NullReferenceException("Unable to resolve type with service locator; type " + typeof(T).Name);
}
return handler;
}
if someone can tell me what exactlythis thing is- function, property?
or show me some link where i can read about –
I will appreciate
This method/function uses a service locator to provide an instance of type
T, returning that instance so it can be called. It’s analgous to this:but instead of a default constructor call, this helper method wraps up the object initialisation and delegates it to a service locator object. The use of generics allows this to be used as a single method call for any type recognised by the service locator.
The type constraint
where T : classmeans that this method can be validly called for any typeTwhich is a class rather than a structure, i.e. a reference rather than a value type. The converse would bewhere T : struct. You can also include constraints to sayTmust implement a particular interface, extend a certain class, or expose a default constructor (where T : new()).Related concepts to look up: generics, inversion of control.