In einer MVC-App gibt es mehrere Klassen, die Konstruktoren ohne einen Methodenkörper verwenden. Zum Beispiel eine der Klassen ist die Actionklasse:.net MCV verwendet Konstruktoren ohne Methodenkörper. Wie ist das möglich und wie kann es dupliziert werden?
using System;
namespace System.Web.Mvc
{
// Summary:
// Encapsulates the result of an action method and is used to perform a framework-level
// operation on behalf of the action method.
public abstract class ActionResult
{
// Summary:
// Initializes a new instance of the System.Web.Mvc.ActionResult class.
protected ActionResult();
// Summary:
// Enables processing of the result of an action method by a custom type that
// inherits from the System.Web.Mvc.ActionResult class.
//
// Parameters:
// context:
// The context in which the result is executed. The context information includes
// the controller, HTTP content, request context, and route data.
public abstract void ExecuteResult(ControllerContext context);
}
}
Diese Klasse Konstruktor keine Methode Körper. Wenn ich versuche, den Code in einer Anwendung zu kopieren, erhalte ich den erwarteten Fehler, dass der Konstruktor einen Textkörper haben muss.
Was macht Microsoft in diesem Fall, damit die Objektkonstruktoren so arbeiten?
Um zu verdeutlichen, Metadata ist eine Darstellung des Codes, nicht der eigentliche Code? – Kuhlk
Ja, was Sie sehen, ist nicht der echte Code, nur die Definition des Typs. –
Ok Danke das beantwortet meine Frage. – Kuhlk