ReadDouble() public method

Reads a double field from the stream.
public ReadDouble ( ) : double
return double
コード例 #1
0
ファイル: Encoder.cs プロジェクト: artwhaley/krpc
 /// <summary>
 /// Decode a value of the given type.
 /// Should not be called directly. This interface is used by service client stubs.
 /// </summary>
 public static object Decode(ByteString value, Type type, Connection client)
 {
     var stream = new CodedInputStream (value.ToByteArray ());
     if (type == typeof(double))
         return stream.ReadDouble ();
     else if (type == typeof(float))
         return stream.ReadFloat ();
     else if (type == typeof(int))
         return stream.ReadInt32 ();
     else if (type == typeof(long))
         return stream.ReadInt64 ();
     else if (type == typeof(uint))
         return stream.ReadUInt32 ();
     else if (type == typeof(ulong))
         return stream.ReadUInt64 ();
     else if (type == typeof(bool))
         return stream.ReadBool ();
     else if (type == typeof(string))
         return stream.ReadString ();
     else if (type == typeof(byte[]))
         return stream.ReadBytes ().ToByteArray ();
     else if (type.IsEnum)
         return stream.ReadInt32 ();
     else if (typeof(RemoteObject).IsAssignableFrom (type)) {
         if (client == null)
             throw new ArgumentException ("Client not passed when decoding remote object");
         var id = stream.ReadUInt64 ();
         if (id == 0)
             return null;
         return (RemoteObject)Activator.CreateInstance (type, client, id);
     } else if (typeof(IMessage).IsAssignableFrom (type)) {
         IMessage message = (IMessage)Activator.CreateInstance (type);
         message.MergeFrom (stream);
         return message;
     } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof(IList<>))
         return DecodeList (value, type, client);
     else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof(IDictionary<,>))
         return DecodeDictionary (value, type, client);
     else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof(ISet<>))
         return DecodeSet (value, type, client);
     else if (type.IsGenericType &&
              (type.GetGenericTypeDefinition () == typeof(Tuple<>) ||
              type.GetGenericTypeDefinition () == typeof(Tuple<,>) ||
              type.GetGenericTypeDefinition () == typeof(Tuple<,,>) ||
              type.GetGenericTypeDefinition () == typeof(Tuple<,,,>) ||
              type.GetGenericTypeDefinition () == typeof(Tuple<,,,,>) ||
              type.GetGenericTypeDefinition () == typeof(Tuple<,,,,,>)))
         return DecodeTuple (value, type, client); // TODO: ugly handing of tuple types
     throw new ArgumentException (type + " is not a serializable type");
 }
コード例 #2
0
ファイル: FieldCodec.cs プロジェクト: drolean/Arctium-RE
 internal double <ForDouble> b__14_0(CodedInputStream input)
 {
     return(input.ReadDouble());
 }
コード例 #3
0
ファイル: ProtocolBuffers.cs プロジェクト: artwhaley/krpc
 /// <summary>
 /// Convert a Protocol Buffer value type, encoded as a byte string, to a C# value.
 /// </summary>
 public static object ReadValue(ByteString value, Type type)
 {
     if (value.Length == 0)
         throw new ArgumentException ("Value is empty");
     var stream = new CodedInputStream (value.ToByteArray ());
     if (type == typeof(double)) {
         return stream.ReadDouble ();
     } else if (type == typeof(float)) {
         return stream.ReadFloat ();
     } else if (type == typeof(int)) {
         return stream.ReadInt32 ();
     } else if (type == typeof(long)) {
         return stream.ReadInt64 ();
     } else if (type == typeof(uint)) {
         return stream.ReadUInt32 ();
     } else if (type == typeof(ulong)) {
         return stream.ReadUInt64 ();
     } else if (type == typeof(bool)) {
         return stream.ReadBool ();
     } else if (type == typeof(string)) {
         return stream.ReadString ();
     } else if (type == typeof(byte[])) {
         return stream.ReadBytes ().ToByteArray();
     }
     throw new ArgumentException (type + " is not a Protocol Buffer value type");
 }