ReadBool() public méthode

Reads a bool field from the stream.
public ReadBool ( ) : bool
Résultat bool
Exemple #1
0
 /// <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");
 }
Exemple #2
0
                public void MergeFrom(CodedInputStream input)
                {
                    while (true)
                    {
IL_F1:
                        uint num;
                        uint arg_B1_0 = ((num = input.ReadTag()) == 0u) ? 892360258u : 1848098736u;
                        while (true)
                        {
                            uint num2;
                            switch ((num2 = (arg_B1_0 ^ 1527141277u)) % 9u)
                            {
                            case 0u:
                                goto IL_F1;

                            case 1u:
                                arg_B1_0 = (((num != 16u) ? 2248849807u : 3227524151u) ^ num2 * 3730220176u);
                                continue;

                            case 3u:
                                input.SkipLastField();
                                arg_B1_0 = (num2 * 783818891u ^ 1987640322u);
                                continue;

                            case 4u:
                                arg_B1_0 = ((num == 10u) ? 319223136u : 559492368u);
                                continue;

                            case 5u:
                                arg_B1_0 = (num2 * 1269553354u ^ 293555476u);
                                continue;

                            case 6u:
                                this.IsExtension = input.ReadBool();
                                arg_B1_0         = 894606036u;
                                continue;

                            case 7u:
                                arg_B1_0 = 1848098736u;
                                continue;

                            case 8u:
                                this.NamePart_ = input.ReadString();
                                arg_B1_0       = 55025149u;
                                continue;
                            }
                            return;
                        }
                    }
                }
Exemple #3
0
 internal bool <ForBool> b__2_0(CodedInputStream input)
 {
     return(input.ReadBool());
 }
Exemple #4
0
 /// <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");
 }