throw new NotImplementedException ();
}
+#if NET_4_5
+ public static IntPtr CreateAggregatedObject<T> (IntPtr pOuter, T o) {
+ return CreateAggregatedObject (pOuter, (object)o);
+ }
+#endif
+
#if !FULL_AOT_RUNTIME
public static object CreateWrapperOfType (object o, Type t)
{
return ComInteropProxy.GetProxy (co.IUnknown, t).GetTransparentProxy ();
}
+
+#if NET_4_5
+ public static TWrapper CreateWrapperOfType<T, TWrapper> (T o) {
+ return (TWrapper)CreateWrapperOfType ((object)o, typeof (TWrapper));
+ }
+#endif
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ComVisible (true)]
public extern static void DestroyStructure (IntPtr ptr, Type structuretype);
+#if NET_4_5
+ public static void DestroyStructure<T> (IntPtr ptr) {
+ DestroyStructure (ptr, typeof (T));
+ }
+#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void FreeBSTR (IntPtr ptr);
#endif
}
+#if NET_4_5
+ public static IntPtr GetComInterfaceForObject<T, TInterface> (T o) {
+ return GetComInterfaceForObject ((object)o, typeof (T));
+ }
+#endif
+
[MonoTODO]
public static IntPtr GetComInterfaceForObjectInContext (object o, Type t)
{
Marshal.StructureToPtr(vt, pDstNativeVariant, false);
}
+#if NET_4_5
+ public static void GetNativeVariantForObject<T> (T obj, IntPtr pDstNativeVariant) {
+ GetNativeVariantForObject ((object)obj, pDstNativeVariant);
+ }
+#endif
+
#if !MOBILE
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern object GetObjectForCCW (IntPtr pUnk);
return vt.GetValue();
}
+#if NET_4_5
+ public static T GetObjectForNativeVariant<T> (IntPtr pSrcNativeVariant) {
+ Variant vt = (Variant)Marshal.PtrToStructure(pSrcNativeVariant, typeof(Variant));
+ return (T)vt.GetValue();
+ }
+#endif
+
public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars)
{
if (cVars < 0)
return objects;
}
+#if NET_4_5
+ public static T[] GetObjectsForNativeVariants<T> (IntPtr aSrcNativeVariant, int cVars) {
+ if (cVars < 0)
+ throw new ArgumentOutOfRangeException ("cVars", "cVars cannot be a negative number.");
+ T[] objects = new T[cVars];
+ for (int i = 0; i < cVars; i++)
+ objects[i] = GetObjectForNativeVariant<T> ((IntPtr)(aSrcNativeVariant.ToInt64 () +
+ i * SizeOf (typeof(Variant))));
+ return objects;
+ }
+#endif
+
[MonoTODO]
public static int GetStartComSlot (Type t)
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr OffsetOf (Type t, string fieldName);
+#if NET_4_5
+ public static IntPtr OffsetOf<T> (string fieldName) {
+ return OffsetOf (typeof (T), fieldName);
+ }
+#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void Prelink (MethodInfo m);
[ComVisible (true)]
public extern static object PtrToStructure (IntPtr ptr, Type structureType);
+#if NET_4_5
+ public static void PtrToStructure<T> (IntPtr ptr, T structure) {
+ PtrToStructure (ptr, (object)structure);
+ }
+
+ public static object PtrToStructure<T> (IntPtr ptr) {
+ return PtrToStructure (ptr, typeof (T));
+ }
+#endif
+
#if !MOBILE
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static int QueryInterfaceInternal (IntPtr pUnk, ref Guid iid, out IntPtr ppv);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static int SizeOf (Type t);
+#if NET_4_5
+ public static int SizeOf<T> () {
+ return SizeOf (typeof (T));
+ }
+
+ public static int SizeOf<T> (T structure) {
+ return SizeOf (structure.GetType ());
+ }
+#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr StringToBSTR (string s);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void StructureToPtr (object structure, IntPtr ptr, bool fDeleteOld);
+#if NET_4_5
+ public static void StructureToPtr<T> (T structure, IntPtr ptr, bool fDeleteOld) {
+ StructureToPtr ((object)structure, ptr, fDeleteOld);
+ }
+#endif
+
public static void ThrowExceptionForHR (int errorCode) {
Exception ex = GetExceptionForHR (errorCode);
if (ex != null)
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index);
+#if NET_4_5
+ public static IntPtr UnsafeAddrOfPinnedArrayElement<T> (T[] arr, int index) {
+ return UnsafeAddrOfPinnedArrayElement ((Array)arr, index);
+ }
+#endif
+
public static void WriteByte (IntPtr ptr, byte val)
{
unsafe {
return GetDelegateForFunctionPointerInternal (ptr, t);
}
+#if NET_4_5
+ public static Delegate GetDelegateForFunctionPointer<T> (IntPtr ptr) {
+ return GetDelegateForFunctionPointer (ptr, typeof (T));
+ }
+#endif
+
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern IntPtr GetFunctionPointerForDelegateInternal (Delegate d);
return GetFunctionPointerForDelegateInternal (d);
}
+
+#if NET_4_5
+ public static IntPtr GetFunctionPointerForDelegate<TDelegate> (TDelegate d) {
+ if (d == null)
+ throw new ArgumentNullException ("d");
+
+ return GetFunctionPointerForDelegateInternal ((Delegate)(object)d);
+ }
+#endif
}
}