-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FileProvider] Add Xcode 9 Beta 1, 2 & 3 Bindings #2279
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
36951e9
[FileProvider] Add Xcode 9 Beta 1 Bindings
dalexsoto 42e75f4
Better naming
dalexsoto fac8d9b
Feedback not related to BindAs
dalexsoto 0be0691
[FileProvider] Removes BindAs, add manual code for it and updated to …
dalexsoto acd1ff8
[FileProvider] Implement feedback
dalexsoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/FileProvider/NSFileProviderItemIdentifierExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// NSFileProviderItemIdentifierExtensions.cs | ||
// | ||
// Authors: | ||
// Alex Soto <[email protected]> | ||
// | ||
// Copyright 2017 Xamarin Inc. All rights reserved. | ||
// | ||
|
||
#if XAMCORE_2_0 | ||
using System; | ||
using XamCore.Foundation; | ||
|
||
namespace XamCore.FileProvider { | ||
public partial class NSFileProviderItemIdentifierExtensions { | ||
|
||
public static NSString[] GetConstants (this NSFileProviderItemIdentifier[] self) | ||
{ | ||
if (self == null) | ||
throw new ArgumentNullException (nameof (self)); | ||
|
||
var array = new NSString [self.Length]; | ||
for (int n = 0; n < self.Length; n++) | ||
array [n] = self [n].GetConstant (); | ||
return array; | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,307 @@ | ||
// | ||
// FileProvider C# bindings | ||
// | ||
// Authors: | ||
// Alex Soto <[email protected]> | ||
// | ||
// Copyright 2017 Xamarin Inc. All rights reserved. | ||
// | ||
|
||
#if XAMCORE_2_0 | ||
|
||
using System; | ||
using XamCore.ObjCRuntime; | ||
using XamCore.CoreGraphics; | ||
using XamCore.Foundation; | ||
|
||
namespace XamCore.FileProvider { | ||
|
||
[iOS (11,0)] | ||
[ErrorDomain ("NSFileProviderErrorDomain")] | ||
[Native] | ||
public enum NSFileProviderError : nint { | ||
NotAuthenticated = -1000, | ||
FilenameCollision = -1001, | ||
SyncAnchorExpired = -1002, | ||
PageExpired = SyncAnchorExpired, | ||
InsufficientQuota = -1003, | ||
ServerUnreachable = -1004, | ||
NoSuchItem = -1005, | ||
} | ||
|
||
[iOS (11,0)] | ||
enum NSFileProviderItemIdentifier { | ||
|
||
[Field ("NSFileProviderRootContainerItemIdentifier")] | ||
RootContainer, | ||
|
||
[Field ("NSFileProviderWorkingSetContainerItemIdentifier")] | ||
WorkingSetContainer, | ||
} | ||
|
||
[iOS (11,0)] | ||
[Native] | ||
[Flags] | ||
public enum NSFileProviderItemCapabilities : nuint { | ||
Reading = 1 << 0, | ||
Writing = 1 << 1, | ||
Reparenting = 1 << 2, | ||
Renaming = 1 << 3, | ||
Trashing = 1 << 4, | ||
Deleting = 1 << 5, | ||
AddingSubItems = Writing, | ||
ContentEnumerating = Reading, | ||
All = Reading | Writing | Reparenting | Renaming | Trashing | Deleting, | ||
} | ||
|
||
[iOS (11,0)] | ||
[DisableDefaultCtor] | ||
[BaseType (typeof (NSObject))] | ||
interface NSFileProviderDomain { | ||
|
||
[Export ("initWithIdentifier:displayName:pathRelativeToDocumentStorage:")] | ||
IntPtr Constructor (string identifier, string displayName, string pathRelativeToDocumentStorage); | ||
|
||
[Export ("identifier")] | ||
string Identifier { get; } | ||
|
||
[Export ("displayName")] | ||
string DisplayName { get; } | ||
|
||
[Export ("pathRelativeToDocumentStorage")] | ||
string PathRelativeToDocumentStorage { get; } | ||
} | ||
|
||
interface INSFileProviderEnumerationObserver { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderEnumerationObserver { | ||
|
||
[Abstract] | ||
[Export ("didEnumerateItems:")] | ||
void DidEnumerateItems (INSFileProviderItem [] updatedItems); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingUpToPage:")] | ||
void FinishEnumerating ([NullAllowed] NSData upToPage); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingWithError:")] | ||
void FinishEnumerating (NSError error); | ||
} | ||
|
||
interface INSFileProviderChangeObserver { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderChangeObserver { | ||
|
||
[Abstract] | ||
[Export ("didUpdateItems:")] | ||
void DidUpdateItems (INSFileProviderItem [] updatedItems); | ||
|
||
[Abstract] | ||
[Export ("didDeleteItemsWithIdentifiers:")] | ||
void DidDeleteItems (string [] deletedItemIdentifiers); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingChangesUpToSyncAnchor:moreComing:")] | ||
void FinishEnumeratingChanges (NSData anchor, bool moreComing); | ||
|
||
[Abstract] | ||
[Export ("finishEnumeratingWithError:")] | ||
void FinishEnumerating (NSError error); | ||
} | ||
|
||
interface INSFileProviderEnumerator { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderEnumerator { | ||
|
||
[Abstract] | ||
[Export ("invalidate")] | ||
void Invalidate (); | ||
|
||
[Abstract] | ||
[Export ("enumerateItemsForObserver:startingAtPage:")] | ||
void EnumerateItems (INSFileProviderEnumerationObserver observer, NSData startPage); | ||
|
||
[Export ("enumerateChangesForObserver:fromSyncAnchor:")] | ||
void EnumerateChanges (INSFileProviderChangeObserver observer, NSData syncAnchor); | ||
|
||
[Export ("currentSyncAnchorWithCompletionHandler:")] | ||
void CurrentSyncAnchor (Action<NSData> completionHandler); | ||
} | ||
|
||
interface INSFileProviderItem { } | ||
|
||
[iOS (11,0)] | ||
[Protocol] | ||
interface NSFileProviderItem { | ||
|
||
[Advice ("Use 'NSFileProviderItemIdentifierExtensions.GetValue (ItemIdentifier)' to get a 'NSFileProviderItemIdentifier' enum.")] | ||
[Abstract] | ||
[Export ("itemIdentifier")] | ||
NSString Identifier { get; } | ||
|
||
[Advice ("Use 'NSFileProviderItemIdentifierExtensions.GetValue (ParentItemIdentifier)' to get a 'NSFileProviderItemIdentifier' enum.")] | ||
[Abstract] | ||
[Export ("parentItemIdentifier")] | ||
NSString ParentIdentifier { get; } | ||
|
||
[Abstract] | ||
[Export ("filename")] | ||
string Filename { get; } | ||
|
||
[Abstract] | ||
[Export ("typeIdentifier")] | ||
string TypeIdentifier { get; } | ||
|
||
[Export ("capabilities")] | ||
NSFileProviderItemCapabilities GetCapabilities (); | ||
|
||
[return: NullAllowed] | ||
[Export ("documentSize", ArgumentSemantic.Copy)] | ||
NSNumber GetDocumentSize (); | ||
|
||
[return: NullAllowed] | ||
[Export ("childItemCount", ArgumentSemantic.Copy)] | ||
NSNumber GetChildItemCount (); | ||
|
||
[return: NullAllowed] | ||
[Export ("creationDate", ArgumentSemantic.Copy)] | ||
NSDate GetCreationDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("contentModificationDate", ArgumentSemantic.Copy)] | ||
NSDate GetContentModificationDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("lastUsedDate", ArgumentSemantic.Copy)] | ||
NSDate GetLastUsedDate (); | ||
|
||
[return: NullAllowed] | ||
[Export ("tagData", ArgumentSemantic.Copy)] | ||
NSData GetTagData (); | ||
|
||
[return: NullAllowed] | ||
[Export ("favoriteRank", ArgumentSemantic.Copy)] | ||
NSNumber GetFavoriteRank (); | ||
|
||
[Export ("isTrashed")] | ||
bool IsTrashed (); | ||
|
||
[Export ("isUploaded")] | ||
bool IsUploaded (); | ||
|
||
[Export ("isUploading")] | ||
bool IsUploading (); | ||
|
||
[return: NullAllowed] | ||
[Export ("uploadingError", ArgumentSemantic.Copy)] | ||
NSError GetUploadingError (); | ||
|
||
[Export ("isDownloaded")] | ||
bool IsDownloaded (); | ||
|
||
[Export ("isDownloading")] | ||
bool IsDownloading (); | ||
|
||
[return: NullAllowed] | ||
[Export ("downloadingError", ArgumentSemantic.Copy)] | ||
NSError GetDownloadingError (); | ||
|
||
[Export ("isMostRecentVersionDownloaded")] | ||
bool IsMostRecentVersionDownloaded (); | ||
|
||
[Export ("isShared")] | ||
bool IsShared (); | ||
|
||
[Export ("isSharedByCurrentUser")] | ||
bool IsSharedByCurrentUser (); | ||
|
||
[return: NullAllowed] | ||
[Export ("ownerNameComponents")] | ||
NSPersonNameComponents GetOwnerNameComponents (); | ||
|
||
[return: NullAllowed] | ||
[Export ("mostRecentEditorNameComponents")] | ||
NSPersonNameComponents GetMostRecentEditorNameComponents (); | ||
|
||
[return: NullAllowed] | ||
[Export ("versionIdentifier")] | ||
NSData GetVersionIdentifier (); | ||
|
||
[return: NullAllowed] | ||
[Export ("userInfo")] | ||
NSDictionary GetUserInfo (); | ||
} | ||
|
||
[iOS (11,0)] | ||
[BaseType (typeof (NSObject))] | ||
[DisableDefaultCtor] | ||
interface NSFileProviderManager { | ||
|
||
[Static] | ||
[Export ("defaultManager", ArgumentSemantic.Strong)] | ||
NSFileProviderManager DefaultManager { get; } | ||
|
||
[Protected] | ||
[Export ("signalEnumeratorForContainerItemIdentifier:completionHandler:")] | ||
// Not Async'ified on purpose, because this can switch from app to extension. | ||
void SignalEnumerator (NSString containerItemIdentifier, Action<NSError> completion); | ||
|
||
[Wrap ("SignalEnumerator (containerItemIdentifier.GetConstant (), completion)")] | ||
void SignalEnumerator (NSFileProviderItemIdentifier containerItemIdentifier, Action<NSError> completion); | ||
|
||
// Not Async'ified on purpose, because the task must be accesed while the completion action is performing... | ||
[Protected] | ||
[Export ("registerURLSessionTask:forItemWithIdentifier:completionHandler:")] | ||
void Register (NSUrlSessionTask task, NSString identifier, Action<NSError> completion); | ||
|
||
[Wrap ("Register (task, identifier.GetConstant (), completion)")] | ||
void Register (NSUrlSessionTask task, NSFileProviderItemIdentifier identifier, Action<NSError> completion); | ||
|
||
[Export ("providerIdentifier")] | ||
string ProviderIdentifier { get; } | ||
|
||
[Export ("documentStorageURL")] | ||
NSUrl DocumentStorageUrl { get; } | ||
|
||
[Static] | ||
[Export ("writePlaceholderAtURL:withMetadata:error:")] | ||
bool WritePlaceholder (NSUrl placeholderUrl, INSFileProviderItem metadata, out NSError error); | ||
|
||
[Static] | ||
[Export ("placeholderURLForURL:")] | ||
NSUrl GetPlaceholderUrl (NSUrl url); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("addDomain:completionHandler:")] | ||
void AddDomain (NSFileProviderDomain domain, Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("removeDomain:completionHandler:")] | ||
void RemoveDomain (NSFileProviderDomain domain, Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("getDomainsWithCompletionHandler:")] | ||
void GetDomains (Action<NSFileProviderDomain [], NSError> completionHandler); | ||
|
||
[Static] | ||
[Async] | ||
[Export ("removeAllDomainsWithCompletionHandler:")] | ||
void RemoveAllDomains (Action<NSError> completionHandler); | ||
|
||
[Static] | ||
[Export ("managerForDomain:")] | ||
[return: NullAllowed] | ||
NSFileProviderManager FromDomain (NSFileProviderDomain domain); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a mix of properties and GetX methods in this type, any particular reason for using one or the other? Most seems like they'd make more sense as properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a protocol we cant use optional properties, can we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I didn't notice that the properties were required and the methods optional.