/// <summary>
        /// Gets the value of specified property in this instance.
        /// </summary>
        /// <param name="propertyDefinition">Definition of the property to get.</param>
        /// <exception cref="ServiceVersionException">Raised if this property requires a later version of Exchange.</exception>
        /// <exception cref="PropertyException">Raised if this property hasn't been assigned or loaded. Raised for set if property cannot be updated or deleted.</exception>
        public object this[PropertyDefinitionBase propertyDefinition]
        {
            get
            {
                object propertyValue;

                PropertyDefinition propDef = propertyDefinition as PropertyDefinition;
                if (propDef != null)
                {
                    return(this.PropertyBag[propDef]);
                }
                else
                {
                    ExtendedPropertyDefinition extendedPropDef = propertyDefinition as ExtendedPropertyDefinition;
                    if (extendedPropDef != null)
                    {
                        if (this.TryGetExtendedProperty(extendedPropDef, out propertyValue))
                        {
                            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));
                    }
                }
            }
        }
        /// <summary>
        /// Try to get the value of a specified property in this instance.
        /// </summary>
        /// <param name="propertyDefinition">The property definition.</param>
        /// <param name="propertyValue">The property value.</param>
        /// <typeparam name="T">Type of expected property value.</typeparam>
        /// <returns>True if property retrieved, false otherwise.</returns>
        public bool TryGetProperty <T>(PropertyDefinitionBase propertyDefinition, out T propertyValue)
        {
            PropertyDefinition propDef = propertyDefinition as PropertyDefinition;

            if (propDef != null)
            {
                return(this.PropertyBag.TryGetProperty <T>(propDef, out propertyValue));
            }
            else
            {
                ExtendedPropertyDefinition extPropDef = propertyDefinition as ExtendedPropertyDefinition;
                if (extPropDef != null)
                {
                    return(this.TryGetExtendedProperty <T>(extPropDef, out propertyValue));
                }
                else
                {
                    // Other subclasses of PropertyDefinitionBase are not supported.
                    throw new NotSupportedException(string.Format(
                                                        Strings.OperationNotSupportedForPropertyDefinitionType,
                                                        propertyDefinition.GetType().Name));
                }
            }
        }