本文整理汇总了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
)
);
}
}
示例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."
);
}
}
示例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
)
);
}
}
示例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." );
}
}
示例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 )
);
}
}
}