Example #1
0
        Task BeginQuery()
        {
            if (firstQueryResult != null)
            {
                var t = firstQueryResult;
                firstQueryResult = null;
                if (!t.Task.IsCompleted)
                {
                    t.SetException(new Exception("Stopped"));
                }
            }
            if (query != null)
            {
                query.StopQuery();
            }

            firstQueryResult = new TaskCompletionSource <object> ();

            if (documentsUrl == null)
            {
                firstQueryResult.SetResult(null);
                return(firstQueryResult.Task);
            }

            var queryString = "";
            var head        = "";
            var args        = new List <NSObject> ();

            foreach (var e in FileExtensions)
            {
                queryString += head + "(%K LIKE '*." + e + "')";
                head         = " OR ";
                args.Add(NSMetadataQuery.ItemFSNameKey);
            }

            query = new NSMetadataQuery();
            query.SearchScopes = new NSObject[] { NSMetadataQuery.UbiquitousDocumentsScope };
            query.Predicate    = NSPredicate.FromFormat(
                queryString,
                args.ToArray());

            Console.WriteLine("START iCLOUD QUERY");

            query.StartQuery();

            needsRefresh = false;

            return(firstQueryResult.Task);
        }
        void StartQuery()
        {
            if (documentMetadataQuery != null)
            {
                documentMetadataQuery.StopQuery();
            }

            if (AppConfig.SharedAppConfiguration.StorageOption == StorageType.Cloud)
            {
                StartMetadataQuery();
            }
            else
            {
                StartLocalQuery();
            }
        }
Example #3
0
 public override void WillTerminate(NSNotification notification)
 {
     _query.StopQuery();
     _query.Delegate = null;
     _query          = null;
 }