예제 #1
0
        // 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();
                }
            }
        }
예제 #2
0
 public static void RemoveAllAttachments(this ICMAttachmentBearer target)
 {
     if (target is null)
     {
         ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(target));
     }
     CMRemoveAllAttachments(target.Handle);
 }
예제 #3
0
 public static void RemoveAllAttachments(this ICMAttachmentBearer target)
 {
     if (target == null)
     {
         throw new ArgumentNullException(nameof(target));
     }
     CMRemoveAllAttachments(target.Handle);
 }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
        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));
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        // 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));
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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));
        }
예제 #15
0
 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));
 }