TryGetPropertyTypeGeneric<T> method

bool TryGetPropertyTypeGeneric<T>(
  1. PropertyDefinition propertyDefinition,
  2. OutParam<T> propertyValue
)
Tries to get a property value based on a property definition. The property definition. The property value.

Implementation

bool TryGetPropertyTypeGeneric<T>(
    PropertyDefinition propertyDefinition, OutParam<T> propertyValue) {
  // Verify that the type parameter and property definition's type are compatible.
  // todo("implement verifing")
//            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");
//            }

  OutParam<Object> value = new OutParam<Object>();

  bool result = this.TryGetProperty(propertyDefinition, value);

  if (result) {
    propertyValue.param = value.param as T?;
  } else {
    propertyValue.param = null;
  }
//            propertyValue = result ? (T)value : default(T);

  return result;
}