src/openSourceC.DotNetLibrary.Core/Extensions/AttributeExtensions.cs
/// <summary>
///		Gets the element name of the <see cref="T:XmlElementAttribute"/> for the specified
///		object.
/// </summary>
/// <param name="obj">The object being extended.</param>
/// <param name="propertyName">The name of the property.</param>
/// <returns>
///		The element name of the <see cref="T:XmlElementAttribute"/> for the specified
///		object, or <b>null</b> if the attribute does not exist.
/// </returns>
Gets the element name of the  for the specified
object.
Gets the element name of the for the specified object .
public static string? GetXmlElementName(this object obj, string propertyName)
		{
			BindingFlags bindingFlags = (BindingFlags.Instance | BindingFlags.Public);
			PropertyInfo? propertyInfo = obj.GetType().GetProperty(propertyName, bindingFlags);
			if (propertyInfo == null)
			{
				return null;
			}
			return (
				propertyInfo.GetCustomAttributes(typeof(XmlElementAttribute), true).SingleOrDefault() is XmlElementAttribute attribute
				? attribute.ElementName
				: null
			);
		}
public static string ? GetXmlElementName ( this object obj , string propertyName ) { BindingFlags bindingFlags = ( BindingFlags . Instance | BindingFlags . Public ) ; PropertyInfo ? propertyInfo = obj . GetType ( ) . GetProperty ( propertyName , bindingFlags ) ; if ( propertyInfo == null ) { return null ; } return ( propertyInfo . GetCustomAttributes ( typeof ( XmlElementAttribute ) , true ) . SingleOrDefault ( ) is XmlElementAttribute attribute ? attribute . ElementName : null ) ; }
Gets the element name of the  for the specified
object.
Gets the element name of the for the specified object .
The element name of the  for the specified
object, or null
The element name of the for the specified object or null
object
this
propertyName
string
The name of the property.
The name of the property .
obj
The object being extended.
The object being extended .