Show / Hide Table of Contents

    Class Metadata

    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
    System.Object
    Metadata
    Implements
    System.Collections.Generic.IList<Metadata.Entry>
    System.Collections.Generic.ICollection<Metadata.Entry>
    System.Collections.Generic.IEnumerable<Metadata.Entry>
    System.Collections.IEnumerable
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Grpc.Core
    Assembly: Grpc.Core.Api.dll
    Syntax
    public sealed class Metadata : IList<Metadata.Entry>, ICollection<Metadata.Entry>, IEnumerable<Metadata.Entry>, IEnumerable

    Constructors

    Metadata()

    Initializes a new instance of Metadata.

    Declaration
    public Metadata()

    Fields

    BinaryHeaderSuffix

    All binary headers should have this suffix.

    Declaration
    public const string BinaryHeaderSuffix = "-bin"
    Field Value
    Type Description
    System.String

    Empty

    An read-only instance of metadata containing no entries.

    Declaration
    public static readonly Metadata Empty
    Field Value
    Type Description
    Metadata

    Properties

    Count

    IList`1
    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    IsReadOnly

    IList`1
    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    System.Boolean

    Item[Int32]

    IList`1
    Declaration
    public Metadata.Entry this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type Description
    Metadata.Entry

    Methods

    Add(Metadata.Entry)

    IList`1
    Declaration
    public void Add(Metadata.Entry item)
    Parameters
    Type Name Description
    Metadata.Entry item

    Add(String, Byte[])

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

    Declaration
    public void Add(string key, byte[] valueBytes)
    Parameters
    Type Name Description
    System.String key
    System.Byte[] valueBytes

    Add(String, String)

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

    Declaration
    public void Add(string key, string value)
    Parameters
    Type Name Description
    System.String key
    System.String value

    Clear()

    IList`1
    Declaration
    public void Clear()

    Contains(Metadata.Entry)

    IList`1
    Declaration
    public bool Contains(Metadata.Entry item)
    Parameters
    Type Name Description
    Metadata.Entry item
    Returns
    Type Description
    System.Boolean

    CopyTo(Metadata.Entry[], Int32)

    IList`1
    Declaration
    public void CopyTo(Metadata.Entry[] array, int arrayIndex)
    Parameters
    Type Name Description
    Metadata.Entry[] array
    System.Int32 arrayIndex

    Get(String)

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

    Declaration
    public Metadata.Entry? Get(string key)
    Parameters
    Type Name Description
    System.String key
    Returns
    Type Description
    System.Nullable<Metadata.Entry>

    GetAll(String)

    Gets all metadata entries with the specified key.

    Declaration
    public IEnumerable<Metadata.Entry> GetAll(string key)
    Parameters
    Type Name Description
    System.String key
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<Metadata.Entry>

    GetEnumerator()

    IList`1
    Declaration
    public IEnumerator<Metadata.Entry> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<Metadata.Entry>

    GetValue(String)

    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.

    Declaration
    public string? GetValue(string key)
    Parameters
    Type Name Description
    System.String key
    Returns
    Type Description
    System.Nullable<System.String>

    IndexOf(Metadata.Entry)

    IList`1
    Declaration
    public int IndexOf(Metadata.Entry item)
    Parameters
    Type Name Description
    Metadata.Entry item
    Returns
    Type Description
    System.Int32

    Insert(Int32, Metadata.Entry)

    IList`1
    Declaration
    public void Insert(int index, Metadata.Entry item)
    Parameters
    Type Name Description
    System.Int32 index
    Metadata.Entry item

    Remove(Metadata.Entry)

    IList`1
    Declaration
    public bool Remove(Metadata.Entry item)
    Parameters
    Type Name Description
    Metadata.Entry item
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

    IList`1
    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    Implements

    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    In This Article
    • Constructors
      • Metadata()
    • Fields
      • BinaryHeaderSuffix
      • Empty
    • Properties
      • Count
      • IsReadOnly
      • Item[Int32]
    • Methods
      • Add(Metadata.Entry)
      • Add(String, Byte[])
      • Add(String, String)
      • Clear()
      • Contains(Metadata.Entry)
      • CopyTo(Metadata.Entry[], Int32)
      • Get(String)
      • GetAll(String)
      • GetEnumerator()
      • GetValue(String)
      • IndexOf(Metadata.Entry)
      • Insert(Int32, Metadata.Entry)
      • Remove(Metadata.Entry)
      • RemoveAt(Int32)
    • Explicit Interface Implementations
      • IEnumerable.GetEnumerator()
    • Implements
    Back to top Generated by DocFX