Google.Protobuf.CodedOutputStream.WriteDouble C# (CSharp) Method

WriteDouble() public method

Writes a double field value, without a tag, to the stream.
public WriteDouble ( double value ) : void
value double The value to write
return void
        public void WriteDouble(double value)
        {
            WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
        }

Usage Example

Example #1
0
 static ByteString EncodeObject (object value, MemoryStream buffer, CodedOutputStream stream)
 {
     buffer.SetLength (0);
     if (value == null) {
         stream.WriteUInt64 (0);
     } else if (value is Enum) {
         stream.WriteInt32 ((int)value);
     } else {
         Type type = value.GetType ();
         switch (Type.GetTypeCode (type)) {
         case TypeCode.Int32:
             stream.WriteInt32 ((int)value);
             break;
         case TypeCode.Int64:
             stream.WriteInt64 ((long)value);
             break;
         case TypeCode.UInt32:
             stream.WriteUInt32 ((uint)value);
             break;
         case TypeCode.UInt64:
             stream.WriteUInt64 ((ulong)value);
             break;
         case TypeCode.Single:
             stream.WriteFloat ((float)value);
             break;
         case TypeCode.Double:
             stream.WriteDouble ((double)value);
             break;
         case TypeCode.Boolean:
             stream.WriteBool ((bool)value);
             break;
         case TypeCode.String:
             stream.WriteString ((string)value);
             break;
         default:
             if (type == typeof(byte[]))
                 stream.WriteBytes (ByteString.CopyFrom ((byte[])value));
             else if (TypeUtils.IsAClassType (type))
                 stream.WriteUInt64 (ObjectStore.Instance.AddInstance (value));
             else if (TypeUtils.IsAMessageType (type))
                 WriteMessage (value, stream);
             else if (TypeUtils.IsAListCollectionType (type))
                 WriteList (value, stream);
             else if (TypeUtils.IsADictionaryCollectionType (type))
                 WriteDictionary (value, stream);
             else if (TypeUtils.IsASetCollectionType (type))
                 WriteSet (value, stream);
             else if (TypeUtils.IsATupleCollectionType (type))
                 WriteTuple (value, stream);
             else
                 throw new ArgumentException (type + " is not a serializable type");
             break;
         }
     }
     stream.Flush ();
     return ByteString.CopyFrom (buffer.GetBuffer (), 0, (int)buffer.Length);
 }
All Usage Examples Of Google.Protobuf.CodedOutputStream::WriteDouble