Was Im a bereitgestellt Art zu tun versucht, ist zu erstellen, wie dies in C# seinen Basiskonstruktor ruft:Verwendung von F # Typ-Anbietern wie Sie eine Basis Konstruktoraufruf als Teil der Konstruktordefinition implementieren
public class SubclassController : BaseClass
{
public SubclassController (IntPtr handle) : base (handle)
{}
}
Die nächstgelegene Ich kann derzeit erhalten ist das:
public sealed class SubclassController : BaseClass
{
public SubclassController (IntPtr handle)
{
this;
base..ctor (handle);
}
Welche obwohl die gleiche Funktionalität ist nicht ganz das gleiche.
Der Code Ich verwende ist die ProvidedConstructor zu bauen, wie folgt:
let providedConstructor = ProvidedConstructor([ProvidedParameter("handle", typeof<IntPtr>)])
let ctorInfo = typeof<SubclassController>.GetConstructor(BindingFlags.Public ||| BindingFlags.Instance, null, [|typeof<IntPtr>|], null)
providedConstructor.BaseConstructorCall <- fun args -> ctorInfo, args
providedConstructor.InvokeCode <- fun args -> <@@() @@>