// test that the tag classes DO support the attachments API. public void CheckAttachments() { var types = CMClockType.Assembly.GetTypes() .Where(t => CMAttachmentInterfaceType.IsAssignableFrom(t) && !t.IsInterface); foreach (var t in types) { ICMAttachmentBearer obj = GetInstance(t); if (obj is NSObject) { continue; } Assert.That(obj.Handle, Is.Not.EqualTo(IntPtr.Zero), t.Name + ".Handle"); using (var attch = new CFString("myAttch")) { var mode = CMAttachmentMode.ShouldNotPropagate; CMAttachmentMode otherMode; obj.SetAttachment("key", attch, CMAttachmentMode.ShouldNotPropagate); using (var otherAttch = obj.GetAttachment <CFString> ("key", out otherMode)) { obj.RemoveAllAttachments(); Assert.AreEqual(mode, otherMode); Assert.IsNotNull(otherAttch, "For type {0}", t.Name); Assert.AreEqual(attch.ToString(), otherAttch.ToString(), "For type {0}", t.Name); } } if (t is IDisposable) { var disposable = obj as IDisposable; disposable.Dispose(); } } }
public static void RemoveAllAttachments(this ICMAttachmentBearer target) { if (target is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(target)); } CMRemoveAllAttachments(target.Handle); }
public static void RemoveAllAttachments(this ICMAttachmentBearer target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } CMRemoveAllAttachments(target.Handle); }
public static void PropagateAttachments(this ICMAttachmentBearer source, ICMAttachmentBearer destination) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (destination == null) { throw new ArgumentNullException(nameof(destination)); } CMPropagateAttachments(source.Handle, destination.Handle); }
public static void SetAttachments(this ICMAttachmentBearer target, NSDictionary theAttachments, CMAttachmentMode attachmentMode) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (theAttachments == null) { throw new ArgumentNullException(nameof(theAttachments)); } CMSetAttachments(target.Handle, theAttachments.Handle, attachmentMode); }
public static void PropagateAttachments(this ICMAttachmentBearer source, ICMAttachmentBearer destination) { if (source is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(source)); } if (destination is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(destination)); } CMPropagateAttachments(source.Handle, destination.Handle); }
public static void SetAttachments(this ICMAttachmentBearer target, NSDictionary theAttachments, CMAttachmentMode attachmentMode) { if (target is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(target)); } if (theAttachments is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(theAttachments)); } CMSetAttachments(target.Handle, theAttachments.Handle, attachmentMode); }
public static NSDictionary GetAttachments(this ICMAttachmentBearer target, CMAttachmentMode attachmentMode) { if (target == null) { throw new ArgumentNullException(nameof(target)); } var attachments = CMCopyDictionaryOfAttachments(IntPtr.Zero, target.Handle, attachmentMode); if (attachments == IntPtr.Zero) { return(null); } return(Runtime.GetNSObject <NSDictionary> (attachments, true)); }
public static void RemoveAttachment(this ICMAttachmentBearer target, string key) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (key == null) { throw new ArgumentNullException(nameof(key)); } var nsKey = NSString.CreateNative(key); CMRemoveAttachment(target.Handle, nsKey); NSString.ReleaseNative(nsKey); }
public static void RemoveAttachment(this ICMAttachmentBearer target, string key) { if (target is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(target)); } if (key is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(key)); } var nsKey = CFString.CreateNative(key); CMRemoveAttachment(target.Handle, nsKey); CFString.ReleaseNative(nsKey); }
// There is some API that needs a more strongly typed version of a NSDictionary // and there is no easy way to downcast from NSDictionary to NSDictionary<TKey, TValue> public static NSDictionary <TKey, TValue> GetAttachments <TKey, TValue> (this ICMAttachmentBearer target, CMAttachmentMode attachmentMode) where TKey : class, INativeObject where TValue : class, INativeObject { if (target == null) { throw new ArgumentNullException(nameof(target)); } var attachments = CMCopyDictionaryOfAttachments(IntPtr.Zero, target.Handle, attachmentMode); if (attachments == IntPtr.Zero) { return(null); } return(Runtime.GetNSObject <NSDictionary <TKey, TValue> > (attachments, true)); }
public static void SetAttachment(this ICMAttachmentBearer target, string key, INativeObject value, CMAttachmentMode attachmentMode) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (key == null) { throw new ArgumentNullException(nameof(key)); } var nsKey = NSString.CreateNative(key); CMSetAttachment(target.Handle, nsKey, value.Handle, attachmentMode); NSString.ReleaseNative(nsKey); }
public static void SetAttachment(this ICMAttachmentBearer target, string key, INativeObject value, CMAttachmentMode attachmentMode) { if (target is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(target)); } if (value is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(value)); } if (key is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(key)); } var nsKey = CFString.CreateNative(key); CMSetAttachment(target.Handle, nsKey, value.Handle, attachmentMode); CFString.ReleaseNative(nsKey); }
public static T GetAttachment <T> (this ICMAttachmentBearer target, string key, out CMAttachmentMode attachmentModeOut) where T : class, INativeObject { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (key == null) { throw new ArgumentNullException(nameof(key)); } var nsKey = NSString.CreateNative(key); var attchm = CMGetAttachment(target.Handle, nsKey, out attachmentModeOut); NSString.ReleaseNative(nsKey); if (attchm != IntPtr.Zero) { return(Runtime.GetINativeObject <T> (attchm, false)); } return(default(T)); }
public static T GetAttachment <T> (this ICMAttachmentBearer target, CMSampleBufferAttachmentKey key, out CMAttachmentMode attachmentModeOut) where T : class, INativeObject { return(GetAttachment <T> (target, key.GetConstant(), out attachmentModeOut)); }