/// <summary> /// Indicates that access to the property of the given name is finished by removing it from the current thread's stack of property names. /// </summary> /// <remarks>This method must be executed after a property previously prepared via <see cref="PreparePropertyAccess"/> has been accessed as needed. /// It is automatically invoked for virtual properties in domain objects created with interception suppport and thus doesn't /// have to be called manually for these objects. If you choose to invoke <see cref="PreparePropertyAccess"/> and /// <see cref="PropertyAccessFinished"/> yourself, be sure to invoke this method in a finally-block in order to guarantee its execution.</remarks> /// <exception cref="InvalidOperationException">There is no property to be finished. There is likely a mismatched number of calls to /// <see cref="PreparePropertyAccess"/> and <see cref="PropertyAccessFinished"/>.</exception> public static void PropertyAccessFinished() { if (CurrentPropertyNames.Count == 0) { throw new InvalidOperationException("There is no property to finish."); } CurrentPropertyNames.Pop(); }
/// <summary> /// Prepares access to the <see cref="PropertyValue"/> of the given name by pushing its name on top of the current thread's stack of property /// names. /// </summary> /// <param name="propertyName">The name of the property to be accessed.</param> /// <remarks>This method prepares the given property for access via <see cref="DomainObject.CurrentProperty"/>. /// It is automatically invoked for virtual properties in domain objects created with interception support and thus doesn't /// have to be called manually for these objects. If you choose to invoke <see cref="PreparePropertyAccess"/> and /// <see cref="PropertyAccessFinished"/> yourself, be sure to finish the property access with exactly one call to /// <see cref="PropertyAccessFinished"/> from a finally-block.</remarks> /// <exception cref="System.ArgumentNullException"><paramref name="propertyName"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// <paramref name="propertyName"/> is an empty string.<br /> -or- <br /> /// The <paramref name="propertyName"/> parameter does not denote a valid property. /// </exception> public static void PreparePropertyAccess(string propertyName) { ArgumentUtility.CheckNotNullOrEmpty("propertyName", propertyName); CurrentPropertyNames.Push(propertyName); }