我将尝试在C#中创建一个提供的类型,以以下方式调用其基础构造函数:
我目前能够提供的最接近的翻译是这样的:
尽管具有相同的功能,但两者并不完全相同。 我用来构建ProvidedConstructor的代码如下:
public class SubclassController : BaseClass
{
public SubclassController (IntPtr handle) : base (handle)
{}
}
我目前能够提供的最接近的翻译是这样的:
我目前能够提供的最接近的翻译是这样的:
public sealed class SubclassController : BaseClass
{
public SubclassController (IntPtr handle)
{
this;
base..ctor (handle);
}
尽管具有相同的功能,但两者并不完全相同。 我用来构建ProvidedConstructor的代码如下:
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 -> <@@ () @@>