Ejemplo n.º 1
0
		public override bool IsEqual (NSObject obj)
		{
			if (obj.GetType () != typeof(MyCollectionViewGridLayoutAttributes))
				return false;

			var other = (MyCollectionViewGridLayoutAttributes)obj;
			if (!base.IsEqual (other))
				return false;

			if (!BackgroundColor.Equals (other.BackgroundColor))
				return false;

			return true;
		}
Ejemplo n.º 2
0
        protected override void CheckNSObjectProtocol(NSObject obj)
        {
            switch (obj.GetType().Name)
            {
            case "NSString":
                // according to bots `isKindOf (null)` returns true before Yosemite
                break;

            case "SBObject":
                // *** NSForwarding: warning: object 0x77a49a0 of class '__NSMessageBuilder' does not implement doesNotRecognizeSelector: -- abort
                break;

            default:
                base.CheckNSObjectProtocol(obj);
                break;
            }
        }
Ejemplo n.º 3
0
        public void AddToLog(NSObject obj)
        {
            if (obj == null)
            {
                return;
            }

            var date = DateTime.Now;

            log = $@"
{date.ToLongTimeString()}
{obj.GetType().Name}:{obj}


{log}
";
        }
Ejemplo n.º 4
0
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            base.PrepareForSegue(segue, sender);

            if (sender.GetType() == typeof(UIButton))
            {
                if (sender == btnViewSplits)
                {
                    var splitsVC = segue.DestinationViewController as SplitsViewController;

                    if (splitsVC != null)
                    {
                        splitsVC.SplitTimes = this.listSplits;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks that the IsDirectBinding property is identical to the IsWrapper property of the Register attribute.
        /// </summary>
        /// <param name="obj">Object.</param>
        protected virtual void CheckIsDirectBinding(NSObject obj)
        {
            var attrib = obj.GetType().GetCustomAttribute <RegisterAttribute> (false);

            // only check types that we register - that way we avoid the 118 MonoTouch.CoreImagge.CI* "special" types
            if (attrib == null)
            {
                return;
            }
            var is_wrapper        = attrib != null && attrib.IsWrapper;
            var is_direct_binding = GetIsDirectBinding(obj);

            if (is_direct_binding != is_wrapper)
            {
                ReportError("{0} : IsDirectBinding (expected {1}, got {2})", instance_type_name, is_wrapper, is_direct_binding);
            }
        }
Ejemplo n.º 6
0
        protected override void CheckToString(NSObject obj)
        {
            switch (obj.GetType().FullName)
            {
            // Crashes on 10.13
            case "MonoMac.AppKit.NSStoryboard":
            case "AppKit.NSStoryboard":
            case "MonoMac.AVFoundation.AVCaptureInputPort":     // https://bugzilla.xamarin.com/show_bug.cgi?id=57668
            case "AVFoundation.AVCaptureInputPort":             // https://bugzilla.xamarin.com/show_bug.cgi?id=57668
            // Crashes on 10.12
            case "Contacts.CNContainer":
            // native crash calling MonoMac.Foundation.NSObject.get_Description ()
            case "WebKit.WKNavigationAction":
            case "WebKit.WKFrameInfo":             //  EXC_BAD_ACCESS (code=1, address=0x0)
            case "MonoMac.Foundation.NSUrlConnection":
            case "Foundation.NSUrlConnection":
            case "MonoMac.AppKit.NSLayoutConstraint":             // Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
            case "AppKit.NSLayoutConstraint":
            case "MonoMac.AVFoundation.AVPlayerItemTrack":
            case "AVFoundation.AVPlayerItemTrack":
            // 10.8
            case "MonoMac.AVFoundation.AVComposition":
            case "AVFoundation.AVComposition":
            case "MonoMac.GameKit.GKPlayer":                               // Crashing on 10.8.3 from the Apple beta channel for abock (on 2013-01-30)
            case "GameKit.GKPlayer":
            case "MonoMac.AVFoundation.AVAssetResourceLoadingRequest":     // Crashing on 10.9.1 for abock (2014-01-13)
            case "AVFoundation.AVAssetResourceLoadingRequest":
            case "MonoMac.AVFoundation.AVAssetResourceLoadingDataRequest": // Crashes on 10.9.3 for chamons (constructor found in AVCompat)
            case "AVFoundation.AVAssetResourceLoadingDataRequest":
            case "MonoMac.AVFoundation.AVCaptureDeviceInputSource":        // Crashes on 10.9.5
            case "AVFoundation.AVCaptureDeviceInputSource":
                break;

            // 11.0
            case "AVFoundation.AVMediaSelection":
            case "AVFoundation.AVMutableMediaSelection":
            case "CoreLocation.CLBeacon":
            case "GameKit.GKTurnBasedMatch":
                break;

            default:
                base.CheckToString(obj);
                break;
            }
        }
        private static void SetPresentationAnchorInternal(UIPopoverPresentationController ppc, NSObject target, NSObject targetOwner)
        {
            TypeSwitch.Do(target,
                          TypeSwitch.Case <UIToolbar>(b => {
                ppc.SourceView = b;
                ppc.SourceRect = b.Bounds;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }),

                          TypeSwitch.Case <UITabBar>(b => {
                ppc.SourceView = b;
                ppc.SourceRect = b.Bounds;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }),
                          TypeSwitch.Case <UITableViewCell>(cvc => {
                if (targetOwner == null || !(targetOwner is UITableView))
                {
                    throw new ArgumentNullException("UITargetReference to UITableViewCell did not contain the UITableView in TargetOwner field ", "targetOwner");
                }
                ppc.SourceView = targetOwner as UITableView;
                ppc.SourceRect = cvc.Frame;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }),
                          TypeSwitch.Case <UICollectionViewCell>(cvc => {
                if (targetOwner == null || !(targetOwner is UICollectionView))
                {
                    throw new ArgumentNullException("UITargetReference to UICollectionViewCell did not contain the UICollectionView in TargetOwner field ", "targetOwner");
                }
                ppc.SourceView = targetOwner as UICollectionView;
                ppc.SourceRect = cvc.Frame;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }),
                          TypeSwitch.Case <UIView>(v => {
                ppc.SourceView = v;
                ppc.SourceRect = v.Bounds;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            }),
                          TypeSwitch.Case <UIBarButtonItem>((Action <UIBarButtonItem>)(b => {
                ppc.BarButtonItem            = b;
                ppc.PermittedArrowDirections = UIPopoverArrowDirection.Any;
            })),
                          TypeSwitch.Default(() => { throw new NotSupportedException(target.GetType().ToString()); })
                          );
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieves a view for our annotations.
        /// </summary>
        /// <param name="mapView"></param>
        /// <param name="annotation"></param>
        /// <returns></returns>
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation)
        {
            if (annotation.GetType() != typeof(ClusterAnnotation))
            {
                return(MapViewViewForAnnotation(mapView, annotation));
            }

            if (((ClusterAnnotation)annotation).Type == ClusterAnnotationType.Leaf)
            {
                return(MapViewViewForAnnotation(mapView, annotation));
            }

            if (((ClusterAnnotation)annotation).Type == ClusterAnnotationType.Cluster)
            {
                return(MapViewViewForClusterAnnotation(mapView, annotation));
            }

            return(null);
        }
Ejemplo n.º 9
0
        public static NSDictionary RemoveNullValues(this NSDictionary dictionary)
        {
            NSMutableDictionary filteredDictionary = new NSMutableDictionary();

            foreach (var key in dictionary.Keys)
            {
                NSObject nsObject = dictionary.ObjectForKey(key);
                if (nsObject.Description == "<null>")
                {
                    continue;
                }
                if (nsObject.GetType() == typeof(NSDictionary))
                {
                    nsObject = ((NSDictionary)nsObject).RemoveNullValues();
                }
                filteredDictionary.Add(key, nsObject);
            }

            return(filteredDictionary);
        }
Ejemplo n.º 10
0
 protected override void CheckHandle(NSObject obj)
 {
     bool result = obj.Handle != IntPtr.Zero;
     if (!result) {
         string name = obj.GetType ().Name;
         switch (name) {
         // FIXME: it's not clear what's the alternative to 'init' and it could be because I have no phone device
         case "CTCallCenter":
         case "CTTelephonyNetworkInfo":
             return;
         // to avoid crashes we do not really create (natively) default instances (iOS gives them to us)
         // for compatibility purpose - we should never had included the default .ctor in monotouch.dll
         case "CAMediaTimingFunction":
         case "CLHeading":
         case "CLRegion":
         case "CLPlacemark":
         case "CMAccelerometerData":
         case "CMLogItem":
         case "CMAttitude":
         case "CMDeviceMotion":
         case "CMGyroData":
         case "CMMagnetometerData":
             return;
         // under iOS5 only - MPMediaPickerController: Unable to access iPod library.
         case "MPMediaPickerController":
             return;
         // re-enabled as an [Obsolete ("", true)] but it will crash if we create it (which we can since we use reflection)
         case "NSTimer":
         case "NSCompoundPredicate":
             return;
         // iOS9 - the instance was "kind of valid" before
         case "PKPaymentAuthorizationViewController":
             if (CheckiOSSystemVersion (9,0))
                 return;
             break;
         }
         base.CheckHandle (obj);
     }
 }
Ejemplo n.º 11
0
        public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            NSObject annotationType = ObjCRuntime.Runtime.GetNSObject(annotation.Handle);

            if (annotationType.GetType() == typeof(MKPointAnnotation))
            {
                return(new MKAnnotationView(annotation, "me")
                {
                    Image = UIImage.FromBundle("monkey.png")
                });
            }

            string resuseId = annotation is StoreAnnotation ? "pin" : "cluster";
            var    pinView  = mapView.DequeueReusableAnnotation(resuseId);

            if (pinView == null)
            {
                if (annotation is StoreAnnotation)
                {
                    pinView              = new MKAnnotationView(annotation, "pin");
                    pinView.Image        = UIImage.FromBundle("banana_pin.png");
                    pinView.CenterOffset = new CoreGraphics.CGPoint(0, -20);

                    pinView.CanShowCallout            = true;
                    pinView.LeftCalloutAccessoryView  = new UIImageView(UIImage.FromBundle("banana.png"));
                    pinView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);
                }
                else
                {
                    pinView = new MKMarkerAnnotationView(annotation, "cluster");
                }
            }
            else
            {
                pinView.Annotation = annotation;
            }
            pinView.ClusteringIdentifier = "banana";
            return(pinView);
        }
Ejemplo n.º 12
0
        public override void ToXml(XmlElement element)
        {
            AddAttribute(element, "type", ResultObject.GetType().ToString());
            AddAttribute(element, "fulltype", ResultObject.GetType().FullName);

            NSView view = ResultObject as NSView;

            if (view == null)
            {
                return;
            }

            if (view.Identifier != null)
            {
                AddAttribute(element, "name", view.Identifier);
            }

            // In Cocoa the attribute is Hidden as opposed to Gtk's Visible.
            AddAttribute(element, "visible", (!view.Hidden).ToString());
            AddAttribute(element, "allocation", view.Frame.ToString());
        }
Ejemplo n.º 13
0
        // Gets the string for the text field from the object passed in.
        public override string StringFor(NSObject value)
        {
            // Not a color?
            if (value.GetType() != typeof(NSColor))
            {
                return(null);
            }

            // Convert to an RGB color space
            NSColor color = ((NSColor)value).UsingColorSpace(NSColorSpace.CalibratedRGB);

            // Get components as floats between 0 and 1
            nfloat red, green, blue, alpha;

            color.GetRgba(out red, out green, out blue, out alpha);

            // Initialize the distance to something large
            double minDistance = 3.0f;
            string closestKey  = "";

            // Find the closest color
            foreach (string key in colorList.AllKeys())
            {
                NSColor c = colorList.ColorWithKey(key);
                nfloat  r, g, b, a;
                c.GetRgba(out r, out g, out b, out a);

                // How far apart are color and c?
                double distance = (Math.Pow(red - r, 2) + Math.Pow(green - g, 2) + Math.Pow(blue - b, 2));
                // Is this the closest yet?
                if (distance < minDistance)
                {
                    minDistance = distance;
                    closestKey  = key;
                }
            }
            return(closestKey);
        }
Ejemplo n.º 14
0
        public static object ToFieldValue(this NSObject fieldValue, Type type)
        {
            if (fieldValue == null)
            {
                return(null);
            }

            switch (fieldValue)
            {
            case NSNumber number:
                if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    type = type.GenericTypeArguments[0];
                }

                if (type == typeof(bool))
                {
                    return(number.BoolValue);
                }
                if (type == typeof(byte))
                {
                    return(number.ByteValue);
                }
                if (type == typeof(double))
                {
                    return(number.DoubleValue);
                }
                if (type == typeof(float))
                {
                    return(number.FloatValue);
                }
                if (type == typeof(int))
                {
                    return(number.Int32Value);
                }
                if (type == typeof(long))
                {
                    return(number.Int64Value);
                }
                if (type == typeof(sbyte))
                {
                    return(number.SByteValue);
                }
                if (type == typeof(short))
                {
                    return(number.Int16Value);
                }
                if (type == typeof(uint))
                {
                    return(number.UInt32Value);
                }
                if (type == typeof(ulong))
                {
                    return(number.UInt64Value);
                }
                if (type == typeof(ushort))
                {
                    return(number.UInt16Value);
                }
                return(Convert.ChangeType(number.DoubleValue, type));

            case NSString @string:
                return(@string.ToString());

            case Timestamp timestamp:
            {
                var dateTimeOffset = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero).AddMilliseconds(timestamp.Seconds * 1000 + timestamp.Nanoseconds / 1000000);
                if (type == typeof(DateTime) || type == typeof(DateTime?))
                {
                    return(dateTimeOffset.LocalDateTime);
                }
                return(dateTimeOffset);
            }

            case NSDate date:
            {
                var dateTimeOffset = new DateTimeOffset(2001, 1, 1, 0, 0, 0, TimeSpan.Zero).AddSeconds(date.SecondsSinceReferenceDate);
                if (type == typeof(DateTime) || type == typeof(DateTime?))
                {
                    return(dateTimeOffset.LocalDateTime);
                }
                return(dateTimeOffset);
            }

            case NSArray array:
            {
                IList list;
                if (type.GetInterfaces().Contains(typeof(IList)))
                {
                    list = (IList)Activator.CreateInstance(type);
                }
                else if (type.IsGenericType)
                {
                    var listType = typeof(List <>).MakeGenericType(type.GenericTypeArguments[0]);
                    list = (IList)Activator.CreateInstance(listType);
                }
                else
                {
                    list = new List <object>();
                }

                var genericType = typeof(object);
                if (type.IsGenericType)
                {
                    genericType = type.GenericTypeArguments[0];
                }

                for (nuint i = 0; i < array.Count; i++)
                {
                    list.Add(array.GetItem <NSObject>(i).ToFieldValue(genericType));
                }
                return(list);
            }

            case NSDictionary dictionary:
            {
                object @object;
                if (type == typeof(object))
                {
                    @object = new Dictionary <string, object>();
                }
                else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary <,>))
                {
                    var dictionaryType = typeof(Dictionary <,>).MakeGenericType(type.GenericTypeArguments[0], type.GenericTypeArguments[1]);
                    @object = Activator.CreateInstance(dictionaryType);
                }
                else
                {
                    @object = Activator.CreateInstance(type);
                }

                if (@object is IDictionary dict)
                {
                    var genericType = typeof(object);
                    if (type.IsGenericType)
                    {
                        genericType = type.GenericTypeArguments[1];
                    }

                    foreach (var(key, value) in dictionary)
                    {
                        dict.Add(key.ToString(), value.ToFieldValue(genericType));
                    }
                }
                else
                {
                    var properties       = type.GetProperties();
                    var mappedProperties = properties.Select(p => (Property: p, Attribute: Attribute.GetCustomAttribute(p, typeof(MapToAttribute)) as MapToAttribute))
                                           .Where(t => t.Attribute != null)
                                           .ToDictionary(t => t.Attribute.Mapping, t => t.Property);
                    var igonoredProperties = properties.Where(p => Attribute.GetCustomAttribute(p, typeof(IgnoredAttribute)) != null);

                    foreach (var(key, value) in dictionary)
                    {
                        PropertyInfo property;
                        if (mappedProperties.ContainsKey(key.ToString()))
                        {
                            property = mappedProperties[key.ToString()];
                        }
                        else
                        {
                            property = type.GetProperty(key.ToString());
                        }

                        if (property != null && !igonoredProperties.Contains(property))
                        {
                            property.SetValue(@object, value.ToFieldValue(property.PropertyType));
                        }
                    }
                }
                return(@object);
            }

            case NSData data:
                if (type == typeof(byte[]))
                {
                    return(data.ToArray());
                }
                return(new MemoryStream(data.ToArray()));

            case Firebase.CloudFirestore.GeoPoint geoPoint:
                return(new GeoPoint(geoPoint.Latitude, geoPoint.Longitude));

            case Firebase.CloudFirestore.DocumentReference documentReference:
                return(new DocumentReferenceWrapper(documentReference));

            case NSNull @null:
                return(null);

            default:
                throw new ArgumentOutOfRangeException($"{fieldValue.GetType().FullName} is not supported");
            }
        }
Ejemplo n.º 15
0
        protected override void CheckToString(NSObject obj)
        {
            string name = obj.GetType().Name;

            switch (name)
            {
            // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /mono/ios/monotouch-ios7/monotouch/src/Foundation/NSObject.g.cs:500
            case "SKTexture":
            case "MCSession":
            // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.g.cs:554
            case "AVPlayerItemTrack":
            case "AVCaptureConnection":
                return;

            // worked before ios6.0 beta 1
            case "AVComposition":
            // new API in iOS7
            case "AVAssetResourceLoadingDataRequest":
            // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
            case "NSLayoutConstraint":
            // new in 6.0
            case "AVAssetResourceLoadingRequest":
            case "GKScoreChallenge":             // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[GKScoreChallenge challengeID]: unrecognized selector sent to instance 0x18acc340
            case "GKAchievementChallenge":       // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[GKAchievementChallenge challengeID]: unrecognized selector sent to instance 0x160f4840
                if (TestRuntime.CheckXcodeVersion(4, 5))
                {
                    return;
                }
                break;

            // iOS 9 beta 1 - crash when called
            case "WKFrameInfo":
            case "WKNavigation":
            case "WKNavigationAction":
                if (TestRuntime.CheckXcodeVersion(7, 0))
                {
                    return;
                }
                break;

            // new iOS 10 beta 1 - crash when calling `description` selector
            case "AVAudioSessionDataSourceDescription":
            case "AVAudioSessionPortDescription":
            case "CLBeacon":
            case "CLCircularRegion":
            // beta 2
            case "CTCallCenter":
            // beta 3
            case "CNContainer":
                if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    return;
                }
                break;

            // Xcode 9 Beta 1 to avoid crashes
            case "CIImageAccumulator":
                if (TestRuntime.CheckXcodeVersion(9, 0))
                {
                    return;
                }
                break;

            default:
                base.CheckToString(obj);
                break;
            }
        }
Ejemplo n.º 16
0
        public static void TestWrap()
        {
            bool     bl   = true;
            byte     byt  = 24;
            short    shrt = 12;
            int      i    = 42;
            long     lng  = 30000000000L;
            float    flt  = 124.3f;
            double   dbl  = 32.0;
            DateTime date = new DateTime();
            string   strg = "Hello World";

            byte[]        bytes  = new byte[] { (byte)0x00, (byte)0xAF, (byte)0xAF };
            Object[]      array  = new Object[] { bl, byt, shrt, i, lng, flt, dbl, date, strg, bytes };
            int[]         array2 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3000 };
            List <Object> list   = new List <Object>(array);

            Dictionary <string, Object> map = new Dictionary <string, Object>();

            map.Add("int", i);
            map.Add("long", lng);
            map.Add("date", date);

            NSObject WrappedO = NSObject.Wrap((Object)bl);

            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True(WrappedO.ToObject().Equals(bl));

            WrappedO = NSObject.Wrap((Object)byt);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((int)WrappedO.ToObject() == byt);

            WrappedO = NSObject.Wrap((Object)shrt);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((int)WrappedO.ToObject() == shrt);

            WrappedO = NSObject.Wrap((Object)i);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((int)WrappedO.ToObject() == i);

            WrappedO = NSObject.Wrap((Object)lng);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((long)WrappedO.ToObject() == lng);

            WrappedO = NSObject.Wrap((Object)flt);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((double)WrappedO.ToObject() == flt);

            WrappedO = NSObject.Wrap((Object)dbl);
            Assert.True(WrappedO.GetType().Equals(typeof(NSNumber)));
            Assert.True((double)WrappedO.ToObject() == dbl);

            WrappedO = NSObject.Wrap((Object)date);
            Assert.True(WrappedO.GetType().Equals(typeof(NSDate)));
            Assert.True(((DateTime)WrappedO.ToObject()).Equals(date));

            WrappedO = NSObject.Wrap((Object)strg);
            Assert.True(WrappedO.GetType().Equals(typeof(NSString)));
            Assert.True(((string)WrappedO.ToObject()).Equals(strg));

            WrappedO = NSObject.Wrap((Object)bytes);
            Assert.True(WrappedO.GetType().Equals(typeof(NSData)));
            byte[] data = (byte[])WrappedO.ToObject();
            Assert.True(data.Length == bytes.Length);
            for (int x = 0; x < bytes.Length; x++)
            {
                Assert.True(data[x] == bytes[x]);
            }

            WrappedO = NSObject.Wrap((Object)array);
            Assert.True(WrappedO.GetType().Equals(typeof(NSArray)));
            Object[] objArray = (Object[])WrappedO.ToObject();
            Assert.True(objArray.Length == array.Length);

            WrappedO = NSObject.Wrap((Object)array2);
            Assert.True(WrappedO.GetType().Equals(typeof(NSArray)));
            Assert.True(((NSArray)WrappedO).Count == array2.Length);

            WrappedO = NSObject.Wrap((Object)list);
            Assert.True(WrappedO.GetType().Equals(typeof(NSArray)));
            objArray = (Object[])WrappedO.ToObject();
            Assert.True(objArray.Length == array.Length);

            WrappedO = NSObject.Wrap((Object)map);
            Assert.True(WrappedO.GetType().Equals(typeof(NSDictionary)));
            NSDictionary dict = (NSDictionary)WrappedO;

            Assert.True(((NSNumber)dict.ObjectForKey("int")).ToLong() == i);
            Assert.True(((NSNumber)dict.ObjectForKey("long")).ToLong() == lng);
            Assert.True(((NSDate)dict.ObjectForKey("date")).Date.Equals(date));

            // TODO

            /*
             * Object unWrappedO = WrappedO.ToObject();
             * Map map2 = (Map)unWrappedO;
             * Assert.True(((int)map.get("int")) == i);
             * Assert.True(((long)map.get("long")) == lng);
             * Assert.True(((DateTime)map.get("date")).Equals(date));*/
        }
Ejemplo n.º 17
0
 public override void SaveDocument(NSObject delegateObject, MonoMac.ObjCRuntime.Selector didSaveSelector, IntPtr contextInfo)
 {
     Logger.Debug("Not sure what this is doing yet SaveDocument {0}", delegateObject.GetType());
     SaveData();
 }
Ejemplo n.º 18
0
 public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
 {
     //photoDetailController controller = segue.DestinationViewController as photoDetailController;
     Console.WriteLine ("Preparing for segue: " + segue.ToString ());
     Console.WriteLine ("From object: " + sender.GetType ().ToString ());
 }
Ejemplo n.º 19
0
        public static void AddBundleURLType(IIgorModule ModuleInst, string PlistPath, string NewURLScheme)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            NSSet BundleURLTypes = null;

                            if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                            {
                                NSObject BundleURLTypesObj = RootDictionary.Get("CFBundleURLTypes");

                                if (IgorAssert.EnsureTrue(ModuleInst, BundleURLTypesObj != null, "CFBundleURLTypes wasn't found in the root dictionary even though the key exists."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(BundleURLTypesObj.GetType()), "CFBundleURLTypes isn't an NSArray."))
                                    {
                                        BundleURLTypes = new NSSet(((NSArray)BundleURLTypesObj).GetArray());
                                    }
                                }
                            }

                            if (BundleURLTypes == null)
                            {
                                BundleURLTypes = new NSSet();
                            }

                            bool bAlreadyExists = false;

                            foreach (NSObject CurrentURLType in BundleURLTypes)
                            {
                                if (bAlreadyExists)
                                {
                                    break;
                                }

                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(CurrentURLType.GetType()), "One of the CFBundleURLTypes isn't an NSDictionary."))
                                {
                                    NSDictionary CurrentURLTypeDict = (NSDictionary)CurrentURLType;

                                    if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLTypeDict != null, "One of the CFBundleURLTypes didn't cast to NSDictionary correctly."))
                                    {
                                        if (CurrentURLTypeDict.ContainsKey("CFBundleURLSchemes"))
                                        {
                                            NSObject CurrentURLSchemesArrayObj = CurrentURLTypeDict.Get("CFBundleURLSchemes");

                                            if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(CurrentURLSchemesArrayObj.GetType()), "A CFBundleURLSchemes key exists for a given CFBundleURLType, but it's not an NSArray type."))
                                            {
                                                NSArray CurrentURLSchemesArray = (NSArray)CurrentURLSchemesArrayObj;

                                                if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLSchemesArray != null, "The CFBundleURLSchemes object didn't cast to NSDictionary correctly."))
                                                {
                                                    NSSet CurrentURLSchemesSet = new NSSet(CurrentURLSchemesArray.GetArray());

                                                    foreach (NSObject CurrentURLSchemeObj in CurrentURLSchemesSet)
                                                    {
                                                        if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(CurrentURLSchemeObj.GetType()), "One of the CFBundleURLSchemes is not an NSString."))
                                                        {
                                                            NSString CurrentURLScheme = (NSString)CurrentURLSchemeObj;

                                                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLScheme != null, "A CFBundleURLScheme entry didn't cast to NSString correctly."))
                                                            {
                                                                if (CurrentURLScheme.GetContent() == NewURLScheme)
                                                                {
                                                                    bAlreadyExists = true;

                                                                    IgorDebug.Log(ModuleInst, "URL scheme " + NewURLScheme + " is already in " + PlistPath);

                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (!bAlreadyExists)
                            {
                                NSString NewSchemeString = new NSString(NewURLScheme);

                                NSArray NewSchemeArray = new NSArray(1);

                                NewSchemeArray.SetValue(0, NewSchemeString);

                                NSDictionary NewTypeDictionary = new NSDictionary();

                                NewTypeDictionary.Add("CFBundleURLSchemes", NewSchemeArray);

                                BundleURLTypes.AddObject(NewTypeDictionary);

                                NSArray BundleURLTypesArray = new NSArray(BundleURLTypes.AllObjects());

                                if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                                {
                                    RootDictionary["CFBundleURLTypes"] = BundleURLTypesArray;

                                    IgorDebug.Log(ModuleInst, "Updated CFBundleURLTypes to add " + NewURLScheme + ".");
                                }
                                else
                                {
                                    RootDictionary.Add("CFBundleURLTypes", BundleURLTypesArray);

                                    IgorDebug.Log(ModuleInst, "Added CFBundleURLTypes to add " + NewURLScheme + ".");
                                }

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public static void AddRequiredDeviceCapability(IIgorModule ModuleInst, string PlistPath, string NewRequiredDeviceCapability)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey("UIRequiredDeviceCapabilities"), "Can't find UIRequiredDeviceCapabilities in plist."))
                            {
                                NSObject DeviceCapabilities = RootDictionary.Get("UIRequiredDeviceCapabilities");

                                if (IgorAssert.EnsureTrue(ModuleInst, DeviceCapabilities != null, "Plist does not contain UIRequiredDeviceCapabilities."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(DeviceCapabilities.GetType()), "Plist UIRequiredDeviceCapabilities is not an array."))
                                    {
                                        NSArray CapabilitiesArray = (NSArray)DeviceCapabilities;

                                        if (IgorAssert.EnsureTrue(ModuleInst, CapabilitiesArray != null, "UIRequiredDeviceCapabilities is not an array."))
                                        {
                                            if (CapabilitiesArray.ContainsObject(new NSString(NewRequiredDeviceCapability)))
                                            {
                                                IgorDebug.Log(ModuleInst, "UIRequiredDeviceCapabilities already contains " + NewRequiredDeviceCapability);
                                            }
                                            else
                                            {
                                                NSSet NewCapabilitiesSet = new NSSet(CapabilitiesArray.GetArray());

                                                NewCapabilitiesSet.AddObject(new NSString(NewRequiredDeviceCapability));

                                                NSArray NewCapabilitiesArray = new NSArray(NewCapabilitiesSet.AllObjects());

                                                RootDictionary["UIRequiredDeviceCapabilities"] = NewCapabilitiesArray;

                                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                                IgorDebug.Log(ModuleInst, NewRequiredDeviceCapability + " added to UIRequiredDeviceCapabilities.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
 protected override void CheckNSObjectProtocol(NSObject obj)
 {
     switch (obj.GetType ().Name) {
     case "NSString":
         // according to bots `isKindOf (null)` returns true before iOS 8, ref: #36726
         if (!CheckiOSOrTVOSSystemVersion (8, 0))
             return;
         break;
     }
     base.CheckNSObjectProtocol (obj);
 }
Ejemplo n.º 22
0
 protected override void CheckToString(NSObject obj)
 {
     string name = obj.GetType ().Name;
     switch (name) {
     // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /mono/ios/monotouch-ios7/monotouch/src/Foundation/NSObject.g.cs:500
     case "SKTexture":
     case "MCSession":
     // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.g.cs:554
     case "AVPlayerItemTrack":
     case "AVCaptureConnection":
         return;
     // worked before ios6.0 beta 1
     case "AVComposition":
     // new API in iOS7
     case "AVAssetResourceLoadingDataRequest":
     // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
     case "NSLayoutConstraint":
     // new in 6.0
     case "AVAssetResourceLoadingRequest":
     case "GKScoreChallenge": // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[GKScoreChallenge challengeID]: unrecognized selector sent to instance 0x18acc340
     case "GKAchievementChallenge": // Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[GKAchievementChallenge challengeID]: unrecognized selector sent to instance 0x160f4840
         if (CheckiOSOrTVOSSystemVersion (6,0))
             return;
         break;
     // crash (when asking `description`) under iOS5 (only) simulator
     case "NSUrlConnection":
         return;
     // iOS 9 beta 1 - crash when called
     case "WKFrameInfo":
     case "WKNavigation":
     case "WKNavigationAction":
         if (CheckiOSSystemVersion (9,0))
             return;
         break;
     default:
         base.CheckToString (obj);
         break;
     }
 }
Ejemplo n.º 23
0
        public static string GetStringValue(IIgorModule ModuleInst, string PlistPath, string StringKey)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey(StringKey), "Plist does not contain " + StringKey + " in root dictionary."))
                            {
                                NSObject StringObj = RootDictionary.ObjectForKey(StringKey);

                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(StringObj.GetType()), "Plist key " + StringKey + " is not a string type."))
                                {
                                    NSString StringValue = (NSString)StringObj;

                                    if (IgorAssert.EnsureTrue(ModuleInst, StringValue != null, "Plist key " + StringKey + " could not be cast to an NSString."))
                                    {
                                        return(StringValue.GetContent());
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return("");
        }
Ejemplo n.º 24
0
			static void Write (string desc, NSObject value)
			{
				Console.Write ("# Extra Tests: {0}={1}", desc, value);
				Console.Write ("; Null? {0}; Type={1}", value == null, value == null ? "<none>" : value.GetType().Name);
				Console.WriteLine ();
			}
        public static object ConvertToObject(NSObject obj)
        {
            object val = null;

            if (obj != null)
            {
                if (obj is NSString)
                {
                    string s = obj.ToString();

                    //allows us to persist datetimes with offsets in a roundtrippable format (NSDate doesn't do timezones)
                    DateTimeOffset dt;
                    if (DateTimeOffset.TryParse(s, out dt))
                    {
                        return(dt);
                    }

                    return(s);
                }
                else if (obj is NSDate)
                {
                    return(DateTimeOffsetHelper.FromNSDate((NSDate)obj));
                }
                else if (obj is NSUuid)
                {
                    return(new Guid(((NSUuid)obj).GetBytes()));
                }
                else if (obj is NSDecimalNumber)
                {
                    return(decimal.Parse(obj.ToString(), CultureInfo.InvariantCulture));
                }
                else if (obj is NSNumber)
                {
                    var x = (NSNumber)obj;
                    switch (x.ObjCType)
                    {
                    case "c":
                        return(x.BoolValue);

                    case "l":
                    case "i":
                        return(x.Int32Value);

                    case "s":
                        return(x.Int16Value);

                    case "q":
                        return(x.Int64Value);

                    case "Q":
                        return(x.UInt64Value);

                    case "C":
                        return(x.ByteValue);

                    case "L":
                    case "I":
                        return(x.UInt32Value);

                    case "S":
                        return(x.UInt16Value);

                    case "f":
                        return(x.FloatValue);

                    case "d":
                        return(x.DoubleValue);

                    case "B":
                        return(x.BoolValue);

                    default:
                        return(x.ToString());
                    }
                }
                else if (obj.GetType() == typeof(NSDate))
                {
                    val = DateTimeOffsetHelper.FromNSDate((NSDate)obj);
                }
                else if (obj is NSArray)
                {
                    NSArray  array  = obj as NSArray;
                    object[] oarray = new object[array.Count];
                    for (int i = 0; i < (int)array.Count; i++)
                    {
                        oarray[i] = ConvertToObject(array.GetItem <NSObject>((nuint)i));
                    }
                    val = oarray;
                }
                else if (obj is NSNull)
                {
                    val = null;
                }
                else
                {
                    val = obj;
                }
            }

            return(val);
        }
Ejemplo n.º 26
0
        // Gets the string for the text field from the object passed in.
        public override string StringFor(NSObject value)
        {
            // Not a color?
            if (value.GetType() != typeof(NSColor)) {
                return null;
            }

            // Convert to an RGB color space
            NSColor color = ((NSColor)value).UsingColorSpace(NSColorSpace.CalibratedRGB);

            // Get components as floats between 0 and 1
            nfloat red, green, blue, alpha;
            color.GetRgba(out red, out green, out blue, out alpha);

            // Initialize the distance to something large
            double minDistance = 3.0f;
            string closestKey = "";

            // Find the closest color
            foreach (string key in colorList.AllKeys()) {
                NSColor c = colorList.ColorWithKey(key);
                nfloat r, g, b, a;
                c.GetRgba(out r, out g, out b, out a);

                // How far apart are color and c?
                double distance = (Math.Pow(red - r, 2) + Math.Pow(green - g, 2) + Math.Pow(blue - b, 2));
                // Is this the closest yet?
                if (distance < minDistance) {
                    minDistance = distance;
                    closestKey = key;
                }

            }
            return closestKey;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Helper method that converts an <see cref="NSObject"/> into
        /// the specified <see cref="Type"/>. It uses reflection to inspect
        /// the properties on <paramref name="type"/> and materializes
        /// an instance of the type, populated with the contents of an <see cref="NSDictionary"/>.
        /// </summary>
        public static object ToObject(NSObject root, Type type)
        {
            InvalidCastException InvalidType() => new(
                $"Unable to bind '{root.GetType()}' to collection type '{type}'"
                );

            if (type == typeof(byte[]) && root is NSData nsData)
            {
                return(nsData.Bytes);
            }

            if (root is NSSet nsSet)
            {
                var elementType = GetElementType(type);
                if (elementType == null)
                {
                    throw InvalidType();
                }

                var set = (IList)Activator.CreateInstance(typeof(HashSet <>).MakeGenericType(elementType)) !;
                foreach (NSObject nsObject in nsSet)
                {
                    set.Add(ToObject(nsObject, elementType));
                }

                return(set);
            }

            if (root is NSArray nsArray)
            {
                var elementType = GetElementType(type);
                if (elementType == null)
                {
                    throw InvalidType();
                }

                var list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(elementType)) !;
                for (int i = 0; i < nsArray.Count; i++)
                {
                    list.Add(ToObject(nsArray[i], elementType));
                }

                return(list);
            }

            if (root is NSNumber nsNumber)
            {
                if (type == typeof(bool))
                {
                    return(nsNumber.ToBool());
                }

                if (type == typeof(double))
                {
                    return(nsNumber.ToDouble());
                }

                if (type == typeof(float))
                {
                    return(nsNumber.floatValue());
                }

                if (type == typeof(int))
                {
                    return(nsNumber.ToInt());
                }

                if (type == typeof(long))
                {
                    return(nsNumber.ToLong());
                }

                throw InvalidType();
            }

            if (root is NSString nsString)
            {
                if (type == typeof(string))
                {
                    return(nsString.Content);
                }

                throw InvalidType();
            }

            if (root is NSDate nsDate)
            {
                if (type == typeof(DateTime))
                {
                    return(nsDate.Date);
                }

                throw InvalidType();
            }

            if (root is NSDictionary nsDictionary)
            {
                if (type.IsPrimitive)
                {
                    // can't convert a dictionary to a primitive type
                    throw InvalidType();
                }

                var elementType = GetDictionaryValueType(type);
                if (elementType != null)
                {
                    var dict = (IDictionary)Activator.CreateInstance(
                        typeof(Dictionary <,>).MakeGenericType(typeof(string), elementType)
                        ) !;
                    foreach (var kvp in nsDictionary)
                    {
                        dict.Add(kvp.Key, ToObject(kvp.Value, elementType));
                    }

                    return(dict);
                }

                // construct an object that we can use
                // and populate its properties
                var instance = Activator.CreateInstance(type) !;
                foreach (var property in type.GetProperties(PropertyFlags))
                {
                    if (!property.CanWrite)
                    {
                        continue;
                    }

                    var name           = property.Name;
                    var dataMemberAttr = property.GetCustomAttribute <DataMemberAttribute>();
                    if (dataMemberAttr?.Name != null)
                    {
                        name = dataMemberAttr.Name;
                    }

                    if (nsDictionary.TryGetValue(name, out var nsObject))
                    {
                        property.SetValue(instance, ToObject(nsObject, property.PropertyType));
                    }
                }

                return(instance);
            }

            throw InvalidType();
        }
Ejemplo n.º 28
0
		partial void Scrub (NSObject sender)
		{
			if(sender.GetType() == typeof(UISlider) && !IsSeeking)
			{
				IsSeeking = true;
				UISlider slider = (UISlider)sender;

				CMTime playerDuration = _playerItem.Duration;
				if(playerDuration == CMTime.Invalid){
					return;
				}

				double duration = playerDuration.Seconds;
				if(!double.IsInfinity(duration) && !double.IsNaN(duration))
				{
					float minValue = slider.MinValue;
					float maxValue = slider.MaxValue;
					float value = slider.Value;

					double time = duration * (value - minValue) / (maxValue - minValue);

					_player.Seek(CMTime.FromSeconds(time, NSEC_PER_SEC), async delegate(bool finished) {
						IsSeeking = false;	
					});

					/*TODO  We can update time labels here */
				}
			}
		}
Ejemplo n.º 29
0
        public static void SetStringValue(IIgorModule ModuleInst, string PlistPath, string StringKey, string Value)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (RootDictionary.ContainsKey(StringKey))
                            {
                                RootDictionary[StringKey] = new NSString(Value);

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " updated to " + Value);
                            }
                            else
                            {
                                RootDictionary.Add(StringKey, new NSString(Value));

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " added with value of " + Value);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
 public override string ToString()
 {
     return(string.Format("NSObject: Type: {0}", ResultObject.GetType().FullName));
 }
Ejemplo n.º 31
0
            /// <inheritdoc />
            public override NSDragOperation ValidateDrop(NSOutlineView outlineView, NSDraggingInfo info, NSObject proposedParentItem, nint index)
            {
                var    operation  = NSDragOperation.None;
                string targetName = "<NULL>";

                if ((proposedParentItem != null) && (index >= 0))
                {
                    var node           = proposedParentItem as NSTreeNode;
                    var proposedParent = node == null ? null : node.GetRepresentedObject() as FileNodeViewModel;
                    if ((node != null) && (proposedParent != null))
                    {
                        var pasteboard = info.DraggingPasteboard;
                        targetName = proposedParent.LongName;
                        if (pasteboard.CanReadItemWithDataConformingToTypes(MenuLayoutPasteboardDataTypeArray))
                        {
                            // Dragging within the menu layout editor.
                            var draggedItems = DragDropHelpers.GetDataForType <IEnumerable <FileNodeViewModel> >(pasteboard, MenuLayoutPasteboardDataTypeArray);
                            if (ShouldAcceptProposedIndex(draggedItems, proposedParent, (int)index) && proposedParent.ShouldAcceptDraggedItems(draggedItems.Select(draggedItem => draggedItem.Model)))
                            {
                                operation = NSDragOperation.Move;
                            }
                        }
                        else if (pasteboard.CanReadItemWithDataConformingToTypes(ProgramDescriptionPasteboardDataTypeArray))
                        {
                            DebugDragDropPrint("OutlineView received drop of ProgramDescriptions!");
                            var draggedItems = DragDropHelpers.GetDataForType <IEnumerable <ProgramDescriptionViewModel> >(pasteboard, ProgramDescriptionPasteboardDataTypeArray);
                            IEnumerable <ProgramDescription> droppedPrograms = ((draggedItems != null) && draggedItems.Any()) ? draggedItems.Select(draggedItem => draggedItem.Model) : null;
                            if (proposedParent.ShouldAcceptDraggedItems(droppedPrograms))
                            {
                                operation = NSDragOperation.Link;
                            }
                        }
                    }
                    else
                    {
                        DebugDragDropPrint("**** OutlineView.ValidateDrop parent not NSTreeNode! Type is: " + proposedParentItem.GetType().FullName);
                    }
                }
                DebugDragDropPrint("**** OutlineView.ValidateDrop index: " + index + ", returning: " + operation);
                return(operation);
            }