Read a property - Metasys - LIT-12013522 - Software Application - Basic Services client library for .NET (and COM) - Metasys API - 4.2

Metasys REST Client for .NET and COM Developer Guide

Brand
Metasys
Product name
Basic Services client library for .NET (and COM)
Metasys API
Document type
API Reference Guide
Document number
LIT-12013522
Version
4.2
Revision date
2021-04-07
Language
English

To read a property of an object, you must know the GUID of the target object. When you request a property from an object, you receive a variant object. A variant can represent many data types and consequently you might get properties in addition to the one you want. If the server cannot find the target object or property on the object, this method raises an exception.

Table 1. Read a property .NET signature
Library method name ReadProperty
Description Read a property of an object.
Method signature Variant ReadProperty(Guid id, string attributeName);
Method input parameters
  • id: the GUID of the object. The method reads the attribute value using the GUID.
  • attributeName: the name of the attribute to read, for example presentValue.
Return value Variant object
The following .NET C# code is an example of a successful property read:
Variant property = client.ReadProperty(objectId, "presentValue");
//Since we know the present value is numeric we can extract it from the variant:
var rawValue = property.NumericValue;
Console.WriteLine(rawValue);
/*
Outputs:
72.0
/*