문제

클래스 imagemagicknet에 사용자 정의 기능을 추가하려고합니다. 사용해야합니다 IsSimilarImage magick imageMagick.net 프로젝트의 메소드이지만 .NET 측에서 사용할 수있는 기능이 Magick ++에서 시작되므로 Magick ++를 통해이 메소드를 라우팅 해야하는지에 대해 혼란스러워합니다.

올바른 솔루션이 없습니다

다른 팁

이것은 꽤 오래되었지만 답이없는 것처럼 여기에 간다.

Imagemagick 라이브러리를 보지 못했기 때문에 아래 코드의 구현 세부 사항은 엄격하게 예입니다. 쓰레기를 올바른 구현으로 교체하십시오. 유효한 .NET 객체를 내보내고 있다고 가정하면 이것이 작동하는 방식입니다.

' Put your extension methods or properties in a clearly labeled module file, on its own within your project
Module ImageMagickNetExtensions

    ' Define an extension method by using the ExtensionAttribute, and make the first argument
    ' for the method the type that you wish to extend. This will serve as a reference to the extended
    ' instance, so that you can reference other methods and properties within your extension code.
    <Extension()> _
    Public Function SomeExtensionFunction(ByVal imn As ImageMagickNet, ByVal filename As String) As Boolean
        Return imn.IsSimilarImage(filename)
    End Function

End Module

Class SomeClass
    ' To use your extension method within your project containing the extension module, simply
    ' call it on any valid instance of the type you have extended. The compiler will call your code
    ' whenever it sees reference to it, passing a reference to your extended instance.
    Private imn As New ImageMagickNet

    Private Sub DoSomething()
        If imn.SomeExtensionFunction("c:\someimage.jpg") Then
            ...
        End If
    End Sub
End Class
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top