public static Opaque GetOpaque(IntPtr o, Type type, bool owned) { if (o == IntPtr.Zero) { return(null); } Opaque opaque = (Opaque)Activator.CreateInstance(type, new object[] { o }); if (owned) { if (opaque.owned) { // The constructor took a Ref it shouldn't have, so undo it opaque.Unref(o); } opaque.owned = true; } else { opaque = opaque.Copy(o); } return(opaque); }
public static Opaque GetOpaque(IntPtr o, Type type, bool owned) { Opaque opaque = FastActivator.CreateOpaque(o, type); if (owned) { if (opaque.Owned) { // The constructor took a Ref it shouldn't have, so undo it opaque.Unref(o); } opaque.Owned = true; } else { opaque = opaque.Copy(o); } return(opaque); }