예제 #1
0
    public TestDelegate()
    {
        base.Name = "Delegate";

        this.nativeLib          = new UnmanagedLibrary("Native");
        this.doWithNoParameters =
            this.nativeLib.GetUnmanagedFunction
            <DelegateWithNoParameters>(
                "DoWithNoParameters"
                );
        this.doWithInt =
            this.nativeLib.GetUnmanagedFunction
            <DelegateWithInt>(
                "DoWithInt"
                );
        this.doWithDouble =
            this.nativeLib.GetUnmanagedFunction
            <DelegateWithDouble>(
                "DoWithDouble"
                );
        this.doWithIntPointer =
            this.nativeLib.GetUnmanagedFunction
            <DelegateWithIntPointer>(
                "DoWithIntPointer"
                );
        this.doWithDoublePointer =
            this.nativeLib.GetUnmanagedFunction
            <DelegateWithDoublePointer>(
                "DoWithDoublePointer"
                );
    }
예제 #2
0
    public TestCalli()
    {
        base.Name = "Calli";

        this.nativeLib = new UnmanagedLibrary("Native");

        IntPtr nativeMethodAddress =
            this.nativeLib.GetUnmanagedFunctionAddress(
                "DoWithNoParameters"
                );

        this.doWithNoParameters =
            GetCalliDelegate
            <DelegateWithNoParameters>(
                nativeMethodAddress
                );

        nativeMethodAddress =
            this.nativeLib.GetUnmanagedFunctionAddress(
                "DoWithInt"
                );
        this.doWithInt =
            GetCalliDelegate
            <DelegateWithInt>(
                nativeMethodAddress
                );

        nativeMethodAddress =
            this.nativeLib.GetUnmanagedFunctionAddress(
                "DoWithDouble"
                );
        this.doWithDouble =
            GetCalliDelegate
            <DelegateWithDouble>(
                nativeMethodAddress
                );

        nativeMethodAddress =
            this.nativeLib.GetUnmanagedFunctionAddress(
                "DoWithIntPointer"
                );
        this.doWithIntPointer =
            GetCalliDelegate
            <DelegateWithIntPointer>(
                nativeMethodAddress
                );

        nativeMethodAddress =
            this.nativeLib.GetUnmanagedFunctionAddress(
                "DoWithDoublePointer"
                );
        this.doWithDoublePointer =
            GetCalliDelegate
            <DelegateWithDoublePointer>(
                nativeMethodAddress
                );
    }
예제 #3
0
    public TestDynamicS()
    {
        base.Name = "DynamicS";

        string            libraryName       = "Native";
        CallingConvention callingConvention = CallingConvention.Cdecl;

        this.doWithNoParameters =
            GetDynamicSDelegate
            <DelegateWithNoParameters>(
                libraryName,
                "DoWithNoParameters",
                callingConvention
                );
        this.doWithInt =
            GetDynamicSDelegate
            <DelegateWithInt>(
                libraryName,
                "DoWithInt",
                callingConvention
                );
        this.doWithDouble =
            GetDynamicSDelegate
            <DelegateWithDouble>(
                libraryName,
                "DoWithDouble",
                callingConvention
                );
        this.doWithIntPointer =
            GetDynamicSDelegate
            <DelegateWithIntPointer>(
                libraryName,
                "DoWithIntPointer",
                callingConvention
                );
        this.doWithDoublePointer =
            GetDynamicSDelegate
            <DelegateWithDoublePointer>(
                libraryName,
                "DoWithDoublePointer",
                callingConvention
                );
    }