// test that the classes do not support the attachments API public void CheckFailAttachments() { // get all tupes that are public, native object but not NSobjects or DispatchSources and that are not interfaces or abstract classes var types = CMClockType.Assembly.GetTypes() .Where(t => !t.IsNotPublic && !CMAttachmentInterfaceType.IsAssignableFrom(t) && NativeObjectInterfaceType.IsAssignableFrom(t) && !t.IsSubclassOf(NSObjectType) && !t.IsSubclassOf(DispatchSourceType) && !t.IsInterface && !t.IsAbstract); foreach (var t in types) { if (Skip(t)) { continue; } var obj = new AttachableNativeObject(GetINativeInstance(t)); Assert.That(obj.Handle, Is.Not.EqualTo(IntPtr.Zero), t.Name + ".Handle"); using (var attch = new CFString("myAttch")) { CMAttachmentMode otherMode; obj.SetAttachment("key", attch, CMAttachmentMode.ShouldNotPropagate); using (var otherAttch = obj.GetAttachment <CFString> ("key", out otherMode)) { obj.RemoveAllAttachments(); Assert.Null(otherAttch, "For type {0}", t.Name); } } if (t is IDisposable) { var disposable = obj as IDisposable; disposable.Dispose(); } } }
public void CheckFailAttachments() { // get all tupes that are public, native object but not NSobjects or DispatchSources and that are not interfaces or abstract classes var types = CMClockType.Assembly.GetTypes () .Where(t => !t.IsNotPublic && !CMAttachmentInterfaceType.IsAssignableFrom(t) && NativeObjectInterfaceType.IsAssignableFrom (t) && !t.IsSubclassOf (NSObjectType) && !t.IsSubclassOf (DispatchSourceType) && !t.IsInterface && !t.IsAbstract); foreach (var t in types) { if (Skip (t)) continue; var obj = new AttachableNativeObject (GetINativeInstance (t)); Assert.That (obj.Handle, Is.Not.EqualTo (IntPtr.Zero), t.Name + ".Handle"); using (var attch = new CFString ("myAttch")) { CMAttachmentMode otherMode; obj.SetAttachment ("key", attch, CMAttachmentMode.ShouldNotPropagate); using (var otherAttch = obj.GetAttachment<CFString> ("key", out otherMode)) { obj.RemoveAllAttachments (); Assert.Null (otherAttch, "For type {0}", t.Name); } } if (t is IDisposable) { var disposable = obj as IDisposable; disposable.Dispose (); } } }