Пример #1
0
        /// <summary>
        /// Create a dynamic type representation of a setter
        /// </summary>
        public static DynamicSetter CreateDynamicSetter(this FieldInfo fieldInfo)
        {
            if (fieldInfo == null)
            {
                throw new ArgumentNullException(nameof(fieldInfo));
            }

            var setterDelegate = FluentIl.CreateSetter(fieldInfo);

            if (setterDelegate == null)
            {
                return(null);
            }
            var access     = GetAccessModifiers(fieldInfo);
            var visibility = GetVisibilityModifiers(fieldInfo);

            return(new DynamicSetter(access, visibility, setterDelegate));
        }
Пример #2
0
        /// <summary>
        /// Create a dynamic type representation of a setter
        /// </summary>
        public static DynamicSetter CreateDynamicSetter(this PropertyInfo propertyInfo)
        {
            if (propertyInfo == null)
            {
                throw new ArgumentNullException(nameof(propertyInfo));
            }

            var setterDelegate = FluentIl.CreateSetter(propertyInfo);

            if (setterDelegate == null)
            {
                return(null);
            }
            var setMethod  = propertyInfo.GetSetMethod(true);
            var access     = GetAccessModifiers(setMethod);
            var visibility = GetVisibilityModifiers(setMethod);

            return(new DynamicSetter(access, visibility, setterDelegate));
        }