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


C# ProtoReader.ReadUInt64方法代码示例

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


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

示例1: ReadDecimal

 public static decimal ReadDecimal(ProtoReader reader)
 {
     ulong num = 0uL;
     uint num2 = 0u;
     uint num3 = 0u;
     SubItemToken token = ProtoReader.StartSubItem(reader);
     int num4;
     while ((num4 = reader.ReadFieldHeader()) > 0)
     {
         switch (num4)
         {
         case 1:
             num = reader.ReadUInt64();
             break;
         case 2:
             num2 = reader.ReadUInt32();
             break;
         case 3:
             num3 = reader.ReadUInt32();
             break;
         default:
             reader.SkipField();
             break;
         }
     }
     ProtoReader.EndSubItem(token, reader);
     if (num == 0uL && num2 == 0u)
     {
         return 0m;
     }
     int lo = (int)(num & 0xFFFFFFFFL);
     int mid = (int)(num >> 32 & 0xFFFFFFFFL);
     int hi = (int)num2;
     bool isNegative = (num3 & 1u) == 1u;
     byte scale = (byte)((num3 & 510u) >> 1);
     return new decimal(lo, mid, hi, isNegative, scale);
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:37,代码来源:BclHelpers.cs

示例2: ReadGuid

 /// <summary>
 /// Parses a Guid from a protobuf stream
 /// </summary>
 public static Guid ReadGuid(ProtoReader source)
 {
     ulong low = 0, high = 0;
     int fieldNumber;
     SubItemToken token = ProtoReader.StartSubItem(source);
     while ((fieldNumber = source.ReadFieldHeader()) > 0)
     {
         switch (fieldNumber)
         {
             case FieldGuidLow: low = source.ReadUInt64(); break;
             case FieldGuidHigh: high = source.ReadUInt64(); break;
             default: source.SkipField(); break;
         }
     }
     ProtoReader.EndSubItem(token, source);
     if(low == 0 && high == 0) return Guid.Empty;
     uint a = (uint)(low >> 32), b = (uint)low, c = (uint)(high >> 32), d= (uint)high;
     return new Guid((int)b, (short)a, (short)(a >> 16), 
         (byte)d, (byte)(d >> 8), (byte)(d >> 16), (byte)(d >> 24),
         (byte)c, (byte)(c >> 8), (byte)(c >> 16), (byte)(c >> 24));
     
 }
开发者ID:tsuixl,项目名称:Frame,代码行数:25,代码来源:BclHelpers.cs

示例3: ReadDecimal

        /// <summary>
        /// Parses a decimal from a protobuf stream
        /// </summary>
        public static decimal ReadDecimal(ProtoReader reader)
        {
            ulong low = 0;
            uint high = 0;
            uint signScale = 0;

            int fieldNumber;
            SubItemToken token = ProtoReader.StartSubItem(reader);
            while ((fieldNumber = reader.ReadFieldHeader()) > 0)
            {
                switch (fieldNumber)
                {
                    case FieldDecimalLow: low = reader.ReadUInt64(); break;
                    case FieldDecimalHigh: high = reader.ReadUInt32(); break;
                    case FieldDecimalSignScale: signScale = reader.ReadUInt32(); break;
                    default: reader.SkipField(); break;
                }
                
            }
            ProtoReader.EndSubItem(token, reader);

            if (low == 0 && high == 0) return decimal.Zero;

            int lo = (int)(low & 0xFFFFFFFFL),
                mid = (int)((low >> 32) & 0xFFFFFFFFL),
                hi = (int)high;
            bool isNeg = (signScale & 0x0001) == 0x0001;
            byte scale = (byte)((signScale & 0x01FE) >> 1);
            return new decimal(lo, mid, hi, isNeg, scale);
        }
开发者ID:tsuixl,项目名称:Frame,代码行数:33,代码来源:BclHelpers.cs

示例4: ReadGuid

 public static Guid ReadGuid(ProtoReader source)
 {
     ulong num = 0uL;
     ulong num2 = 0uL;
     SubItemToken token = ProtoReader.StartSubItem(source);
     int num3;
     while ((num3 = source.ReadFieldHeader()) > 0)
     {
         int num4 = num3;
         if (num4 != 1)
         {
             if (num4 != 2)
             {
                 source.SkipField();
             }
             else
             {
                 num2 = source.ReadUInt64();
             }
         }
         else
         {
             num = source.ReadUInt64();
         }
     }
     ProtoReader.EndSubItem(token, source);
     if (num == 0uL && num2 == 0uL)
     {
         return Guid.Empty;
     }
     uint num5 = (uint)(num >> 32);
     uint a = (uint)num;
     uint num6 = (uint)(num2 >> 32);
     uint num7 = (uint)num2;
     return new Guid((int)a, (short)num5, (short)(num5 >> 16), (byte)num7, (byte)(num7 >> 8), (byte)(num7 >> 16), (byte)(num7 >> 24), (byte)num6, (byte)(num6 >> 8), (byte)(num6 >> 16), (byte)(num6 >> 24));
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:36,代码来源:BclHelpers.cs

示例5: ReadField

 object ReadField(ProtoReader reader, Type memberT, string sClassName, CLS_Environment environment)
 {
     if (memberT == typeof(int))
     {
         return reader.ReadInt32();
     }
     else if (memberT == typeof(uint))
     {
         return reader.ReadUInt32();
     }
     else if (memberT == typeof(bool))
     {
         return reader.ReadBoolean();
     }
     else if (memberT == typeof(byte))
     {
         return reader.ReadByte();
     }
     else if (memberT == typeof(sbyte))
     {
         return reader.ReadSByte();
     }
     else if (memberT == typeof(float))
     {
         return reader.ReadSingle();
     }
     else if (memberT == typeof(double))
     {
         return reader.ReadDouble();
     }
     else if (memberT == typeof(short))
     {
         return reader.ReadInt16();
     }
     else if (memberT == typeof(ushort))
     {
         return reader.ReadUInt16();
     }
     else if (memberT == typeof(long))
     {
         return reader.ReadInt64();
     }
     else if (memberT == typeof(ulong))
     {
         return reader.ReadUInt64();
     }
     else if (memberT == typeof(string))
     {
         return reader.ReadString();
     }
     else if (memberT == typeof(byte[]))
     {
         return ProtoReader.AppendBytes(null, reader);
     }
     else if (memberT == typeof(SInstance))
     {
         SubItemToken st = ProtoReader.StartSubItem(reader);
         CLS_Type_Class sClass = environment.GetTypeByKeywordQuiet(sClassName) as CLS_Type_Class;
         if (!sClass.compiled)
             RuntimeCompilerClass(sClassName);
         CLS_Content content = CLS_Content.NewContent(environment);
         CLS_Content.Value retVal = sClass.function.New(content, m_emptyParams);
         CLS_Content.PoolContent(content);
         SInstance sInstance = (SInstance)retVal.value;
         ReadSInstance(reader, sInstance, environment);
         ProtoReader.EndSubItem(st, reader);
         return sInstance;
     }
     else
     {
         throw new NotImplementedException("未实现类型: " + memberT);
     }
 }
开发者ID:wpszz,项目名称:CSLightForUnity,代码行数:73,代码来源:CSLightMng_ProtoBuf.cs


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