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