diff --git a/src/UIKit/UIDragDropSessionExtensions.cs b/src/UIKit/UIDragDropSessionExtensions.cs new file mode 100644 index 0000000000..09fba0082d --- /dev/null +++ b/src/UIKit/UIDragDropSessionExtensions.cs @@ -0,0 +1,32 @@ +// +// UIDragDropSessionExtensions.cs +// +// Authors: +// Vincent Dondain +// +// Copyright 2017 Microsoft +// + +#if !TVOS && !WATCH + +using System; +using XamCore.ObjCRuntime; +using XamCore.Foundation; + +namespace XamCore.UIKit { + + public static class UIDragDropSessionExtensions { + + public static NSProgress LoadObjects (this IUIDropSession session, Type type, Action completion) + { + return session.LoadObjects (new Class (type), completion); + } + + public static bool CanLoadObjects (this IUIDragDropSession session, Type type) + { + return session.CanLoadObjects (new Class (type)); + } + } +} + +#endif \ No newline at end of file diff --git a/src/frameworks.sources b/src/frameworks.sources index 39ebdaf4c8..9dcf176ce3 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1320,6 +1320,7 @@ UIKIT_SOURCES = \ UIKit/UIDocumentInteractionController.cs \ UIKit/UIDocumentMenuViewController.cs \ UIKit/UIDocumentPickerViewController.cs \ + UIKit/UIDragDropSessionExtensions.cs \ UIKit/UIDynamicAnimator.cs \ UIKit/UIEnumsExtensions.cs \ UIKit/UIEvent.cs \ diff --git a/src/uikit.cs b/src/uikit.cs index 53204362b2..b3a2bfd95d 100644 --- a/src/uikit.cs +++ b/src/uikit.cs @@ -16204,7 +16204,7 @@ namespace XamCore.UIKit { [Abstract] [Export ("canLoadObjectsOfClass:")] - bool CanLoadObjectsOfClass (Class itemProviderReadingClass); + bool CanLoadObjects (Class itemProviderReadingClass); } [NoWatch, NoTV, iOS (11,0)] @@ -16374,7 +16374,7 @@ namespace XamCore.UIKit { [Abstract] [Export ("loadObjectsOfClass:completion:")] - NSProgress Completion (INSItemProviderReading aClass, Action completion); + NSProgress LoadObjects (Class itemProviderReadingClass, Action completion); } [NoWatch, NoTV, iOS (11,0)] diff --git a/tests/monotouch-test/UIKit/UIDragDropSessionExtensionsTest.cs b/tests/monotouch-test/UIKit/UIDragDropSessionExtensionsTest.cs new file mode 100644 index 0000000000..891e239feb --- /dev/null +++ b/tests/monotouch-test/UIKit/UIDragDropSessionExtensionsTest.cs @@ -0,0 +1,79 @@ +// +// Unit tests for UIDragDropSessionExtensionsTest +// +// Authors: +// Vincent Dondain +// +// +// Copyright 2017 Microsoft. +// + +#if !__TVOS__ && !__WATCHOS__ + +using System; +#if XAMCORE_2_0 +using CoreGraphics; +using Foundation; +using ObjCRuntime; +using UIKit; +#else +using MonoTouch.CoreGraphics; +using MonoTouch.Foundation; +using MonoTouch.ObjCRuntime; +using MonoTouch.UIKit; +#endif +using NUnit.Framework; + +namespace MonoTouchFixtures.UIKit { + [TestFixture] + [Preserve (AllMembers = true)] + public class UIDragDropSessionExtensionsTest { + + [Test] + public void LoadObjectsTest () + { + if (!TestRuntime.CheckXcodeVersion (9,0)) + Assert.Ignore ("Ignoring tests: Requires iOS11+"); + + var test = new DropSession (); + test.CanLoadObjects (typeof (UIImage)); + test.LoadObjects (typeof (UIImage), null); + } + } + + class DropSession : NSObject, IUIDropSession { + public IUIDragSession LocalDragSession => throw new NotImplementedException (); + + public UIDropSessionProgressIndicatorStyle ProgressIndicatorStyle { get => throw new NotImplementedException (); set => throw new NotImplementedException (); } + + public UIDragItem [] Items => throw new NotImplementedException (); + + public bool AllowsMoveOperation => throw new NotImplementedException (); + + public bool RestrictedToDraggingApplication => throw new NotImplementedException (); + + public bool CanLoadObjects (Class itemProviderReadingClass) + { + Assert.That (itemProviderReadingClass.Handle, Is.EqualTo (new Class (typeof (UIImage)).Handle), "UIDragDropSessionExtensionsTest did not convert the type properly for 'CanLoadObjects'."); + return true; + } + + public bool HasConformingItems (string [] typeIdentifiers) + { + throw new NotImplementedException (); + } + + public NSProgress LoadObjects (Class itemProviderReadingClass, Action completion) + { + Assert.That (itemProviderReadingClass.Handle, Is.EqualTo (new Class (typeof (UIImage)).Handle), "UIDragDropSessionExtensionsTest did not convert the type properly for 'LoadObjects'."); + return new NSProgress (); + } + + public CGPoint LocationInView (UIView view) + { + throw new NotImplementedException (); + } + } +} + +#endif // !__TVOS__ && !__WATCHOS__ \ No newline at end of file diff --git a/tests/monotouch-test/monotouch-test.csproj b/tests/monotouch-test/monotouch-test.csproj index 2168bb736b..53c53030c8 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -656,6 +656,7 @@ +