src/Common.Logging.Sitecore/Extensions/Extensions.cs
/// <summary>
/// Returns a _private_ Property Value from a given Object. Uses Reflection.
///     Throws a ArgumentOutOfRangeException if the Property is not found.
/// </summary>
/// <typeparam name="T">
/// Type of the Property
/// </typeparam>
/// <param name="obj">
/// Object from where the Property Value is returned
/// </param>
/// <param name="propName">
/// Propertyname as string.
/// </param>
/// <returns>
/// PropertyValue
/// </returns>
Returns a _private_ Property Value from a given Object. Uses Reflection.
Throws a ArgumentOutOfRangeException if the Property is not found.
Returns a _private_ Property Value from a given Object . Uses Reflection . Throws a ArgumentOutOfRangeException if the Property is not found .
public static T GetPrivatePropertyValue<T>(this object obj, string propName)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }
            var pi = obj.GetType()
                .GetProperty(propName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            if (pi == null)
            {
                throw new ArgumentOutOfRangeException(
                    nameof(propName), 
                    $"Property {propName} was not found in Type {obj.GetType().FullName}");
            }
            return (T)pi.GetValue(obj, null);
        }
public static T GetPrivatePropertyValue < T > ( this object obj , string propName ) { if ( obj == null ) { throw new ArgumentNullException ( nameof ( obj ) ) ; } var pi = obj . GetType ( ) . GetProperty ( propName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ; if ( pi == null ) { throw new ArgumentOutOfRangeException ( nameof ( propName ) , $" Property  { propName }  was not found in Type  { obj . GetType ( ) . FullName } " ) ; } return ( T ) pi . GetValue ( obj , null ) ; }
Returns a _private_ Property Value from a given Object.
Returns a _private_ Property Value from a given Object .
None
object
this
propName
string
Propertyname as string.
Propertyname as string .
obj
Object from where the Property Value is returned
Object from where the Property Value is returned
typeparam
Type of the Property
Type of the Property