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


C# Unpacker.GetPreviousPosition方法代码示例

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


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

示例1: ThrowTupleCardinarityIsNotMatch

		/// <summary>
		///		<strong>This is intended to MsgPack for CLI internal use. Do not use this type from application directly.</strong>
		///		Throws an exception to notify that the array length does not match to expected tuple cardinality.
		/// </summary>
		/// <param name="expectedTupleCardinality">The expected cardinality of the tuple.</param>
		/// <param name="actualArrayLength">The actual serialized array length.</param>
		/// <param name="unpacker">The unpacker for pretty message.</param>
		/// <exception cref="Exception">Always thrown.</exception>
		/// <returns><see cref="Exception"/> instance. It will not be <c>null</c>.</returns>
		public static void ThrowTupleCardinarityIsNotMatch(
			int expectedTupleCardinality,
			long actualArrayLength,
			Unpacker unpacker 
		)
		{
#if DEBUG
			Contract.Requires( expectedTupleCardinality > 0 );
#endif // DEBUG
			long offsetOrPosition = -1;
			bool isRealPosition = false;
			if ( unpacker != null )
			{
				isRealPosition = unpacker.GetPreviousPosition( out offsetOrPosition );
			}

			if ( offsetOrPosition >= 0L )
			{
				if ( isRealPosition )
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"The length of array ({0}) does not match to tuple cardinality ({1}), at position {2}",
							actualArrayLength,
							expectedTupleCardinality,
							offsetOrPosition
						)
					);
				}
				else
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"The length of array ({0}) does not match to tuple cardinality ({1}), at offset {2}",
							actualArrayLength,
							expectedTupleCardinality,
							offsetOrPosition
						)
					);
				}
			}
			else
			{
				throw new InvalidMessagePackStreamException(
					String.Format(
						CultureInfo.CurrentCulture,
						"The length of array ({0}) does not match to tuple cardinality ({1}).",
						actualArrayLength,
						expectedTupleCardinality
					)
				);
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:64,代码来源:SerializationExceptions.cs

示例2: ThrowIsNotMapHeader

		/// <summary>
		///		<strong>This is intended to MsgPack for CLI internal use. Do not use this type from application directly.</strong>
		///		Throws an exception to notify that unpacker is not in the map header, that is the state is invalid.
		/// </summary>
		/// <param name="unpacker">The unpacker for pretty message.</param>
		/// <exception cref="Exception">Always thrown.</exception>
		public static void ThrowIsNotMapHeader( Unpacker unpacker )
		{
			long offsetOrPosition;
			if ( unpacker != null )
			{
				if ( unpacker.GetPreviousPosition( out offsetOrPosition ) )
				{
					throw new SerializationException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Unpacker is not in the map header at position {0}. The stream may not be map.",
							offsetOrPosition
						)
					);
				}
				else
				{
					throw new SerializationException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Unpacker is not in the map header at offset {0}. The stream may not be map.",
							offsetOrPosition
						)
					);
				}
			}
			else
			{
				throw new SerializationException(
					"Unpacker is not in the map header. The stream may not be map."
				);
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:39,代码来源:SerializationExceptions.cs

示例3: ThrowMissingKey

		internal static void ThrowMissingKey( int index, Unpacker unpacker )
		{
			long offsetOrPosition;
			var isRealPosition = unpacker.GetPreviousPosition( out offsetOrPosition );
			if ( offsetOrPosition >= 0L )
			{
				if ( isRealPosition )
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Key of map entry at index {0} is missing, at position {1}",
							index,
							offsetOrPosition
						)
					);
				}
				else
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Key of map entry at index {0} is missing, at offset {1}",
							index,
							offsetOrPosition
						)
					);
				}
			}
			else
			{
				throw new InvalidMessagePackStreamException(
					String.Format(
						CultureInfo.CurrentCulture,
						"Key of map entry at index {0} is missing.",
						index
					)
				);
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:40,代码来源:SerializationExceptions.cs

示例4: ThrowUnexpectedEndOfStream

		internal static void ThrowUnexpectedEndOfStream( Unpacker unpacker )
		{
			long offsetOrPosition;
			var isRealPosition = unpacker.GetPreviousPosition( out offsetOrPosition );
			if ( offsetOrPosition >= 0L )
			{
				if ( isRealPosition )
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Stream unexpectedly ends at position {0}",
							offsetOrPosition
						)
					);
				}
				else
				{
					throw new InvalidMessagePackStreamException(
						String.Format(
							CultureInfo.CurrentCulture,
							"Stream unexpectedly ends at offset {0}",
							offsetOrPosition
						)
					);
				}
			}
			else
			{
				throw new InvalidMessagePackStreamException( "Stream unexpectedly ends." );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:32,代码来源:SerializationExceptions.cs

示例5: ThrowMissingItem

		/// <summary>
		/// 	<strong>This is intended to MsgPack for CLI internal use. Do not use this type from application directly.</strong>
		/// 	Throws a exception to notify that item is not found on the unpacking stream.
		/// </summary>
		/// <param name="index">The index to be unpacking.</param>
		/// <param name="name">The name of the item to be unpacking.</param>
		/// <param name="unpacker">The unpacker for pretty message.</param>
		/// <exception cref="Exception">Always thrown.</exception>
		public static void ThrowMissingItem( int index, string name, Unpacker unpacker )
		{
			long offsetOrPosition = -1;
			bool isRealPosition = false;
			if ( unpacker != null )
			{
				isRealPosition = unpacker.GetPreviousPosition( out offsetOrPosition );
			}

			if ( String.IsNullOrEmpty( name ) )
			{
				if ( offsetOrPosition >= 0L )
				{
					if ( isRealPosition )
					{
						throw new InvalidMessagePackStreamException(
							String.Format(
								CultureInfo.CurrentCulture,
								"Value for '{0}' at index {1} is missing, at position {2}",
								name,
								index,
								offsetOrPosition
							)
						);
					}
					else
					{
						throw new InvalidMessagePackStreamException(
							String.Format(
								CultureInfo.CurrentCulture,
								"Value for '{0}' at index {1} is missing, at offset {2}",
								name,
								index,
								offsetOrPosition
							)
						);
					}
				}
				else
				{
					throw new InvalidMessagePackStreamException(
						String.Format( CultureInfo.CurrentCulture, "Value for '{0}' at index {1} is missing.", name, index )
					);
				}
			}
			else
			{
				if ( offsetOrPosition >= 0L )
				{
					if ( isRealPosition )
					{
						throw new InvalidMessagePackStreamException(
							String.Format(
								CultureInfo.CurrentCulture,
								"Item at index {0} is missing, at position {1}",
								index,
								offsetOrPosition
							)
						);
					}
					else
					{
						throw new InvalidMessagePackStreamException(
							String.Format(
								CultureInfo.CurrentCulture,
								"Item at index {0} is missing, at offset {1}",
								index,
								offsetOrPosition
							)
						);
					}
				}
				else
				{
					throw new InvalidMessagePackStreamException(
						String.Format( CultureInfo.CurrentCulture, "Item at index '{0}' is missing.", index )
					);
				}
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:88,代码来源:SerializationExceptions.cs


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