hubitat2prom/HubitatDevice/DeviceSummaryAttributes.cs
/// <summary>
/// Return the name and value of each property in this class instance.
/// </summary>
Return the name and value of each property in this class instance.
Return the name and value of each property in this class instance .
public IEnumerator<KeyValuePair<string, AttributeValue?>> GetEnumerator()
    {
        return this.GetType().GetProperties(
              BindingFlags.Public
            | BindingFlags.Instance
            | BindingFlags.DeclaredOnly
        )
        .Select(propertyInfo =>
        {
            AttributeValue? attributeValue = null;
            var value = propertyInfo.GetValue(this);
            if (value is string @string) attributeValue = AttributeValue.FromT0(@string);
            if (value is string[] stringValue) attributeValue = AttributeValue.FromT1(stringValue);
            if (value is int @int) attributeValue = AttributeValue.FromT2(@int);
            if (value is double @double) attributeValue = AttributeValue.FromT3(@double);
            if (value is OneOfDoubleString oneOfDoubleString) attributeValue = AttributeValue.FromT4(oneOfDoubleString);
            return new KeyValuePair<string, AttributeValue?>(
                propertyInfo.Name,
                attributeValue
            );
        })
        .GetEnumerator();
    }
public IEnumerator < KeyValuePair < string , AttributeValue ? > > GetEnumerator ( ) { return this . GetType ( ) . GetProperties ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) . Select ( propertyInfo => { AttributeValue ? attributeValue = null ; var value = propertyInfo . GetValue ( this ) ; if ( value is string @string ) attributeValue = AttributeValue . FromT0 ( @string ) ; if ( value is string [ ] stringValue ) attributeValue = AttributeValue . FromT1 ( stringValue ) ; if ( value is int @int ) attributeValue = AttributeValue . FromT2 ( @int ) ; if ( value is double @double ) attributeValue = AttributeValue . FromT3 ( @double ) ; if ( value is OneOfDoubleString oneOfDoubleString ) attributeValue = AttributeValue . FromT4 ( oneOfDoubleString ) ; return new KeyValuePair < string , AttributeValue ? > ( propertyInfo . Name , attributeValue ) ; } ) . GetEnumerator ( ) ; }
Return the name and value of each property in this class instance.
Return the name and value of each property in this class instance .