Show / Hide Table of Contents

Class FieldCodec

Factory methods for FieldCodec<T>.

Inheritance
System.Object
FieldCodec
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
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.

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.

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.

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

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.

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.

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.

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 : 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.

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.

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 : 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.

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.

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.

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.

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.

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.

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.

Back to top