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.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()
Assembly: Grpc.Core.Api.dll
public sealed class Metadata : IList<Metadata.Entry>, ICollection<Metadata.Entry>, IEnumerable<Metadata.Entry>, IEnumerable
Constructors
Initializes a new instance of Metadata
.
Declaration
Fields
All binary headers should have this suffix.
Declaration
public const string BinaryHeaderSuffix = "-bin"
Field Value
Type |
Description |
System.String |
|
An read-only instance of metadata containing no entries.
Declaration
public static readonly Metadata Empty
Field Value
Properties
IList`1
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
IList`1
Declaration
public bool IsReadOnly { get; }
Property Value
Type |
Description |
System.Boolean |
|
IList`1
Declaration
public Metadata.Entry this[int index] { get; set; }
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Property Value
Methods
Add(Metadata.Entry)
IList`1
Declaration
public void Add(Metadata.Entry item)
Parameters
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 |
|
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 |
|
IList`1
Declaration
Contains(Metadata.Entry)
IList`1
Declaration
public bool Contains(Metadata.Entry item)
Parameters
Returns
Type |
Description |
System.Boolean |
|
CopyTo(Metadata.Entry[], Int32)
IList`1
Declaration
public void CopyTo(Metadata.Entry[] array, int arrayIndex)
Parameters
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
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> |
|
IList`1
Declaration
public IEnumerator<Metadata.Entry> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<Metadata.Entry> |
|
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.String |
|
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.
Declaration
public byte[] GetValueBytes(string key)
Parameters
Type |
Name |
Description |
System.String |
key |
|
Returns
Type |
Description |
System.Byte[] |
|
IndexOf(Metadata.Entry)
IList`1
Declaration
public int IndexOf(Metadata.Entry item)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Insert(Int32, Metadata.Entry)
IList`1
Declaration
public void Insert(int index, Metadata.Entry item)
Parameters
Remove(Metadata.Entry)
IList`1
Declaration
public bool Remove(Metadata.Entry item)
Parameters
Returns
Type |
Description |
System.Boolean |
|
IList`1
Declaration
public void RemoveAt(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Explicit Interface Implementations
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