Example #1
0
        /// <summary>
        /// Creates a <see cref="PropertyNode"/> for a specified object property.<para/>
        /// If an <see cref="ObjectProperty"/> is specified, the typed value of the property will be retrieved. Otherwise, the raw value will be used.
        /// </summary>
        /// <param name="objectOrId">The object to retrieve the property from.</param>
        /// <param name="property">The <see cref="ObjectProperty"/> or raw property name of the property to retrieve.</param>
        /// <returns>A <see cref="PropertyNode"/> encapsulating the specified property.</returns>
        public PropertyNode Property(Either <IPrtgObject, int> objectOrId, Either <ObjectProperty, string> property)
        {
            object value;

            if (property.IsLeft)
            {
                value = client.GetObjectProperty(objectOrId, property.Left);
            }
            else
            {
                value = client.GetObjectPropertyRaw(objectOrId, property.Right);
            }

            return(PrtgNode.Property(objectOrId, property, value));
        }
Example #2
0
 /// <summary>
 /// Creates a <see cref="PropertyNode"/> for all properties of a specified object.
 /// </summary>
 /// <param name="objectOrId">The object to retrieve the properties from.</param>
 /// <returns>A list of <see cref="PropertyNode"/> objects encapsulating the returned properties.</returns>
 public List <PropertyNode> Properties(Either <IPrtgObject, int> objectOrId) =>
 client.GetObjectPropertiesRaw(objectOrId).Select(kv => PrtgNode.Property(objectOrId, kv.Key, kv.Value)).ToList();