public static bool CheckAttributeOrTrue<T>(IMemberAccessor memberAccessor, Predicate<T> predicate) where T : Attribute
        {
            var attribute = memberAccessor.GetCustomAttribute<T>();

            if (attribute == null)
            {
                return true;
            }

            return predicate(attribute);
        }
예제 #2
0
        private static bool CanSyncMember(IMemberAccessor propertyInfo)
        {
            if (propertyInfo.Name == "Controls")
            {
                int wtf = 0;
            }

            if (propertyInfo.GetCustomAttribute <IgnorePropertySyncAttribute>() != null)
            {
                return(false);
            }

            if (propertyInfo.GetCustomAttribute <ForcePropertySyncAttribute>() != null)
            {
                return(true);
            }

            // if we have property of the type derived from IControlDefinition it
            if (typeof(IControlDefinition).IsAssignableFrom(propertyInfo.MemberType))
            {
                return(false);
            }

            if (propertyInfo.MemberType.IsInterface && CheckIfTypeIsControlsCollection(propertyInfo.MemberType))
            {
                return(false);
            }

            foreach (var @interface in propertyInfo.MemberType.GetInterfaces())
            {
                if (CheckIfTypeIsControlsCollection(@interface))
                {
                    return(false);
                }
            }

            return(true);
        }