Class FieldCodec
Factory methods for FieldCodec<T>.
Inheritance
Inherited Members
Namespace: Google.Protobuf
Assembly: Google.Protobuf.dll
Syntax
public static class FieldCodec
Methods
ForBool(UInt32)
Retrieves a codec suitable for a bool field with the given tag.
Declaration
public static FieldCodec<bool> ForBool(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Boolean> | A codec for the given tag. |
ForBool(UInt32, Boolean)
Retrieves a codec suitable for a bool field with the given tag.
Declaration
public static FieldCodec<bool> ForBool(uint tag, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Boolean | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Boolean> | A codec for the given tag. |
ForBytes(UInt32)
Retrieves a codec suitable for a bytes field with the given tag.
Declaration
public static FieldCodec<ByteString> ForBytes(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<ByteString> | A codec for the given tag. |
ForBytes(UInt32, ByteString)
Retrieves a codec suitable for a bytes field with the given tag.
Declaration
public static FieldCodec<ByteString> ForBytes(uint tag, ByteString defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
ByteString | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<ByteString> | A codec for the given tag. |
ForClassWrapper<T>(UInt32)
Creates a codec for a wrapper type of a class - which must be string or ByteString.
Declaration
public static FieldCodec<T> ForClassWrapper<T>(uint tag)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag |
Returns
Type | Description |
---|---|
FieldCodec<T> |
Type Parameters
Name | Description |
---|---|
T |
ForDouble(UInt32)
Retrieves a codec suitable for a double field with the given tag.
Declaration
public static FieldCodec<double> ForDouble(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Double> | A codec for the given tag. |
ForDouble(UInt32, Double)
Retrieves a codec suitable for a double field with the given tag.
Declaration
public static FieldCodec<double> ForDouble(uint tag, double defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Double | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Double> | A codec for the given tag. |
ForEnum<T>(UInt32, Func<T, Int32>, Func<Int32, T>)
Retrieves a codec suitable for an enum field with the given tag.
Declaration
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Func<T, System.Int32> | toInt32 | A conversion function from System.Int32 to the enum type. |
System.Func<System.Int32, T> | fromInt32 | A conversion function from the enum type to System.Int32. |
Returns
Type | Description |
---|---|
FieldCodec<T> | A codec for the given tag. |
Type Parameters
Name | Description |
---|---|
T |
ForEnum<T>(UInt32, Func<T, Int32>, Func<Int32, T>, T)
Retrieves a codec suitable for an enum field with the given tag.
Declaration
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32, T defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Func<T, System.Int32> | toInt32 | A conversion function from System.Int32 to the enum type. |
System.Func<System.Int32, T> | fromInt32 | A conversion function from the enum type to System.Int32. |
T | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<T> | A codec for the given tag. |
Type Parameters
Name | Description |
---|---|
T |
ForFixed32(UInt32)
Retrieves a codec suitable for a fixed32 field with the given tag.
Declaration
public static FieldCodec<uint> ForFixed32(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt32> | A codec for the given tag. |
ForFixed32(UInt32, UInt32)
Retrieves a codec suitable for a fixed32 field with the given tag.
Declaration
public static FieldCodec<uint> ForFixed32(uint tag, uint defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.UInt32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt32> | A codec for the given tag. |
ForFixed64(UInt32)
Retrieves a codec suitable for a fixed64 field with the given tag.
Declaration
public static FieldCodec<ulong> ForFixed64(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt64> | A codec for the given tag. |
ForFixed64(UInt32, UInt64)
Retrieves a codec suitable for a fixed64 field with the given tag.
Declaration
public static FieldCodec<ulong> ForFixed64(uint tag, ulong defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.UInt64 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt64> | A codec for the given tag. |
ForFloat(UInt32)
Retrieves a codec suitable for a float field with the given tag.
Declaration
public static FieldCodec<float> ForFloat(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Single> | A codec for the given tag. |
ForFloat(UInt32, Single)
Retrieves a codec suitable for a float field with the given tag.
Declaration
public static FieldCodec<float> ForFloat(uint tag, float defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Single | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Single> | A codec for the given tag. |
ForGroup<T>(UInt32, UInt32, MessageParser<T>)
Retrieves a codec suitable for a group field with the given tag.
Declaration
public static FieldCodec<T> ForGroup<T>(uint startTag, uint endTag, MessageParser<T> parser)
where T : class, IMessage<T>
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | startTag | The start group tag. |
System.UInt32 | endTag | The end group tag. |
MessageParser<T> | parser | A parser to use for the group message type. |
Returns
Type | Description |
---|---|
FieldCodec<T> | A codec for given tag |
Type Parameters
Name | Description |
---|---|
T |
ForInt32(UInt32)
Retrieves a codec suitable for an int32 field with the given tag.
Declaration
public static FieldCodec<int> ForInt32(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForInt32(UInt32, Int32)
Retrieves a codec suitable for an int32 field with the given tag.
Declaration
public static FieldCodec<int> ForInt32(uint tag, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForInt64(UInt32)
Retrieves a codec suitable for an int64 field with the given tag.
Declaration
public static FieldCodec<long> ForInt64(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForInt64(UInt32, Int64)
Retrieves a codec suitable for an int64 field with the given tag.
Declaration
public static FieldCodec<long> ForInt64(uint tag, long defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int64 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForMessage<T>(UInt32, MessageParser<T>)
Retrieves a codec suitable for a message field with the given tag.
Declaration
public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser)
where T : class, IMessage<T>
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
MessageParser<T> | parser | A parser to use for the message type. |
Returns
Type | Description |
---|---|
FieldCodec<T> | A codec for the given tag. |
Type Parameters
Name | Description |
---|---|
T |
ForSFixed32(UInt32)
Retrieves a codec suitable for an sfixed32 field with the given tag.
Declaration
public static FieldCodec<int> ForSFixed32(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForSFixed32(UInt32, Int32)
Retrieves a codec suitable for an sfixed32 field with the given tag.
Declaration
public static FieldCodec<int> ForSFixed32(uint tag, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForSFixed64(UInt32)
Retrieves a codec suitable for an sfixed64 field with the given tag.
Declaration
public static FieldCodec<long> ForSFixed64(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForSFixed64(UInt32, Int64)
Retrieves a codec suitable for an sfixed64 field with the given tag.
Declaration
public static FieldCodec<long> ForSFixed64(uint tag, long defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int64 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForSInt32(UInt32)
Retrieves a codec suitable for an sint32 field with the given tag.
Declaration
public static FieldCodec<int> ForSInt32(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForSInt32(UInt32, Int32)
Retrieves a codec suitable for an sint32 field with the given tag.
Declaration
public static FieldCodec<int> ForSInt32(uint tag, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int32> | A codec for the given tag. |
ForSInt64(UInt32)
Retrieves a codec suitable for an sint64 field with the given tag.
Declaration
public static FieldCodec<long> ForSInt64(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForSInt64(UInt32, Int64)
Retrieves a codec suitable for an sint64 field with the given tag.
Declaration
public static FieldCodec<long> ForSInt64(uint tag, long defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.Int64 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.Int64> | A codec for the given tag. |
ForString(UInt32)
Retrieves a codec suitable for a string field with the given tag.
Declaration
public static FieldCodec<string> ForString(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.String> | A codec for the given tag. |
ForString(UInt32, String)
Retrieves a codec suitable for a string field with the given tag.
Declaration
public static FieldCodec<string> ForString(uint tag, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.String | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.String> | A codec for the given tag. |
ForStructWrapper<T>(UInt32)
Creates a codec for a wrapper type of a struct - which must be Int32, Int64, UInt32, UInt64, Bool, Single or Double.
Declaration
public static FieldCodec<T?> ForStructWrapper<T>(uint tag)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag |
Returns
Type | Description |
---|---|
FieldCodec<System.Nullable<T>> |
Type Parameters
Name | Description |
---|---|
T |
ForUInt32(UInt32)
Retrieves a codec suitable for a uint32 field with the given tag.
Declaration
public static FieldCodec<uint> ForUInt32(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt32> | A codec for the given tag. |
ForUInt32(UInt32, UInt32)
Retrieves a codec suitable for a uint32 field with the given tag.
Declaration
public static FieldCodec<uint> ForUInt32(uint tag, uint defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.UInt32 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt32> | A codec for the given tag. |
ForUInt64(UInt32)
Retrieves a codec suitable for a uint64 field with the given tag.
Declaration
public static FieldCodec<ulong> ForUInt64(uint tag)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt64> | A codec for the given tag. |
ForUInt64(UInt32, UInt64)
Retrieves a codec suitable for a uint64 field with the given tag.
Declaration
public static FieldCodec<ulong> ForUInt64(uint tag, ulong defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | tag | The tag. |
System.UInt64 | defaultValue | The default value. |
Returns
Type | Description |
---|---|
FieldCodec<System.UInt64> | A codec for the given tag. |