operator [] method

Object? operator [](
  1. PropertyDefinitionBase propertyDefinition
)
Gets the value of specified property in this instance. Definition of the property to get.

Implementation

Object? operator [](PropertyDefinitionBase propertyDefinition) {
  Object? propertyValue;

  if (propertyDefinition is PropertyDefinition) {
    return PropertyBag[propertyDefinition];
  } else {
    if (propertyDefinition is ExtendedPropertyDefinition) {
      OutParam<Object> propertyValueOutParam = OutParam();
      if (TryGetExtendedProperty(propertyDefinition, propertyValueOutParam)) {
        return propertyValue;
      } else {
        throw ServiceObjectPropertyException(
          /*Strings.MustLoadOrAssignPropertyBeforeAccess,*/
          propertyDefinition,
        );
      }
    } else {
      // Other subclasses of PropertyDefinitionBase are not supported.
      throw NotSupportedException("""string.Format(
                      Strings.OperationNotSupportedForPropertyDefinitionType,
                      propertyDefinition.GetType().Name)""");
    }
  }
}