예제 #1
0
        protected void SetMemberValue <T>(MemberInfo memberInfo, T instance)
        {
            if (memberInfo is PropertyInfo && BuilderSetup.ShouldIgnoreProperty((PropertyInfo)memberInfo))
            {
                return;
            }
            var currentValue = memberInfo.GetFieldOrPropertyValue(instance);

            if (!currentValue.IsDefaultValue())
            {
                return;
            }

            var handler = GetTypeHandler(memberInfo);

            if (handler == null)
            {
                return;
            }
            var value = handler.Method.GetParameters().Length == 1 ?
                        handler.DynamicInvoke(memberInfo) :
                        handler.DynamicInvoke();

            memberInfo.SetFieldOrPropertyValue(instance, value);
        }
예제 #2
0
        protected virtual bool ShouldIgnore(MemberInfo memberInfo)
        {
            if (memberInfo is PropertyInfo)
            {
                if (BuilderSetup.ShouldIgnoreProperty(((PropertyInfo)memberInfo)))
                {
                    return(true);
                }
            }

            return(false);
        }