' PlatformUtils.vb copyright(c) 2009 Tony Tanzillo
'
'
' Abstract:
'
' Platform compatibiity helper methods that allow an
' assembly to run on both 32 and 64 bit systems.
'
' Refer to PlatformUtils.cs for more complete documentation.
'
Imports System.Runtime.CompilerServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports System.Reflection
<Extension()> _
Public Module PlatformCompatibilityExtensionMethods
Sub New()
Dim types1 As Type() = Nothing
Dim types2 As Type() = Nothing
If (IntPtr.Size > 4) Then
types1 = New Type() {GetType(Entity), GetType(Intersect), GetType(Point3dCollection), GetType(Long), GetType(Long)}
types2 = New Type() {GetType(Entity), GetType(Intersect), GetType(Plane), GetType(Point3dCollection), GetType(Long), GetType(Long)}
Else
types1 = New Type() {GetType(Entity), GetType(Intersect), GetType(Point3dCollection), GetType(Integer), GetType(Integer)}
types2 = New Type() {GetType(Entity), GetType(Intersect), GetType(Plane), GetType(Point3dCollection), GetType(Integer), GetType(Integer)}
End If
PlatformCompatibilityExtensionMethods.intersectWithMethod1 = GetType(Entity).GetMethod("IntersectWith", (BindingFlags.Public Or BindingFlags.Instance), Nothing, types1, Nothing)
PlatformCompatibilityExtensionMethods.intersectWithMethod2 = GetType(Entity).GetMethod("IntersectWith", (BindingFlags.Public Or BindingFlags.Instance), Nothing, types2, Nothing)
End Sub
<Extension()> _
Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal points As Point3dCollection) As Integer
Dim start As Integer = points.Count
Dim args As Object() = Nothing
If (IntPtr.Size > 4) Then
args = New Object() {other, intersectType, points, CLng(0), CLng(0)}
Else
args = New Object() {other, intersectType, points, CInt(0), CInt(0)}
End If
PlatformCompatibilityExtensionMethods.intersectWithMethod1.Invoke(Nothing, _
(BindingFlags.NonPublic Or BindingFlags.Static), Nothing, args, Nothing)
Return (points.Count - start)
End Function
<Extension()> _
Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal plane As Plane, ByVal points As Point3dCollection) As Integer
Dim start As Integer = points.Count
Dim args As Object() = Nothing
If (IntPtr.Size > 4) Then
args = New Object() {other, intersectType, plane, points, CLng(0), CLng(0)}
Else
args = New Object() {other, intersectType, plane, points, CInt(0), CInt(0)}
End If
PlatformCompatibilityExtensionMethods.intersectWithMethod2.Invoke(Nothing, _
(BindingFlags.NonPublic Or BindingFlags.Static), Nothing, args, Nothing)
Return (points.Count - start)
End Function
<Extension()> _
Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal points As Point3dCollection, ByVal thisGsMarker As IntPtr, ByVal otherGsMarker As IntPtr) As Integer
Dim start As Integer = points.Count
Dim args As Object() = Nothing
If (IntPtr.Size > 4) Then
args = New Object() {other, intersectType, points, thisGsMarker.ToInt64, otherGsMarker.ToInt64}
Else
args = New Object() {other, intersectType, points, thisGsMarker.ToInt32, otherGsMarker.ToInt32}
End If
PlatformCompatibilityExtensionMethods.intersectWithMethod1.Invoke(Nothing, _
(BindingFlags.NonPublic Or BindingFlags.Static), Nothing, args, Nothing)
Return (points.Count - start)
End Function
<Extension()> _
Public Function IntersectWith(ByVal entity As Entity, ByVal other As Entity, ByVal intersectType As Intersect, ByVal plane As Plane, ByVal points As Point3dCollection, ByVal thisGsMarker As IntPtr, ByVal otherGsMarker As IntPtr) As Integer
Dim start As Integer = points.Count
Dim args As Object() = Nothing
If (IntPtr.Size > 4) Then
args = New Object() {other, intersectType, plane, points, thisGsMarker.ToInt64, otherGsMarker.ToInt64}
Else
args = New Object() {other, intersectType, plane, points, thisGsMarker.ToInt32, otherGsMarker.ToInt32}
End If
PlatformCompatibilityExtensionMethods.intersectWithMethod2.Invoke(Nothing, _
(BindingFlags.NonPublic Or BindingFlags.Static), Nothing, args, Nothing)
Return (points.Count - start)
End Function
Private intersectWithMethod1 As MethodInfo = Nothing
Private intersectWithMethod2 As MethodInfo = Nothing
End Module