当前位置: 首页>>代码示例>>C#>>正文


C# ICursor.MoveToNext方法代码示例

本文整理汇总了C#中ICursor.MoveToNext方法的典型用法代码示例。如果您正苦于以下问题:C# ICursor.MoveToNext方法的具体用法?C# ICursor.MoveToNext怎么用?C# ICursor.MoveToNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICursor的用法示例。


在下文中一共展示了ICursor.MoveToNext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create_Database

        public void Create_Database()
        {
            HashSet<String> tableNameHashSet = new HashSet<String> ();
            tableNameHashSet.Add (WeatherContractOpen.LocationEntryOpen.TABLE_NAME);
            tableNameHashSet.Add (WeatherContractOpen.WeatherEntryOpen.TABLE_NAME);

            context.DeleteDatabase (WeatherDbOpenHelper.DATABASE_NAME);
            SQLiteDatabase db = new WeatherDbOpenHelper (
                                    this.context).WritableDatabase;
            Assert.AreEqual (true, db.IsOpen);

            // have we created the tables we want?
            c = db.RawQuery ("SELECT name FROM sqlite_master WHERE type='table'", null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that the database has not been created correctly");

            // verify that the tables have been created
            do {
                tableNameHashSet.Remove (c.GetString (0));
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain both the location entry
            // and weather entry tables
            Assert.IsTrue (tableNameHashSet.Count == 0, "Error: Your database was created without both the location entry and weather entry tables");

            // now, do our tables contain the correct columns?
            c = db.RawQuery ("PRAGMA table_info(" + WeatherContractOpen.LocationEntryOpen.TABLE_NAME + ")",
                null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that we were unable to query the database for table information.");

            // Build a HashSet of all of the column names we want to look for
            HashSet<String> locationColumnHashSet = new HashSet<String> ();
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen._ID);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LAT);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LONG);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_LOCATION_SETTING);

            int columnNameIndex = c.GetColumnIndex ("name");
            do {
                String columnName = c.GetString (columnNameIndex);
                locationColumnHashSet.Remove (columnName);
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain all of the required location
            // entry columns
            Assert.IsTrue (locationColumnHashSet.Count == 0, "Error: The database doesn't contain all of the required location entry columns");
            db.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:50,代码来源:TestDbOpen.cs

示例2: cursorToList

 private static List<Transaction> cursorToList(ICursor c)
 {
     List<Transaction> transactions = new List<Transaction>();
     if (c != null)
     {
         while (c.MoveToNext())
         {
             Transaction purchase = BillingDB.createTransaction(c);
             transactions.Add(purchase);
         }
         c.Close();
     }
     return transactions;
 }
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:14,代码来源:TransactionManager.cs

示例3: GetContacts

		internal static IEnumerable<Contact> GetContacts (ICursor cursor, bool rawContacts, ContentResolver content, Resources resources, int batchSize)
		{
			if (cursor == null)
				yield break;

			string column = (rawContacts)
								? ContactsContract.RawContactsColumns.ContactId
								: ContactsContract.ContactsColumns.LookupKey;

			string[] ids = new string[batchSize];
			int columnIndex = cursor.GetColumnIndex (column);

			HashSet<string> uniques = new HashSet<string>();

			int i = 0;
			while (cursor.MoveToNext())
			{
				if (i == batchSize)
				{
					i = 0;
					foreach (Contact c in GetContacts (rawContacts, content, resources, ids))
						yield return c;
				}

				string id = cursor.GetString (columnIndex);
				if (uniques.Contains (id))
					continue;

				uniques.Add (id);
				ids[i++] = id;
			}

			if (i > 0)
			{
				foreach (Contact c in GetContacts (rawContacts, content, resources, ids.Take(i).ToArray()))
					yield return c;
			}
		}
开发者ID:rampyodm,项目名称:Xamarin.Mobile,代码行数:38,代码来源:ContactHelper.cs

示例4: OnSpeakersQueryComplete

		private void OnSpeakersQueryComplete (ICursor cursor)
		{
			try {
				mSpeakersCursor = true;
				// TODO: remove any existing speakers from layout, since this cursor
				// might be from a data change notification.
				ViewGroup speakersGroup = mRootView.FindViewById<ViewGroup> (Resource.Id.session_speakers_block);
				LayoutInflater inflater = Activity.LayoutInflater;
	
				bool hasSpeakers = false;
	
				while (cursor.MoveToNext()) {
					String speakerName = cursor.GetString (SpeakersQuery.SPEAKER_NAME);
					if (TextUtils.IsEmpty (speakerName)) {
						continue;
					}
	
					String speakerImageUrl = cursor.GetString (SpeakersQuery.SPEAKER_IMAGE_URL);
					String speakerCompany = cursor.GetString (SpeakersQuery.SPEAKER_COMPANY);
					String speakerUrl = cursor.GetString (SpeakersQuery.SPEAKER_URL);
					String speakerAbstract = cursor.GetString (SpeakersQuery.SPEAKER_ABSTRACT);
	
					String speakerHeader = speakerName;
					if (!TextUtils.IsEmpty (speakerCompany)) {
						speakerHeader += ", " + speakerCompany;
					}
	
					var speakerView = inflater.Inflate (Resource.Layout.speaker_detail, speakersGroup, false);
					var speakerHeaderView = speakerView.FindViewById<TextView> (Resource.Id.speaker_header);
					var speakerImgView = speakerView.FindViewById<ImageView> (Resource.Id.speaker_image);
					var speakerUrlView = speakerView.FindViewById<TextView> (Resource.Id.speaker_url);
					var speakerAbstractView = speakerView.FindViewById<TextView> (Resource.Id.speaker_abstract);
					
					if (!TextUtils.IsEmpty (speakerImageUrl)) {
						BitmapUtils.FetchImage (Activity, new Java.Lang.String (speakerImageUrl), null, null, (result) => {
							Activity.RunOnUiThread (() => {
								speakerImgView.SetImageBitmap (result);
							});
						});
					}
	
					speakerHeaderView.Text = speakerHeader;
					UIUtils.SetTextMaybeHtml (speakerAbstractView, speakerAbstract);
	
					if (!TextUtils.IsEmpty (speakerUrl)) {
						UIUtils.SetTextMaybeHtml (speakerUrlView, speakerUrl);
						speakerUrlView.Visibility = ViewStates.Visible;
					} else {
						speakerUrlView.Visibility = ViewStates.Gone;
					}
	
					speakersGroup.AddView (speakerView);
					hasSpeakers = true;
					mHasSummaryContent = true;
				}
	
				speakersGroup.Visibility = (hasSpeakers ? ViewStates.Visible : ViewStates.Gone);
	
				// Show empty message when all data is loaded, and nothing to show
				if (mSessionCursor && !mHasSummaryContent) {
					mRootView.FindViewById (Android.Resource.Id.Empty).Visibility = ViewStates.Visible;
				}
			} finally {
				if (null != cursor) {
					cursor.Close ();
				}
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:68,代码来源:SessionDetailFragment.cs

示例5: OnQueryComplete

		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
	            return;
	        }
			
			Day day = (Day) cookie;
			
			// Clear out any existing sessions before inserting again
	        day.BlocksView.RemoveAllBlocks();
			
			try {
	            while (cursor.MoveToNext()) {
	                string type = cursor.GetString(BlocksQuery.BLOCK_TYPE);
	                
					// TODO: place random blocks at bottom of entire layout
					int column;
					try {
						column = TypeColumnMap[type];
					} catch {
						continue;
					}
	                
	                string blockId = cursor.GetString(BlocksQuery.BLOCK_ID);
	                string title = cursor.GetString(BlocksQuery.BLOCK_TITLE);
	                long start = cursor.GetLong(BlocksQuery.BLOCK_START);
	                long end = cursor.GetLong(BlocksQuery.BLOCK_END);
	                bool containsStarred = cursor.GetInt(BlocksQuery.CONTAINS_STARRED) != 0;
	
	                BlockView blockView = new BlockView(Activity, blockId, title, start, end, containsStarred, column);
	
	                int sessionsCount = cursor.GetInt(BlocksQuery.SESSIONS_COUNT);
					
	                if (sessionsCount > 0) {
	                    blockView.Click += HandleClick;
	                } else {
	                    blockView.Focusable = false;
	                    blockView.Enabled = false;
	                    LayerDrawable buttonDrawable = (LayerDrawable) blockView.Background;
	                    buttonDrawable.GetDrawable(0).SetAlpha(DISABLED_BLOCK_ALPHA);
	                    buttonDrawable.GetDrawable(2).SetAlpha(DISABLED_BLOCK_ALPHA);
	                }
	
	                day.BlocksView.AddView(blockView);
	            }
	        } finally {
	            cursor.Close();
	        }

		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:50,代码来源:ScheduleFragment.cs

示例6: prepareSyncableNotes

        // syncing based on updated local notes only
        protected void prepareSyncableNotes(ICursor localGuids)
        {
            remoteGuids = new List<string>();
            pushableNotes = new List<Note>();
            pullableNotes = new List<Note>();
            comparableNotes = new List<Note[]>();
            deleteableNotes = new List<Note>();
            conflictingNotes = new List<Note[]>();

            localGuids.MoveToFirst();
            do {
                Note note = NoteManager.getNoteByGuid(activity, localGuids.GetString(localGuids.GetColumnIndexOrThrow(Note.GUID)));

                if(!note.getTags().Contains("system:template")) // don't push templates TODO: find out what's wrong with this, if anything
                    pushableNotes.Add(note);
            } while (localGuids.MoveToNext());

            if(cancelled) {
                doCancel();
                return;
            }

            doSyncNotes();
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:25,代码来源:SyncService.cs

示例7: OnQueryComplete

		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null || cursor == null) {
				return;
			}

			mCursor = cursor;
			Activity.StartManagingCursor (mCursor);

			// If there was a last-opened track, load it. Otherwise load the first track.
			cursor.MoveToFirst ();
			String lastTrackID = UIUtils.GetLastUsedTrackID (Activity);
			if (lastTrackID != null) {
				while (!cursor.IsAfterLast) {
					if (lastTrackID.Equals (cursor.GetString (TracksAdapter.TracksQuery.TRACK_ID))) {
						break;
					}
					cursor.MoveToNext ();
				}

				if (cursor.IsAfterLast) {
					LoadTrack (null, mAutoloadTarget);
				} else {
					LoadTrack (cursor, mAutoloadTarget);
				}
			} else {
				LoadTrack (null, mAutoloadTarget);
			}

			mAdapter.SetHasAllItem (true);
			mAdapter.SetIsSessions (TracksFragment.NEXT_TYPE_SESSIONS.Equals (mNextType));
			mAdapter.ChangeCursor (mCursor);
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:33,代码来源:TracksDropdownFragment.cs

示例8: testBulkInsert

        public void testBulkInsert()
        {
            // first, let's create a location value
            ContentValues testValues = TestUtilitiesOpen.createNorthPoleLocationValues ();
            Android.Net.Uri locationUri = context.ContentResolver.Insert (WeatherContractOpen.LocationEntryOpen.CONTENT_URI, testValues);
            long locationRowId = ContentUris.ParseId (locationUri);

            // Verify we got a row back.
            Assert.IsTrue (locationRowId != -1);

            // Data's inserted.  IN THEORY.  Now pull some out to stare at it and verify it made
            // the round trip.

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                null  // sort order
            );

            Assert.IsTrue (cursor.MoveToFirst (), "Cursor is empty");
            TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert. Error validating WeatherContractOpen.LocationEntryOpen.",
                cursor, testValues);

            // Now we can bulkInsert some weather.  In fact, we only implement BulkInsert for weather
            // entries.  With ContentProviders, you really only have to implement the features you
            // use, after all.
            ContentValues[] bulkInsertContentValues = createBulkInsertWeatherValues (locationRowId);

            // Register a content observer for our bulk insert.
            TestUtilitiesOpen.TestContentObserver weatherObserver = TestUtilitiesOpen.getTestContentObserver ();
            context.ContentResolver.RegisterContentObserver (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, true, weatherObserver);

            int insertCount = context.ContentResolver.BulkInsert (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, bulkInsertContentValues);

            // Students:  If this fails, it means that you most-likely are not calling the
            // getContext().ContentResolver.notifyChange(uri, null); in your BulkInsert
            // ContentProvider method.
            weatherObserver.waitForNotificationOrFail ();
            context.ContentResolver.UnregisterContentObserver (weatherObserver);

            Assert.AreEqual (insertCount, BULK_INSERT_RECORDS_TO_INSERT);

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.WeatherEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                WeatherContractOpen.WeatherEntryOpen.COLUMN_DATE + " ASC"  // sort order == by DATE ASCENDING
            );

            // we should have as many records in the database as we've inserted
            Assert.AreEqual (cursor.Count, BULK_INSERT_RECORDS_TO_INSERT);

            // and let's make sure they match the ones we created
            cursor.MoveToFirst ();
            for (int i = 0; i < BULK_INSERT_RECORDS_TO_INSERT; i++, cursor.MoveToNext ()) {
                TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert.  Error validating WeatherContractOpen.WeatherEntryOpen " + i,
                    cursor, bulkInsertContentValues [i]);
            }
            cursor.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:65,代码来源:TestProvider.cs


注:本文中的ICursor.MoveToNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。