NServiceBus.MemberInfoExtensions.GetValue C# (CSharp) Method

GetValue() public static method

public static GetValue ( this member, object source ) : object
member this
source object
return object
        public static object GetValue(this MemberInfo member, object source)
        {
            var fieldInfo = member as FieldInfo;

            if (fieldInfo != null)
            {
                var field = DelegateFactory.CreateGet(fieldInfo);
                return field.Invoke(source);
            }

            var propertyInfo = (PropertyInfo) member;

            if (!propertyInfo.CanRead)
            {
                if (propertyInfo.PropertyType.IsValueType)
                {
                    return Activator.CreateInstance(propertyInfo.PropertyType);
                }

                return null;
            }

            var property = DelegateFactory.CreateGet(propertyInfo);
            return property.Invoke(source);
        }
MemberInfoExtensions