Ejemplo n.º 1
0
        /// <summary>
        /// Creates the wrapped object property wrapper.
        /// </summary>
        private static PropertyDescriptor CreateWrappedObjectPropertyWrapper(TypeMetaData context, PropertyInfo property)
        {
            IDelegatePropertyReader actualReader = GetPropertyReader(property, context);
            IDelegatePropertyWriter actualWriter = GetPropertyWriter(property, context);

            Func<object, object> reader = property.CanRead ? new Func<object, object>(o => ((IEditable)o).ReadProperty(property)) : null;
            Action<object, object> writer = property.CanWrite ? new Action<object, object>((o, v) => ((IEditable)o).WriteProperty(property, v)) : null;

            DelegatePropertyDescriptor descriptor = new DelegatePropertyDescriptor(
                property.Name,
                property.DeclaringType,
                property.PropertyType,
                reader,
                writer
                );
            return descriptor;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the wrapper object property wrapper.
        /// </summary>
        private static PropertyDescriptor CreateWrapperObjectPropertyWrapper(TypeMetaData context, PropertyInfo property)
        {
            IDelegatePropertyReader actualReader = GetPropertyReader(property, context);
            IDelegatePropertyWriter actualWriter = GetPropertyWriter(property, context);

            Func <object, object>   reader = property.CanRead ? new Func <object, object>(o => actualReader.GetValue(o)) : null;
            Action <object, object> writer = property.CanWrite ? new Action <object, object>((o, v) => actualWriter.SetValue(o, v)) : null;

            DelegatePropertyDescriptor descriptor = new DelegatePropertyDescriptor(
                property.Name,
                property.DeclaringType,
                property.PropertyType,
                reader,
                writer
                );

            return(descriptor);
        }