Class OrtKeyValuePairs
Class to manage key-value pairs. These are most often used for options and metadata.
Implements
Inherited Members
Namespace: Microsoft.ML.OnnxRuntime
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public class OrtKeyValuePairs : SafeHandle, IDisposable
Constructors
| Improve this Doc View SourceOrtKeyValuePairs()
Create a new OrtKeyValuePairs instance.
Declaration
public OrtKeyValuePairs()
Remarks
A backing native instance is created and kept in sync with the C# content.
OrtKeyValuePairs(IReadOnlyDictionary<string, string>)
Create a new OrtKeyValuePairs instance from a dictionary.
Declaration
public OrtKeyValuePairs(IReadOnlyDictionary<string, string> keyValuePairs)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyDictionary<string, string> | keyValuePairs | Key-value pairs to add. |
Remarks
A backing native instance is created and kept in sync with the C# content.
Properties
| Improve this Doc View SourceEntries
Current key-value pair entries.
Declaration
public IReadOnlyDictionary<string, string> Entries { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, string> |
Remarks
Call Refresh() to update the cached values with the latest from the backing native instance. In general that should not be required as it's not expected an OrtKeyValuePairs instance would be updated by both native and C# code.
IsInvalid
Indicates whether the native handle is invalid.
Declaration
public override bool IsInvalid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Methods
| Improve this Doc View SourceAdd(string, string)
Adds a key-value pair. Overrides any existing value for the key.
Declaration
public void Add(string key, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to add. Must not be null or empty. |
| string | value | Value to add. May be empty. Must not be null. |
Refresh()
Update the cached values with the latest from the backing native instance as that is the source of truth.
Declaration
public void Refresh()
ReleaseHandle()
Release the native instance of OrtKeyValuePairs if we own it.
Declaration
protected override bool ReleaseHandle()
Returns
| Type | Description |
|---|---|
| bool | true |
Overrides
| Improve this Doc View SourceRemove(string)
Removes a key-value pair by key. Ignores keys that do not exist.
Declaration
public void Remove(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Key to remove. |