Class Metadata

public sealed class Metadata : IList<Metadata.Entry>

A collection of metadata entries that can be exchanged during a call. gRPC supports these types of metadata:

  • Request headersare sent by the client at the beginning of a remote call before any request messages are sent.
  • Response headersare sent by the server at the beginning of a remote call handler before any response messages are sent.
  • Response trailersare sent by the server at the end of a remote call along with resulting call status.

Inheritance

Object > Metadata

Namespace

Grpc.Core

Assembly

Grpc.Core.Api.dll

Constructors

Metadata()

public Metadata()

Initializes a new instance of Metadata.

Fields

BinaryHeaderSuffix

public const string BinaryHeaderSuffix = null

All binary headers should have this suffix.

Field Value
TypeDescription
String

Empty

public static readonly Metadata Empty

An read-only instance of metadata containing no entries.

Field Value
TypeDescription
Metadata

Properties

Count

public int Count { get; }
IList<>
Property Value
TypeDescription
Int32

IsReadOnly

public bool IsReadOnly { get; }
IList<>
Property Value
TypeDescription
Boolean

Item[Int32]

public Metadata.Entry this[int index] { get; set; }
IList<>
Parameter
TypeNameDescription
Int32index
Property Value
TypeDescription
Metadata.Entry

Methods

Add(Metadata.Entry)

public void Add(Metadata.Entry item)
IList<>
Parameter
TypeNameDescription
Metadata.Entryitem

Add(String, Byte[])

public void Add(string key, byte[] valueBytes)

Adds a new binary-valued metadata entry. See Metadata.Entry constructor for params.

Parameters
TypeNameDescription
Stringkey
Byte[]valueBytes

Add(String, String)

public void Add(string key, string value)

Adds a new ASCII-valued metadata entry. See Metadata.Entry constructor for params.

Parameters
TypeNameDescription
Stringkey
Stringvalue

Clear()

public void Clear()
IList<>

Contains(Metadata.Entry)

public bool Contains(Metadata.Entry item)
IList<>
Parameter
TypeNameDescription
Metadata.Entryitem
Returns
TypeDescription
Boolean

CopyTo(Metadata.Entry[], Int32)

public void CopyTo(Metadata.Entry[] array, int arrayIndex)
IList<>
Parameters
TypeNameDescription
Metadata.Entry[]array
Int32arrayIndex

Get(String)

public Metadata.Entry Get(string key)

Gets the last metadata entry with the specified key. If there are no matching entries then null is returned.

Parameter
TypeNameDescription
Stringkey
Returns
TypeDescription
Metadata.Entry

GetAll(String)

public IEnumerable<Metadata.Entry> GetAll(string key)

Gets all metadata entries with the specified key.

Parameter
TypeNameDescription
Stringkey
Returns
TypeDescription
IEnumerable<Metadata.Entry>

GetEnumerator()

public IEnumerator<Metadata.Entry> GetEnumerator()
IList<>
Returns
TypeDescription
IEnumerator<Metadata.Entry>

GetValue(String)

public string GetValue(string key)

Gets the string value of the last metadata entry with the specified key. If the metadata entry is binary then an exception is thrown. If there are no matching entries then null is returned.

Parameter
TypeNameDescription
Stringkey
Returns
TypeDescription
String

GetValueBytes(String)

public byte[] GetValueBytes(string key)

Gets the bytes value of the last metadata entry with the specified key. If the metadata entry is not binary the string value will be returned as ASCII encoded bytes. If there are no matching entries then null is returned.

Parameter
TypeNameDescription
Stringkey
Returns
TypeDescription
Byte[]

IndexOf(Metadata.Entry)

public int IndexOf(Metadata.Entry item)
IList<>
Parameter
TypeNameDescription
Metadata.Entryitem
Returns
TypeDescription
Int32

Insert(Int32, Metadata.Entry)

public void Insert(int index, Metadata.Entry item)
IList<>
Parameters
TypeNameDescription
Int32index
Metadata.Entryitem

Remove(Metadata.Entry)

public bool Remove(Metadata.Entry item)
IList<>
Parameter
TypeNameDescription
Metadata.Entryitem
Returns
TypeDescription
Boolean

RemoveAt(Int32)

public void RemoveAt(int index)
IList<>
Parameter
TypeNameDescription
Int32index