TryGetValue<T> method

bool TryGetValue<T>(
  1. ExtendedPropertyDefinition propertyDefinition,
  2. OutParam<T> propertyValueOut
)
Tries to get property value. The property definition. The property value.

Implementation

bool TryGetValue<T>(
  ExtendedPropertyDefinition propertyDefinition,
  OutParam<T> propertyValueOut,
) {
  ExtendedProperty? extendedProperty;
  OutParam<ExtendedProperty> extendedPropertyOut =
      OutParam<ExtendedProperty>();
  if (_TryGetProperty(propertyDefinition, extendedPropertyOut)) {
    extendedProperty = extendedPropertyOut.param;
    // todo ("implement runtimeType check")
    //      if (T.runtimeType is propertyDefinition.Type) {
    //        String errorMessage = String.format(
    //            "Property definition type '%s' and type parameter '%s' aren't compatible.",
    //            propertyDefinition.getType().getSimpleName(),
    //            cls.getSimpleName());
    //        throw new ArgumentException(errorMessage, "propertyDefinition");
    //      }
    propertyValueOut.param = extendedProperty!.Value as T?;
    return true;
  } else {
    propertyValueOut.param = null;
    return false;
  }
  //  ExtendedProperty extendedProperty;
  //  if (this.TryGetProperty(propertyDefinition, out extendedProperty))
  //  {
  //  // Verify that the type parameter and property definition's type are compatible.
  //  if (!typeof(T).IsAssignableFrom(propertyDefinition.Type))
  //  {
  //  String errorMessage = string.Format(
  //  Strings.PropertyDefinitionTypeMismatch,
  //  EwsUtilities.GetPrintableTypeName(propertyDefinition.Type),
  //  EwsUtilities.GetPrintableTypeName(typeof(T)));
  //  throw new ArgumentException(errorMessage, "propertyDefinition");
  //  }
  //
  //  propertyValue = (T)extendedProperty.Value;
  //  return true;
  //  }
  //  else
  //  {
  //  propertyValue = default(T);
  //  return false;
  //  }
}