what difference between resourcecontrollerfactory , defaultcontrollerfactory in asp.net mvc?
context: looking hook ioc container controller factory - have overriden defaultcontrollerfactory
this, see resourcecontrollerfactory
being used in project working with.
does 1 provide improved support rest apis?
code each:
defaultcontrollerfactory
public class defaultcontrollerfactory : icontrollerfactory { // fields private ibuildmanager _buildmanager; private controllerbuilder _controllerbuilder; private controllertypecache _instancecontrollertypecache; private static controllertypecache _staticcontrollertypecache; // methods static defaultcontrollerfactory(); public defaultcontrollerfactory(); internal static invalidoperationexception createambiguouscontrollerexception(routebase route, string controllername, icollection<type> matchingtypes); public virtual icontroller createcontroller(requestcontext requestcontext, string controllername); protected internal virtual icontroller getcontrollerinstance(requestcontext requestcontext, type controllertype); protected internal virtual type getcontrollertype(requestcontext requestcontext, string controllername); private type getcontrollertypewithinnamespaces(routebase route, string controllername, hashset<string> namespaces); public virtual void releasecontroller(icontroller controller); // properties internal ibuildmanager buildmanager { get; set; } internal controllerbuilder controllerbuilder { get; set; } internal controllertypecache controllertypecache { get; set; } }
resourcecontrollerfactory
public class resourcecontrollerfactory : icontrollerfactory { // fields private icontrollerfactory inner; private const string restactiontoken = "$rest$"; // methods public resourcecontrollerfactory(); public resourcecontrollerfactory(icontrollerfactory inner); public icontroller createcontroller(requestcontext requestcontext, string controllername); public void releasecontroller(icontroller controller); // nested types private class resourcecontrolleractioninvoker : controlleractioninvoker { // methods public resourcecontrolleractioninvoker(); protected override actiondescriptor findaction(controllercontext controllercontext, controllerdescriptor controllerdescriptor, string actionname); // nested types private class resourceerroractiondescriptor : actiondescriptor { // fields private controllerdescriptor controllerdescriptor; private string message; private httpstatuscode statuscode; // methods public resourceerroractiondescriptor(controllerdescriptor controllerdescriptor, httpstatuscode statuscode, string message); public override object execute(controllercontext controllercontext, idictionary<string, object> parameters); public override parameterdescriptor[] getparameters(); // properties public override string actionname { get; } public override controllerdescriptor controllerdescriptor { get; } } } } expand methods
the resourcecontrollerfactory offers automatic response serialisation according accept http header (i think).
Comments
Post a Comment