/// <summary> /// Returns true if the status is bad or uncertain. /// </summary> /// <remarks> /// Returns true if the status is bad or uncertain. /// </remarks> /// <param name="value">The value to check the quality of</param> public static bool IsNotGood(DataValue value) { if (value != null) { return StatusCode.IsNotGood(value.m_statusCode); } return true; }
/// <summary> /// Returns true if the status is bad or uncertain. /// </summary> public static bool IsNotGood(ServiceResult status) { if (status != null) { return(StatusCode.IsNotGood(status.m_code)); } return(true); }
/// <summary> /// Gets the value from the data value. /// </summary> /// <typeparam name="T">The type of object.</typeparam> /// <param name="defaultValue">The default value to return if any error occurs.</param> /// <returns>The value.</returns> /// <remarks> /// Does not throw exceptions; returns the caller provided value instead. /// Extracts the body from an ExtensionObject value if it has the correct type. /// Checks the StatusCode and returns an error if not Good. /// </remarks> public T GetValue<T>(T defaultValue) { if (StatusCode.IsNotGood(this.StatusCode)) { return defaultValue; } if (typeof(T).IsInstanceOfType(this.Value)) { return (T) this.Value; } ExtensionObject extension = this.Value as ExtensionObject; if (extension != null) { if (typeof(T).IsInstanceOfType(extension.Body)) { return (T) extension.Body; } } return defaultValue; }