/// <summary> /// Returns the property value with the specified property name (if it exists), otherwise the fallback value is /// returned. /// </summary> /// <typeparam name="TValue">The type of the value.</typeparam> /// <param name="source">The propset.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="fallbackValue">The fallback value.</param> /// <returns> /// Returns the <see cref="object" /> casted to the specified /// <param ref="TValue" /> /// for the property. /// </returns> public static TValue GetValue <TValue>(this IMMWMSPropertySet source, string propertyName, TValue fallbackValue) { if (source == null || !source.Exists(propertyName)) { return(fallbackValue); } return(TypeCast.Cast(source.GetProperty(propertyName), fallbackValue)); }
/// <summary> /// Sets the property value for the specified name (if it exists). /// </summary> /// <param name="source">The propset.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="propertyValue">The property value.</param> /// <returns> /// Returns a <see cref="bool" /> representing <c>true</c> if the property was updated; otherwise <c>false</c>. /// </returns> public static bool SetValue(this IMMWMSPropertySet source, string propertyName, object propertyValue) { if (source == null || !source.Exists(propertyName)) { return(false); } source.SetProperty(propertyName, propertyValue); return(true); }