コード例 #1
0
ファイル: Helpers.cs プロジェクト: ice0/test
        /// <summary>
        /// This function inserts three items into the index with generic Key, Name, Keywords, and Comment properties.
        /// </summary>
        public async static Task <string> AddItemsToIndex(Windows.Storage.Search.ContentIndexer indexer)
        {
            var       content = new Windows.Storage.Search.IndexableContent();
            const int numberOfItemsToIndex = 3;

            for (int i = 0; i < numberOfItemsToIndex; i++)
            {
                content.Properties[Windows.Storage.SystemProperties.ItemNameDisplay] = "Sample Item Name " + i;
                content.Properties[Windows.Storage.SystemProperties.Keywords]        = "Sample keyword " + i;
                content.Properties[Windows.Storage.SystemProperties.Comment]         = "Sample comment " + i;
                content.Id = "SampleKey" + i;
                OnIndexerOperationBegin();
                await indexer.AddAsync(content);

                OnIndexerOperationComplete(indexer);
            }
            string[] propertiesToQuery =
            {
                Windows.Storage.SystemProperties.ItemNameDisplay,
                Windows.Storage.SystemProperties.Keywords,
                Windows.Storage.SystemProperties.Comment
            };
            var  query = indexer.CreateQuery("*", propertiesToQuery);
            uint count = await query.GetCountAsync();

            return("Number of items currently in the index: " + count);
        }
コード例 #2
0
ファイル: Helpers.cs プロジェクト: ice0/test
        public static void OnIndexerOperationComplete(Windows.Storage.Search.ContentIndexer indexer)
        {
            // Set the expectedIndexRevision to be the reported index revision number because the operation
            // has succeeded
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            localSettings.Values["expectedIndexRevision"] = indexer.Revision;
        }