Class FieldCodec (3.15.8)

public static class FieldCodec : object

Factory methods for FieldCodec<T>.

Inheritance

Object > FieldCodec

Namespace

Google.Protobuf

Assembly

Google.Protobuf.dll

Methods

ForBool(UInt32)

public static FieldCodec<bool> ForBool(uint tag)

Retrieves a codec suitable for a bool field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Boolean>

A codec for the given tag.

ForBool(UInt32, Boolean)

public static FieldCodec<bool> ForBool(uint tag, bool defaultValue)

Retrieves a codec suitable for a bool field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueBoolean

The default value.

Returns
TypeDescription
FieldCodec<Boolean>

A codec for the given tag.

ForBytes(UInt32)

public static FieldCodec<ByteString> ForBytes(uint tag)

Retrieves a codec suitable for a bytes field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<ByteString>

A codec for the given tag.

ForBytes(UInt32, ByteString)

public static FieldCodec<ByteString> ForBytes(uint tag, ByteString defaultValue)

Retrieves a codec suitable for a bytes field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueByteString

The default value.

Returns
TypeDescription
FieldCodec<ByteString>

A codec for the given tag.

ForClassWrapper<T>(UInt32)

public static FieldCodec<T> ForClassWrapper<T>(uint tag)
    where T : class

Creates a codec for a wrapper type of a class - which must be string or ByteString.

Parameter
NameDescription
tagUInt32
Returns
TypeDescription
FieldCodec<T>
Type Parameter
NameDescription
T

ForDouble(UInt32)

public static FieldCodec<double> ForDouble(uint tag)

Retrieves a codec suitable for a double field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Double>

A codec for the given tag.

ForDouble(UInt32, Double)

public static FieldCodec<double> ForDouble(uint tag, double defaultValue)

Retrieves a codec suitable for a double field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueDouble

The default value.

Returns
TypeDescription
FieldCodec<Double>

A codec for the given tag.

ForEnum<T>(UInt32, Func<T, Int32>, Func<Int32, T>)

public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)

Retrieves a codec suitable for an enum field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

toInt32Func<T, Int32>

A conversion function from to the enum type.

fromInt32Func<Int32, T>

A conversion function from the enum type to .

Returns
TypeDescription
FieldCodec<T>

A codec for the given tag.

Type Parameter
NameDescription
T

ForEnum<T>(UInt32, Func<T, Int32>, Func<Int32, T>, T)

public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32, T defaultValue)

Retrieves a codec suitable for an enum field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

toInt32Func<T, Int32>

A conversion function from to the enum type.

fromInt32Func<Int32, T>

A conversion function from the enum type to .

defaultValueT

The default value.

Returns
TypeDescription
FieldCodec<T>

A codec for the given tag.

Type Parameter
NameDescription
T

ForFixed32(UInt32)

public static FieldCodec<uint> ForFixed32(uint tag)

Retrieves a codec suitable for a fixed32 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<UInt32>

A codec for the given tag.

ForFixed32(UInt32, UInt32)

public static FieldCodec<uint> ForFixed32(uint tag, uint defaultValue)

Retrieves a codec suitable for a fixed32 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueUInt32

The default value.

Returns
TypeDescription
FieldCodec<UInt32>

A codec for the given tag.

ForFixed64(UInt32)

public static FieldCodec<ulong> ForFixed64(uint tag)

Retrieves a codec suitable for a fixed64 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<UInt64>

A codec for the given tag.

ForFixed64(UInt32, UInt64)

public static FieldCodec<ulong> ForFixed64(uint tag, ulong defaultValue)

Retrieves a codec suitable for a fixed64 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueUInt64

The default value.

Returns
TypeDescription
FieldCodec<UInt64>

A codec for the given tag.

ForFloat(UInt32)

public static FieldCodec<float> ForFloat(uint tag)

Retrieves a codec suitable for a float field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Single>

A codec for the given tag.

ForFloat(UInt32, Single)

public static FieldCodec<float> ForFloat(uint tag, float defaultValue)

Retrieves a codec suitable for a float field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueSingle

The default value.

Returns
TypeDescription
FieldCodec<Single>

A codec for the given tag.

ForGroup<T>(UInt32, UInt32, MessageParser<T>)

public static FieldCodec<T> ForGroup<T>(uint startTag, uint endTag, MessageParser<T> parser)
    where T : class, IMessage<T>

Retrieves a codec suitable for a group field with the given tag.

Parameters
NameDescription
startTagUInt32

The start group tag.

endTagUInt32

The end group tag.

parserMessageParser<T>

A parser to use for the group message type.

Returns
TypeDescription
FieldCodec<T>

A codec for given tag

Type Parameter
NameDescription
T

ForInt32(UInt32)

public static FieldCodec<int> ForInt32(uint tag)

Retrieves a codec suitable for an int32 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForInt32(UInt32, Int32)

public static FieldCodec<int> ForInt32(uint tag, int defaultValue)

Retrieves a codec suitable for an int32 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt32

The default value.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForInt64(UInt32)

public static FieldCodec<long> ForInt64(uint tag)

Retrieves a codec suitable for an int64 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForInt64(UInt32, Int64)

public static FieldCodec<long> ForInt64(uint tag, long defaultValue)

Retrieves a codec suitable for an int64 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt64

The default value.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForMessage<T>(UInt32, MessageParser<T>)

public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser)
    where T : class, IMessage<T>

Retrieves a codec suitable for a message field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

parserMessageParser<T>

A parser to use for the message type.

Returns
TypeDescription
FieldCodec<T>

A codec for the given tag.

Type Parameter
NameDescription
T

ForSFixed32(UInt32)

public static FieldCodec<int> ForSFixed32(uint tag)

Retrieves a codec suitable for an sfixed32 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForSFixed32(UInt32, Int32)

public static FieldCodec<int> ForSFixed32(uint tag, int defaultValue)

Retrieves a codec suitable for an sfixed32 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt32

The default value.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForSFixed64(UInt32)

public static FieldCodec<long> ForSFixed64(uint tag)

Retrieves a codec suitable for an sfixed64 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForSFixed64(UInt32, Int64)

public static FieldCodec<long> ForSFixed64(uint tag, long defaultValue)

Retrieves a codec suitable for an sfixed64 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt64

The default value.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForSInt32(UInt32)

public static FieldCodec<int> ForSInt32(uint tag)

Retrieves a codec suitable for an sint32 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForSInt32(UInt32, Int32)

public static FieldCodec<int> ForSInt32(uint tag, int defaultValue)

Retrieves a codec suitable for an sint32 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt32

The default value.

Returns
TypeDescription
FieldCodec<Int32>

A codec for the given tag.

ForSInt64(UInt32)

public static FieldCodec<long> ForSInt64(uint tag)

Retrieves a codec suitable for an sint64 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForSInt64(UInt32, Int64)

public static FieldCodec<long> ForSInt64(uint tag, long defaultValue)

Retrieves a codec suitable for an sint64 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueInt64

The default value.

Returns
TypeDescription
FieldCodec<Int64>

A codec for the given tag.

ForString(UInt32)

public static FieldCodec<string> ForString(uint tag)

Retrieves a codec suitable for a string field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<String>

A codec for the given tag.

ForString(UInt32, String)

public static FieldCodec<string> ForString(uint tag, string defaultValue)

Retrieves a codec suitable for a string field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueString

The default value.

Returns
TypeDescription
FieldCodec<String>

A codec for the given tag.

ForStructWrapper<T>(UInt32)

public static FieldCodec<T?> ForStructWrapper<T>(uint tag)
    where T : struct

Creates a codec for a wrapper type of a struct - which must be Int32, Int64, UInt32, UInt64, Bool, Single or Double.

Parameter
NameDescription
tagUInt32
Returns
TypeDescription
FieldCodec<Nullable<T>>
Type Parameter
NameDescription
T

ForUInt32(UInt32)

public static FieldCodec<uint> ForUInt32(uint tag)

Retrieves a codec suitable for a uint32 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<UInt32>

A codec for the given tag.

ForUInt32(UInt32, UInt32)

public static FieldCodec<uint> ForUInt32(uint tag, uint defaultValue)

Retrieves a codec suitable for a uint32 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueUInt32

The default value.

Returns
TypeDescription
FieldCodec<UInt32>

A codec for the given tag.

ForUInt64(UInt32)

public static FieldCodec<ulong> ForUInt64(uint tag)

Retrieves a codec suitable for a uint64 field with the given tag.

Parameter
NameDescription
tagUInt32

The tag.

Returns
TypeDescription
FieldCodec<UInt64>

A codec for the given tag.

ForUInt64(UInt32, UInt64)

public static FieldCodec<ulong> ForUInt64(uint tag, ulong defaultValue)

Retrieves a codec suitable for a uint64 field with the given tag.

Parameters
NameDescription
tagUInt32

The tag.

defaultValueUInt64

The default value.

Returns
TypeDescription
FieldCodec<UInt64>

A codec for the given tag.