Class Metadata (2.48.0)

 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

 public Metadata() 

Initializes a new instance of Metadata .

Fields

  public 
  
 const 
  
 string 
  
 BinaryHeaderSuffix 
  
 = 
  
 null 
 

All binary headers should have this suffix.

Field Value
Type
Description
 public static readonly Metadata Empty 

An read-only instance of metadata containing no entries.

Field Value
Type
Description

Properties

 public int Count { get; } 
IList`1
Property Value
Type
Description
 public bool IsReadOnly { get; } 
IList`1
Property Value
Type
Description
  public 
  
 Metadata 
 . 
 Entry 
  
 this 
 [ 
 int 
  
 index 
 ] 
  
 { 
  
 get 
 ; 
  
 set 
 ; 
  
 } 
 
IList`1
Parameter
Name
Description
index
Property Value
Type
Description

Methods

 public void Add(Metadata.Entry item) 
IList`1
Parameter
Name
Description
 public void Add(string key, byte[] valueBytes) 

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

Parameters
Name
Description
key
valueBytes
Byte []
 public void Add(string key, string value) 

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

Parameters
Name
Description
key
value
 public void Clear() 
IList`1
 public bool Contains(Metadata.Entry item) 
IList`1
Parameter
Name
Description
Returns
Type
Description
 public void CopyTo(Metadata.Entry[] array, int arrayIndex) 
IList`1
Parameters
Name
Description
array
arrayIndex
 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
Name
Description
key
Returns
Type
Description
 public IEnumerable<Metadata.Entry> GetAll(string key) 

Gets all metadata entries with the specified key.

Parameter
Name
Description
key
Returns
Type
Description
IEnumerable < Metadata.Entry >
 public IEnumerator<Metadata.Entry> GetEnumerator() 
IList`1
Returns
Type
Description
IEnumerator < Metadata.Entry >
 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
Name
Description
key
Returns
Type
Description
 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
Name
Description
key
Returns
Type
Description
Byte []
 public int IndexOf(Metadata.Entry item) 
IList`1
Parameter
Name
Description
Returns
Type
Description
 public void Insert(int index, Metadata.Entry item) 
IList`1
Parameters
Name
Description
index
 public bool Remove(Metadata.Entry item) 
IList`1
Parameter
Name
Description
Returns
Type
Description
 public void RemoveAt(int index) 
IList`1
Parameter
Name
Description
index
Create a Mobile Website
View Site in Mobile | Classic
Share by: