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


C# BufferedStream.ToJObject方法代码示例

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


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

示例1: Read

		public IEnumerable<ListItem> Read(string name, Guid start, int take)
		{
			Api.JetSetCurrentIndex(session, Lists, "by_name_and_etag");
			Api.MakeKey(session, Lists, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			Api.MakeKey(session, Lists, start.TransformToValueForEsentSorting(), MakeKeyGrbit.None);
			if (Api.TrySeek(session, Lists, SeekGrbit.SeekGT) == false)
				yield break;
			int count = 0;
			do
			{
				var nameFromDb = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["name"], Encoding.Unicode);
				if(string.Equals(name, nameFromDb, StringComparison.InvariantCultureIgnoreCase) == false)
					yield break;

				count++;

				var etag = Api.RetrieveColumn(session, Lists, tableColumnsCache.ListsColumns["etag"]).TransfromToGuidWithProperSorting();
				using (Stream stream = new BufferedStream(new ColumnStream(session, Lists, tableColumnsCache.ListsColumns["data"])))
				{
					yield return new ListItem
					{
						Etag = etag,
						Data = stream.ToJObject(),
						Key = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["key"], Encoding.Unicode)
					};
				}
			} while (Api.TryMoveNext(session, Lists) && count < take);
		
		}
开发者ID:arelee,项目名称:ravendb,代码行数:29,代码来源:Lists.cs

示例2: GetMappedResults

		public IEnumerable<RavenJObject> GetMappedResults(params GetMappedResultsParams[] getMappedResultsParams)
		{
			var optimizedIndexReader = new OptimizedIndexReader<GetMappedResultsParams>(Session, MappedResults, getMappedResultsParams.Length);
			
			Api.JetSetCurrentIndex(session, MappedResults, "by_reduce_key_and_view_hashed");
			
			foreach (var item in getMappedResultsParams)
			{
				Api.MakeKey(session, MappedResults, item.ViewAndReduceKeyHashed, MakeKeyGrbit.NewKey);
				if (Api.TrySeek(session, MappedResults, SeekGrbit.SeekEQ) == false)
					continue;

				Api.MakeKey(session, MappedResults, item.ViewAndReduceKeyHashed, MakeKeyGrbit.NewKey);
				Api.JetSetIndexRange(session, MappedResults, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive);
				do
				{
					optimizedIndexReader.Add(item);
				} while (Api.TryMoveNext(session, MappedResults));
			}

			return optimizedIndexReader
				.Where(item =>
				{
					// we need to check that we don't have hash collisions
					var currentReduceKey = Api.RetrieveColumnAsString(session, MappedResults,
					                                                  tableColumnsCache.MappedResultsColumns["reduce_key"]);
					if (currentReduceKey != item.ReduceKey)
						return false;

					var currentView = Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["view"]);
					
					return currentView == item.View;
				})
				.Select(item =>
				{
					using (var stream = new BufferedStream(new ColumnStream(session, MappedResults, tableColumnsCache.MappedResultsColumns["data"])))
					{
						return stream.ToJObject();
					}
				});
		}
开发者ID:neiz,项目名称:ravendb,代码行数:41,代码来源:MappedResults.cs

示例3: ReadLast

        public ListItem ReadLast(string name)
        {
            Api.JetSetCurrentIndex(session, Lists, "by_name_and_etag");
            Api.MakeKey(session, Lists, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
            Api.MakeKey(session, Lists, Etag.InvalidEtag.TransformToValueForEsentSorting(), MakeKeyGrbit.None);

            if (Api.TrySeek(session, Lists, SeekGrbit.SeekLE) == false)
                return null;

            var nameFromDb = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["name"], Encoding.Unicode);
            if (string.Equals(name, nameFromDb, StringComparison.InvariantCultureIgnoreCase) == false) 
                return null;

            using (Stream stream = new BufferedStream(new ColumnStream(session, Lists, tableColumnsCache.ListsColumns["data"])))
            {
                return new ListItem
                {
                    Data = stream.ToJObject(),
                    Key = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["key"], Encoding.Unicode),
                    Etag = Etag.Parse(Api.RetrieveColumn(session, Lists, tableColumnsCache.ListsColumns["etag"])),
					CreatedAt = Api.RetrieveColumnAsDateTime(session, Lists, tableColumnsCache.ListsColumns["created_at"]).Value
                };
            }
        }
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:24,代码来源:Lists.cs

示例4: Read

		public ListItem Read(string name, string key)
		{
			Api.JetSetCurrentIndex(session, Lists, "by_name_and_key");
			Api.MakeKey(session, Lists, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			Api.MakeKey(session, Lists, key, Encoding.Unicode, MakeKeyGrbit.None);

			if (Api.TrySeek(session, Lists, SeekGrbit.SeekEQ) == false)
				return null;

			using (Stream stream = new BufferedStream(new ColumnStream(session, Lists, tableColumnsCache.ListsColumns["data"])))
			{
				return new ListItem
				{
					Data = stream.ToJObject(),
					Key = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["key"], Encoding.Unicode),
					Etag = Etag.Parse(Api.RetrieveColumn(session, Lists, tableColumnsCache.ListsColumns["etag"])),
					CreatedAt = Api.RetrieveColumnAsDateTime(session, Lists, tableColumnsCache.ListsColumns["created_at"]).Value
				};
			}
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:20,代码来源:Lists.cs

示例5: Read

        public IEnumerable<ListItem> Read(string name, int start, int take)
        {
            Api.JetSetCurrentIndex(session, Lists, "by_name_and_etag");
            Api.MakeKey(session, Lists, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
            if (Api.TrySeek(session, Lists, SeekGrbit.SeekGT) == false)
                yield break;

            int skipped = 0;
            while (skipped < start)
            {
                if (!Api.TryMoveNext(session, Lists))
                    yield break;
                skipped++;
            }

            int count = 0;
            do
            {
                var nameFromDb = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["name"], Encoding.Unicode);
                if (string.Equals(name, nameFromDb, StringComparison.InvariantCultureIgnoreCase) == false)
                    yield break;


                var etag = Etag.Parse(Api.RetrieveColumn(session, Lists, tableColumnsCache.ListsColumns["etag"]));

                count++;

                using (Stream stream = new BufferedStream(new ColumnStream(session, Lists, tableColumnsCache.ListsColumns["data"])))
                {
                    yield return new ListItem
                    {
                        Etag = etag,
                        Data = stream.ToJObject(),
                        Key = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["key"], Encoding.Unicode),
                        CreatedAt = Api.RetrieveColumnAsDateTime(session, Lists, tableColumnsCache.ListsColumns["created_at"]).Value
                    };
                }
            } while (Api.TryMoveNext(session, Lists) && count < take);
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:39,代码来源:Lists.cs

示例6: GetMappedResults

		public IEnumerable<RavenJObject> GetMappedResults(params GetMappedResultsParams[] getMappedResultsParams)
		{
			// optimized according to this: http://managedesent.codeplex.com/discussions/274843#post680337
			var primaryKeyIndexes = new List<Tuple<byte[], GetMappedResultsParams>>();

			Api.JetSetCurrentIndex(session, MappedResults, "by_reduce_key_and_view_hashed");
			foreach (var item in getMappedResultsParams)
			{
				Api.MakeKey(session, MappedResults, item.ViewAndReduceKeyHashed, MakeKeyGrbit.NewKey);
				if (Api.TrySeek(session, MappedResults, SeekGrbit.SeekEQ) == false)
					continue;

				var bookmarkBuffer = new byte[SystemParameters.BookmarkMost];
				var ignoredBuffer = new byte[SystemParameters.BookmarkMost];
				Api.MakeKey(session, MappedResults, item.ViewAndReduceKeyHashed, MakeKeyGrbit.NewKey);
				Api.JetSetIndexRange(session, MappedResults, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive);
				do
				{
					int actualBookmarkSize;
					int ignored;
					Api.JetGetSecondaryIndexBookmark(session, MappedResults, ignoredBuffer, ignoredBuffer.Length, out ignored, bookmarkBuffer,
					                                 bookmarkBuffer.Length, out actualBookmarkSize, GetSecondaryIndexBookmarkGrbit.None);

					primaryKeyIndexes.Add(Tuple.Create(bookmarkBuffer.Take(actualBookmarkSize).ToArray(), item));
				} while (Api.TryMoveNext(session, MappedResults));
			}

			primaryKeyIndexes.Sort((x, y) =>
			{
				var bytes1 = x.Item1;
				var bytes2 = y.Item1;
				for (int i = 0; i < Math.Min(bytes1.Length, bytes2.Length); i++)
				{
					if (bytes1[i] != bytes2[i])
						return bytes1[i] - bytes2[i];
				}
				return bytes1.Length - bytes2.Length;
			});

			foreach (var primaryKeyIndexTuple in primaryKeyIndexes)
			{
				var bookmark = primaryKeyIndexTuple.Item1;
				var item = primaryKeyIndexTuple.Item2;
				Api.JetGotoBookmark(session, MappedResults, bookmark, bookmark.Length);

				// we need to check that we don't have hash collisions
				var currentReduceKey = Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["reduce_key"]);
				if (currentReduceKey != item.ReduceKey)
					continue;

				var currentView = Api.RetrieveColumnAsString(session, MappedResults, tableColumnsCache.MappedResultsColumns["view"]);
				if (currentView != item.View)
					continue;

				RavenJObject obj;
				using(var stream = new BufferedStream(new ColumnStream(session, MappedResults, tableColumnsCache.MappedResultsColumns["data"])))
				{
					obj = stream.ToJObject();
				}

				yield return obj;

			}
		}
开发者ID:Korn1699,项目名称:ravendb,代码行数:64,代码来源:MappedResults.cs


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