Beispiel #1
0
        public void GetUnarchivedObject_TypeWrappers()
        {
            TestRuntime.AssertXcodeVersion(10, 0);

            NSDictionary <NSString, NSString> testValues = new NSDictionary <NSString, NSString> ((NSString)"1", (NSString)"a");

#if NET
            NSData data = NSKeyedArchiver.GetArchivedData(testValues, true, out NSError error);
#else
            NSData data = NSKeyedArchiver.ArchivedDataWithRootObject(testValues, true, out NSError error);
#endif
            Assert.IsNull(error);

            Type     dictionaryType  = typeof(NSDictionary <NSString, NSString>);
            Class    dictionaryClass = new Class(dictionaryType);
            NSObject o = NSKeyedUnarchiver.GetUnarchivedObject(dictionaryClass, data, out error);
            Assert.IsNotNull(o);
            Assert.IsNull(error, "GetUnarchivedObject - Class");

            o = NSKeyedUnarchiver.GetUnarchivedObject(new NSSet <Class> (new Class [] { dictionaryClass }), data, out error);
            Assert.IsNotNull(o);
            Assert.IsNull(error, "GetUnarchivedObject - NSSet<Class>");

            o = NSKeyedUnarchiver.GetUnarchivedObject(dictionaryType, data, out error);
            Assert.IsNotNull(o);
            Assert.IsNull(error, "GetUnarchivedObject - Type");

            o = NSKeyedUnarchiver.GetUnarchivedObject(new Type [] { dictionaryType }, data, out error);
            Assert.IsNotNull(o);
            Assert.IsNull(error, "GetUnarchivedObject - Type []");
        }
Beispiel #2
0
            public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard)
            {
                var item = new NSPasteboardItem();

                item.SetDataForType(NSKeyedArchiver.GetArchivedData(rowIndexes), DataTypeName);
                pboard.WriteObjects(new[] { item });
                return(true);
            }