Esempio n. 1
0
        internal static TypeErrorsBuilder CheckIndexers(this TypeErrorsBuilder typeErrors, Type type, MemberSettings settings)
        {
            var propertiesSettings = settings as PropertiesSettings;
            var propertyInfos      = type.GetProperties(settings.BindingFlags);

            foreach (var propertyInfo in propertyInfos)
            {
                if (propertyInfo.GetIndexParameters().Length == 0)
                {
                    continue;
                }

                if (propertiesSettings?.IsIgnoringProperty(propertyInfo) == true)
                {
                    continue;
                }

                if (settings.IsIgnoringDeclaringType(propertyInfo.DeclaringType))
                {
                    continue;
                }

                typeErrors = typeErrors.CreateIfNull(type)
                             .Add(UnsupportedIndexer.GetOrCreate(propertyInfo));
            }

            return(typeErrors);
        }
Esempio n. 2
0
        internal static TypeErrorsBuilder CheckNotifies(this TypeErrorsBuilder typeErrors, Type type, MemberSettings settings)
        {
            if (settings.IsImmutable(type))
            {
                return(typeErrors);
            }

            if (typeof(IEnumerable).IsAssignableFrom(type))
            {
                if (!typeof(INotifyCollectionChanged).IsAssignableFrom(type))
                {
                    return(typeErrors.CreateIfNull(type)
                           .Add(CollectionMustNotifyError.GetOrCreate(type)));
                }
            }
            else if (!typeof(INotifyPropertyChanged).IsAssignableFrom(type))
            {
                if (settings.IsIgnoringDeclaringType(type))
                {
                    return(typeErrors);
                }

                return(typeErrors.CreateIfNull(type)
                       .Add(TypeMustNotifyError.GetOrCreate(type)));
            }

            return(typeErrors);
        }
Esempio n. 3
0
        internal static TypeErrorsBuilder CheckIndexers(this TypeErrorsBuilder typeErrors, Type type, MemberSettings settings)
        {
            var propertiesSettings = settings as PropertiesSettings;
            var propertyInfos = type.GetProperties(settings.BindingFlags);
            foreach (var propertyInfo in propertyInfos)
            {
                if (propertyInfo.GetIndexParameters().Length == 0)
                {
                    continue;
                }

                if (propertiesSettings?.IsIgnoringProperty(propertyInfo) == true)
                {
                    continue;
                }

                if (settings.IsIgnoringDeclaringType(propertyInfo.DeclaringType))
                {
                    continue;
                }

                typeErrors = typeErrors.CreateIfNull(type)
                                       .Add(UnsupportedIndexer.GetOrCreate(propertyInfo));
            }

            return typeErrors;
        }
Esempio n. 4
0
        internal static TypeErrorsBuilder CheckNotifies(this TypeErrorsBuilder typeErrors, Type type, MemberSettings settings)
        {
            if (settings.IsImmutable(type))
            {
                return typeErrors;
            }

            if (type.IsValueType)
            {
                if (typeof(INotifyCollectionChanged).IsAssignableFrom(type) ||
                    typeof(INotifyPropertyChanged).IsAssignableFrom(type))
                {
                    return typeErrors.CreateIfNull(type)
                                     .Add(StructMustNotNotifyError.GetOrCreate(type));
                }

                return typeErrors;
            }

            if (typeof(IEnumerable).IsAssignableFrom(type))
            {
                if (!typeof(INotifyCollectionChanged).IsAssignableFrom(type))
                {
                    return typeErrors.CreateIfNull(type)
                                           .Add(CollectionMustNotifyError.GetOrCreate(type));
                }
            }
            else if (!typeof(INotifyPropertyChanged).IsAssignableFrom(type))
            {
                if (settings.IsIgnoringDeclaringType(type))
                {
                    return typeErrors;
                }

                return typeErrors.CreateIfNull(type)
                                 .Add(TypeMustNotifyError.GetOrCreate(type));
            }

            return typeErrors;
        }