Class OrtKeyValuePairs
Class to manage key-value pairs. These are most often used for options and metadata.
Inheritance
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 |
---|---|
Boolean |
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 |
---|---|
Boolean | true |
Overrides
Remove(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. |