本文整理汇总了C#中ProtoReader.ReadInt64方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoReader.ReadInt64方法的具体用法?C# ProtoReader.ReadInt64怎么用?C# ProtoReader.ReadInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoReader
的用法示例。
在下文中一共展示了ProtoReader.ReadInt64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public object Read(object value, ProtoReader source)
{
return source.ReadInt64();
}
示例2: TryDeserializeAuxiliaryType
/// <summary>
/// This is the more "complete" version of Deserialize, which handles single instances of mapped types.
/// The value is read as a complete field, including field-header and (for sub-objects) a
/// length-prefix..kmc
///
/// In addition to that, this provides support for:
/// - basic values; individual int / string / Guid / etc
/// - IList sets of any type handled by TryDeserializeAuxiliaryType
/// </summary>
private bool TryDeserializeAuxiliaryType(ProtoReader reader, DataFormat format, int tag, Type type, ref object value, bool skipOtherFields, bool asListItem)
{
if (type == null) throw new ArgumentNullException("type");
Type itemType = null;
TypeCode typecode = Type.GetTypeCode(type);
int modelKey;
WireType wiretype = GetWireType(typecode, format, ref type, out modelKey);
bool found = false;
if (wiretype == WireType.None)
{
itemType = GetListItemType(type);
if (itemType != null)
{
return TryDeserializeList(reader, format, tag, type, itemType, ref value);
}
// otherwise, not a happy bunny...
ThrowUnexpectedType(type);
}
// to treat correctly, should read all values
while (true)
{
// for convenience (re complex exit conditions), additional exit test here:
// if we've got the value, are only looking for one, and we aren't a list - then exit
if (found && asListItem) break;
// read the next item
int fieldNumber = reader.ReadFieldHeader();
if (fieldNumber <= 0) break;
if (fieldNumber != tag)
{
if (skipOtherFields)
{
reader.SkipField();
continue;
}
throw ProtoReader.AddErrorData(new InvalidOperationException(
"Expected field " + tag + ", but found " + fieldNumber), reader);
}
found = true;
reader.Hint(wiretype); // handle signed data etc
if (modelKey >= 0)
{
switch (wiretype)
{
case WireType.String:
case WireType.StartGroup:
SubItemToken token = ProtoReader.StartSubItem(reader);
value = Deserialize(modelKey, value, reader);
ProtoReader.EndSubItem(token, reader);
continue;
default:
value = Deserialize(modelKey, value, reader);
continue;
}
}
switch (typecode)
{
case TypeCode.Int16: value = reader.ReadInt16(); continue;
case TypeCode.Int32: value = reader.ReadInt32(); continue;
case TypeCode.Int64: value = reader.ReadInt64(); continue;
case TypeCode.UInt16: value = reader.ReadUInt16(); continue;
case TypeCode.UInt32: value = reader.ReadUInt32(); continue;
case TypeCode.UInt64: value = reader.ReadUInt64(); continue;
case TypeCode.Boolean: value = reader.ReadBoolean(); continue;
case TypeCode.SByte: value = reader.ReadSByte(); continue;
case TypeCode.Byte: value = reader.ReadByte(); continue;
case TypeCode.Char: value = (char)reader.ReadUInt16(); continue;
case TypeCode.Double: value = reader.ReadDouble(); continue;
case TypeCode.Single: value = reader.ReadSingle(); continue;
case TypeCode.DateTime: value = BclHelpers.ReadDateTime(reader); continue;
case TypeCode.Decimal: BclHelpers.ReadDecimal(reader); continue;
case TypeCode.String: value = reader.ReadString(); continue;
}
if (type == typeof(byte[])) { value = ProtoReader.AppendBytes((byte[])value, reader); continue; }
if (type == typeof(TimeSpan)) { value = BclHelpers.ReadTimeSpan(reader); continue; }
if (type == typeof(Guid)) { value = BclHelpers.ReadGuid(reader); continue; }
if (type == typeof(Uri)) { value = new Uri(reader.ReadString()); continue; }
}
if (!found && !asListItem) { value = Activator.CreateInstance(type); }
return found;
}
示例3: Read
public object Read(object value, ProtoReader source)
{
Helpers.DebugAssert(value == null); // since replaces
return source.ReadInt64();
}