6
This builder has a this
, what it really means?
public class HelpController : Controller
{
private const string ErrorViewName = "Error";
public HelpController()
: this(GlobalConfiguration.Configuration)
{
}
public HelpController(HttpConfiguration config)
{
Configuration = config;
}
public HttpConfiguration Configuration { get; private set; }
public ActionResult Index()
{
ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}
public ActionResult Api(string apiId)
{
if (!String.IsNullOrEmpty(apiId))
{
HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId);
if (apiModel != null)
{
return View(apiModel);
}
}
return View(ErrorViewName);
}
public ActionResult ResourceModel(string modelName)
{
if (!String.IsNullOrEmpty(modelName))
{
ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator();
ModelDescription modelDescription;
if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription))
{
return View(modelDescription);
}
}
return View(ErrorViewName);
}
}
Look at the full class. Does he inherit from the builder below him? I have more or less understood what colleagues have said, but there is still a doubt: why this
has it: GlobalConfiguration.Configuration
. Ttalvez I’m in doubt in the nomenclature.
Big, I made an issue and look at my question there, please.
– pnet
That builder with the
: this()
is something new? I never knew it, I always created a private method calledInicializa()
that I called in all builders (normally I use no more than 2 builders, but only did it to facilitate).– Alisson
Now it became clearer (after the last edition), I understood why this, from
this
. Thank you and thank you.– pnet
@Alisson since version 1.0 :)
– Maniero