Example #1
0
        public FieldReference(object target, FieldInfo field)
        {
            SRDebugUtil.AssertNotNull(target);

            _target = target;
            _field  = field;
        }
Example #2
0
        public PropertyReference(object target, PropertyInfo property)
        {
            SRDebugUtil.AssertNotNull(target);

            _target   = target;
            _property = property;
        }
Example #3
0
        public MethodReference(object target, MethodInfo method)
        {
            SRDebugUtil.AssertNotNull(target);

            _target = target;
            _method = method;
        }
Example #4
0
        /// <summary>
        /// Create a property reference from an object target and reflection PropertyInfo.
        /// This represents a property on an object.
        /// </summary>
        public PropertyReference(object target, PropertyInfo property)
        {
            SRDebugUtil.AssertNotNull(target);
            SRDebugUtil.AssertNotNull(property);

            PropertyType = property.PropertyType;
            _property    = property;
            _target      = target;

#if NETFX_CORE
            if (_property.GetMethod != null && _property.GetMethod.IsPublic)
#else
            if (property.GetGetMethod() != null)
#endif
            {
                _getter = () => SRReflection.GetPropertyValue(target, property);
            }


#if NETFX_CORE
            if (_property.SetMethod != null && _property.SetMethod.IsPublic)
#else
            if (property.GetSetMethod() != null)
#endif
            {
                _setter = (v) => SRReflection.SetPropertyValue(target, property, v);
            }
        }
Example #5
0
        /// <summary>
        /// Create a property reference from lambdas. This has no underlying reflection or object associated with it.
        /// </summary>
        public PropertyReference(Type type, Func <object> getter = null, Action <object> setter = null, Attribute[] attributes = null)
        {
            SRDebugUtil.AssertNotNull(type);

            PropertyType = type;
            _attributes  = attributes;
            _getter      = getter;
            _setter      = setter;
        }
Example #6
0
        public CustomReference(Type type, string name, Func <object> get, Action <object> set)
        {
            SRDebugUtil.AssertNotNull(get);
            SRDebugUtil.AssertNotNull(set);

            _type = type;
            _name = name;
            _get  = get;
            _set  = set;
        }
Example #7
0
        public MethodReference(object target, MethodInfo method)
        {
            SRDebugUtil.AssertNotNull(target);

            _method = o => method.Invoke(target, o);
        }
Example #8
0
 protected void AssertNotNull(object value, string fieldName = null)
 {
     SRDebugUtil.AssertNotNull(value, fieldName, this);
 }