Show / Hide Table of Contents

Class OrtKeyValuePairs

Class to manage key-value pairs. These are most often used for options and metadata.

Inheritance
Object
CriticalFinalizerObject
SafeHandle
OrtKeyValuePairs
Implements
IDisposable
Inherited Members
SafeHandle.handle
SafeHandle.Close()
SafeHandle.DangerousAddRef(Boolean)
SafeHandle.DangerousGetHandle()
SafeHandle.DangerousRelease()
SafeHandle.Dispose()
SafeHandle.Dispose(Boolean)
SafeHandle.SetHandle(IntPtr)
SafeHandle.SetHandleAsInvalid()
SafeHandle.IsClosed
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Microsoft.ML.OnnxRuntime
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public class OrtKeyValuePairs : SafeHandle, IDisposable

Constructors

| Improve this Doc View Source

OrtKeyValuePairs()

Create a new OrtKeyValuePairs instance.

Declaration
public OrtKeyValuePairs()
Remarks

A backing native instance is created and kept in sync with the C# content.

| Improve this Doc View Source

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 Source

Entries

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.

| Improve this Doc View Source

IsInvalid

Indicates whether the native handle is invalid.

Declaration
public override bool IsInvalid { get; }
Property Value
Type Description
Boolean
Overrides
System.Runtime.InteropServices.SafeHandle.IsInvalid

Methods

| Improve this Doc View Source

Add(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.

| Improve this Doc View Source

Refresh()

Update the cached values with the latest from the backing native instance as that is the source of truth.

Declaration
public void Refresh()
| Improve this Doc View Source

ReleaseHandle()

Release the native instance of OrtKeyValuePairs if we own it.

Declaration
protected override bool ReleaseHandle()
Returns
Type Description
Boolean

true

Overrides
System.Runtime.InteropServices.SafeHandle.ReleaseHandle()
| Improve this Doc View Source

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.

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top