IDS peak ICV v1.6.0
Loading...
Searching...
No Matches
ArchiveExtensions Class Reference

Static Public Member Functions

static void SetValue (this IArchive archive, string key, object value)
 Stores a value in the archive using runtime type dispatch.
 
static T GetValue< T > (this IArchive archive, string key)
 Retrieves a value from the archive and converts it to the requested CLR type.
 

Detailed Description

Provides convenience extension methods for setting and retrieving values from an IArchive using common CLR types.

These methods are intended as syntactic sugar over the strongly-typed IArchive API. They do not replace the explicit Set/Get methods and should primarily be used at call sites where reduced verbosity is desired.

Supported CLR types are intentionally limited to ensure predictable, cross-language behavior compatible with the C++ archive representation.

Type mapping rules:

  • bool → Bool
  • int / long → Int64
  • float / double → Double
  • string → String
  • IArchive → Archive

Unsupported CLR types are not handled by these helpers unless explicitly documented.

All archive contract rules still apply: missing keys, type mismatches, or unsupported conversions will result in exceptions.

Since
IDSImaging.Peak.Common 1.3

Member Function Documentation

◆ GetValue< T >()

static T GetValue< T > ( this IArchive archive,
string key )
inlinestatic

Retrieves a value from the archive and converts it to the requested CLR type.

Template Parameters
TThe expected CLR type of the value.
Parameters
archiveThe source archive.
keyThe key identifying the stored value.
Returns
The retrieved value converted to T .
Exceptions
CommonInvalidParameterExceptionThrown if archive is null.
CommonNotSupportedExceptionThrown if T is not supported by this helper method.
ExceptionThrown by the underlying IArchive implementation if the key does not exist or the stored value has an incompatible type.

Only a limited set of CLR types is supported. Numeric conversions are restricted to safe, explicit mappings defined by the archive contract.

This method does not perform implicit narrowing conversions.

◆ SetValue()

static void SetValue ( this IArchive archive,
string key,
object value )
inlinestatic

Stores a value in the archive using runtime type dispatch.

Parameters
archiveThe target archive.
keyThe key under which the value will be stored.
valueThe value to store. Must not be null.
Exceptions
CommonInvalidParameterExceptionThrown if archive or value is null.
CommonNotSupportedExceptionThrown if the runtime type of value is not supported.

The runtime type of value determines which IArchive setter is invoked. If a value already exists under the specified key, it is overwritten.

This method performs widening numeric conversions only (e.g. int → long, float → double).