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


C# ByteString.CreateCodedInput方法代码示例

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


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

示例1: MergeFrom

 /// <summary>
 /// Merges data from the given byte string into an existing message.
 /// </summary>
 /// <param name="message">The message to merge the data into.</param>
 /// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
 public static void MergeFrom(this IMessage message, ByteString data)
 {
     ProtoPreconditions.CheckNotNull(message, "message");
     ProtoPreconditions.CheckNotNull(data, "data");
     CodedInputStream input = data.CreateCodedInput();
     message.MergeFrom(input);
     input.CheckReadEndOfStreamTag();
 }
开发者ID:2php,项目名称:protobuf,代码行数:13,代码来源:MessageExtensions.cs

示例2: AssertFieldsInOrder

        private static void AssertFieldsInOrder(ByteString data)
        {
            CodedInputStream input = data.CreateCodedInput();
            uint previousTag = 0;

            uint tag;
            string name;
            while (input.ReadTag(out tag, out name))
            {
                Assert.IsTrue(tag > previousTag);
                previousTag = tag;
                input.SkipField();
            }
        }
开发者ID:radavies,项目名称:protobuf,代码行数:14,代码来源:WireFormatTest.cs

示例3: MergeFrom

 /// <summary>
 /// Parses <paramref name="data"/> as an UnknownFieldSet and merge it
 /// with the set being built. This is just a small wrapper around
 /// MergeFrom(CodedInputStream).
 /// </summary>
 public Builder MergeFrom(ByteString data)
 {
     CodedInputStream input = data.CreateCodedInput();
     MergeFrom(input);
     input.CheckLastTagWas(0);
     return this;
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:12,代码来源:UnknownFieldSet.cs

示例4: Decode

 public static object Decode (ByteString value, Type type, IConnection client)
 {
     var stream = value.CreateCodedInput ();
     if (type.IsEnum)
         return stream.ReadInt32 ();
     switch (Type.GetTypeCode (type)) {
     case TypeCode.Int32:
         return stream.ReadInt32 ();
     case TypeCode.Int64:
         return stream.ReadInt64 ();
     case TypeCode.UInt32:
         return stream.ReadUInt32 ();
     case TypeCode.UInt64:
         return stream.ReadUInt64 ();
     case TypeCode.Single:
         return stream.ReadFloat ();
     case TypeCode.Double:
         return stream.ReadDouble ();
     case TypeCode.Boolean:
         return stream.ReadBool ();
     case TypeCode.String:
         return stream.ReadString ();
     default:
         if (type.Equals (typeof(byte[])))
             return stream.ReadBytes ().ToByteArray ();
         else if (IsAClassType (type)) {
             if (client == null)
                 throw new ArgumentException ("Client not passed when decoding remote object");
             var id = stream.ReadUInt64 ();
             return id == 0 ? null : (RemoteObject)Activator.CreateInstance (type, client, id);
         } else if (IsAMessageType (type)) {
             var message = (IMessage)Activator.CreateInstance (type);
             message.MergeFrom (stream);
             return message;
         } else if (IsAListType (type))
             return DecodeList (stream, type, client);
         else if (IsADictionaryType (type))
             return DecodeDictionary (stream, type, client);
         else if (IsASetType (type))
             return DecodeSet (stream, type, client);
         else if (IsATupleType (type))
             return DecodeTuple (stream, type, client);
         throw new ArgumentException (type + " is not a serializable type");
     }
 }
开发者ID:paperclip,项目名称:krpc,代码行数:45,代码来源:Encoder.cs

示例5: AssertFieldsInOrder

        private void AssertFieldsInOrder(ByteString data)
        {
            CodedInputStream input = data.CreateCodedInput();
              uint previousTag = 0;

              while (true) {
            uint tag = input.ReadTag();
            if (tag == 0) {
              break;
            }

            Assert.IsTrue(tag > previousTag);
            previousTag = tag;
            input.SkipField(tag);
              }
        }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:16,代码来源:WireFormatTest.cs

示例6: Decode

 public static object Decode (ByteString value, Type type)
 {
     var stream = value.CreateCodedInput ();
     if (type.IsEnum) {
         if (TypeUtils.IsAnEnumType (type))
             return Enum.ToObject (type, stream.ReadInt32 ());
     } else {
         switch (Type.GetTypeCode (type)) {
         case TypeCode.Int32:
             return stream.ReadInt32 ();
         case TypeCode.Int64:
             return stream.ReadInt64 ();
         case TypeCode.UInt32:
             return stream.ReadUInt32 ();
         case TypeCode.UInt64:
             return stream.ReadUInt64 ();
         case TypeCode.Single:
             return stream.ReadFloat ();
         case TypeCode.Double:
             return stream.ReadDouble ();
         case TypeCode.Boolean:
             return stream.ReadBool ();
         case TypeCode.String:
             return stream.ReadString ();
         default:
             if (type == typeof(byte[]))
                 return stream.ReadBytes ().ToByteArray ();
             else if (TypeUtils.IsAClassType (type))
                 return ObjectStore.Instance.GetInstance (stream.ReadUInt64 ());
             else if (TypeUtils.IsAMessageType (type))
                 return DecodeMessage (stream, type);
             else if (TypeUtils.IsAListCollectionType (type))
                 return DecodeList (stream, type);
             else if (TypeUtils.IsADictionaryCollectionType (type))
                 return DecodeDictionary (stream, type);
             else if (TypeUtils.IsASetCollectionType (type))
                 return DecodeSet (stream, type);
             else if (TypeUtils.IsATupleCollectionType (type))
                 return DecodeTuple (stream, type);
             break;
         }
     }
     throw new ArgumentException (type + " is not a serializable type");
 }
开发者ID:paperclip,项目名称:krpc,代码行数:44,代码来源:Encoder.cs


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