Skip to content

Commit

Permalink
[FIX] some missing doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanael smiechowski committed Oct 23, 2024
1 parent 308f685 commit f2c81ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 17 additions & 2 deletions uml4net/Decorators/ReferencedPropertyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,29 @@ public ReferencedPropertyAttribute(string propertyName)
{
this.PropertyName = propertyName;
}

/// <summary>
/// Retrieves the property name from the <see cref="ReferencedPropertyAttribute"/> of the specified <see cref="IReferenceable{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type parameter of the referenced element.</typeparam>
/// <param name="instance">The instance of the <see cref="IReferenceable{T}"/> interface from which the property name is retrieved.</param>
/// <returns>The name of the referenced property specified in the <see cref="ReferencedPropertyAttribute"/>.</returns>
/// <exception cref="InvalidOperationException">Thrown if the referenced property cannot be found.</exception>
public static string GetName<T>(IReferenceable<T> instance)
{
var memberInfo = GetExplicitInterfaceProperty(instance);
var customAttribute = Attribute.GetCustomAttribute(memberInfo, typeof(ReferencedPropertyAttribute));
return ((ReferencedPropertyAttribute)customAttribute).PropertyName;
}


/// <summary>
/// Retrieves the <see cref="PropertyInfo"/> of the explicit interface implementation for the <see cref="IReferenceable{T}.Reference"/> property.
/// </summary>
/// <typeparam name="T">The type parameter of the referenced element.</typeparam>
/// <param name="instance">The instance of the <see cref="IReferenceable{T}"/> interface to inspect.</param>
/// <returns>
/// The <see cref="PropertyInfo"/> of the <see cref="IReferenceable{T}.Reference"/> property.
/// </returns>
/// <exception cref="InvalidOperationException">Thrown if the explicit interface implementation of the Reference property is not found.</exception>
public static PropertyInfo GetExplicitInterfaceProperty<T>(IReferenceable<T> instance)
{
var instanceType = instance.GetType();
Expand Down
7 changes: 7 additions & 0 deletions uml4net/POCO/Values/StringExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public class StringExpression : XmiElement, IStringExpression, IReferenceable<IS
[Implements(implementation: "INamedElement.NameExpression")]
public IStringExpression NameExpression { get; set; }

/// <summary>
/// Gets or sets the reference to the NameExpression owned by this element.
/// </summary>
/// <remarks>
/// This property implements the <see cref="IReferenceable{T}"/> interface,
/// providing access to the owned comments through the <see cref="NameExpression"/> property.
/// </remarks>
IStringExpression IReferenceable<IStringExpression>.Reference
{
get => this.NameExpression;
Expand Down

0 comments on commit f2c81ad

Please sign in to comment.