Esempio n. 1
0
        /// <param name="url">The shared document's URL.</param>
        /// <param name="completionHandler">
        ///   <para>An action the system calls subsequent to the creation of a placeholder.</para>
        ///   <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
        /// </param>
        /// <summary>When implemented by the developer, creates a specified placeholder for a previously defined URL.</summary>
        /// <remarks>
        ///   <para>The developer must override this method. This method is called to provide a placeholder for documents that are returned by the Document Picker but that are not locally stored.</para>
        ///   <para tool="threads">This can be used from a background thread.</para>
        /// </remarks>
        public override void ProvidePlaceholderAtUrl(NSUrl url, Action <NSError> completionHandler)
        {
            try
            {
                string       identifier   = this.GetPersistentIdentifier(url);
                ItemMetadata itemMetadata = this.StorageManager.GetItemMetadata(identifier);
                if (!itemMetadata.IsExists)
                {
                    completionHandler?.Invoke(NSFileProviderErrorFactory.CreateNonExistentItemError(identifier));
                    return;
                }
                NSUrl   placeholderUrl = NSFileProviderManager.GetPlaceholderUrl(url);
                NSError error;
                NSFileManager.DefaultManager.CreateDirectory(placeholderUrl.RemoveLastPathComponent(), true, null, out error);
                if (error != null)
                {
                    completionHandler?.Invoke(error);
                    return;
                }

                INSFileProviderItem providerItem = ProviderItem.CreateFromMetadata(itemMetadata);
                NSFileProviderManager.WritePlaceholder(placeholderUrl, providerItem, out error);
                completionHandler?.Invoke(error);
            }
            catch (Exception ex)
            {
                NSError error = this.MapError(ex);
                completionHandler?.Invoke(error);
            }
        }
 public void UninstallExtension()
 {
     ManagerForDomain = null;
     NSFileProviderManager.RemoveDomain(Domain, (NSError error) =>
     {
         if (error is not null)
         {
             // error uninstalling
             return;
         }
     });
 }
        public void InstallExtension()
        {
            NSFileProviderManager.GetDomains((domains, error) =>
            {
                if (error is not null)
                {
                    // error
                    return;
                }

                foreach (NSFileProviderDomain domain in domains)
                {
                    if (domain.IsEqual(Domain))
                    {
                        // already installed
                        return;
                    }
                }

                NSFileProviderManager.AddDomain(Domain, (NSError error) =>
                {
                    if (error is not null)
                    {
                        // error installing
                        return;
                    }

                    ManagerForDomain = NSFileProviderManager.FromDomain(Domain);
                    if (ManagerForDomain is null)
                    {
                        // error creating manager
                        return;
                    }
                });
            });
        }
        public VfsEngine(NSFileProviderDomain domain)
            : base(domain)
        {
            License = AppGroupSettings.GetLicense();
            logger  = new ConsoleLogger(GetType().Name);

            remoteStorageMonitor = new RemoteStorageMonitor(AppGroupSettings.GetRemoteRootPath(), NSFileProviderManager.FromDomain(domain));
            remoteStorageMonitor.Start();
        }
 public RemoteStorageMonitor(string remoteStorageRootPath, NSFileProviderManager fileProviderManager)
 {
     this.remoteStorageRootPath = remoteStorageRootPath;
     this.logger = new ConsoleLogger(GetType().Name);
     this.fileProviderManager = fileProviderManager;
 }