src/openSourceC.DotNetLibrary.Core/Extensions/AttributeExtensions.cs
/// <summary>
///		Gets the attribute name of the <see cref="T:XmlAttributeAttribute"/> for the
///		specified object.
/// </summary>
/// <param name="obj">The object being extended.</param>
/// <param name="propertyName">The name of the property.</param>
/// <returns>
///		The attribute name of the <see cref="T:XmlAttributeAttribute"/> for the specified
///		object, or <b>null</b> if the attribute does not exist.
/// </returns>
Gets the attribute name of the  for the
specified object.
Gets the attribute name of the for the specified object .
public static string? GetXmlAttributeName(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 XmlAttributeAttribute attribute
				? attribute.AttributeName
				: null
			);
		}
public static string ? GetXmlAttributeName ( 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 XmlAttributeAttribute attribute ? attribute . AttributeName : null ) ; }
Gets the attribute name of the  for the
specified object.
Gets the attribute name of the for the specified object .
The attribute name of the  for the specified
object, or null
The attribute 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 .