Esempio n. 1
0
        private void InheritanceMaps(MapValidator.ValidationContext context)
        {
            var enumerable = context.CurrentNode as IEnumerable<TypeMapBase>;
            var propertyMapBase = context.ParentNode as PropertyMapBase;

            Error.MapValidationException_IfPropertyMapHasMapperAndInheritanceMapsOrNothing(
                context.Map, propertyMapBase, propertyMapBase.Mapper, enumerable);
            Error.MapValidationException_IfPropertyMapIsNotForBothComplexEnumerableOrComplexTypes(context.Map, propertyMapBase);

            foreach (TypeMapBase current in enumerable)
            {
                Error.MapValidationException_IfInheritanceMapDuplicated(current, enumerable);
                Error.MapValidationException_IfInheritanceMapIsNotForDerivedTypes(context.Map, propertyMapBase, current);

                Validate(current, enumerable);
            }
        }
Esempio n. 2
0
        private void AllNodes(MapValidator.ValidationContext currentNodeContext)
        {
            var properties = currentNodeContext.CurrentNode.GetType()
                .GetProperties(BindingFlags.Instance | BindingFlags.Public);

            for (int i = 0; i < properties.Length; i++)
            {
                var propertyInfo = properties[i];
                object value = propertyInfo.GetValue(currentNodeContext.CurrentNode, null);

                if (value != null && nodeValidators.ContainsKey(propertyInfo))
                {
                    nodeValidators[propertyInfo](new MapValidator.ValidationContext
                    {
                        Map = currentNodeContext.Map,
                        CurrentNode = value,
                        ParentNode = currentNodeContext.CurrentNode
                    });
                }
            }
        }
Esempio n. 3
0
        private void PropertyMaps(MapValidator.ValidationContext context)
        {
            var enumerable = context.CurrentNode as IEnumerable<PropertyMapBase>;

            Error.MapValidationException_IfTypeMapHasMapperAndPropertyMaps(context.Map, context.Map.Mapper, enumerable);

            foreach (PropertyMapBase current in enumerable)
            {
                Error.MapValidationException_IfPropertyMapDuplicated(context.Map, current, enumerable);

                AllNodes(new MapValidator.ValidationContext
                {
                    Map = context.Map,
                    ParentNode = enumerable,
                    CurrentNode = current
                });
            }
        }
Esempio n. 4
0
        private void TypeMap(MapValidator.ValidationContext context)
        {
            Error.MapValidationException_IfTypeMapDuplicated(context.Map, context.ParentNode as IEnumerable<TypeMapBase>);
            Error.MapValidationException_IfTypeMapIsNotForComplexTypes(context.Map);

            AllNodes(context);
        }
Esempio n. 5
0
        private void ReversiveTypeMap(MapValidator.ValidationContext context)
        {
            Error.MapValidationException_IfTypeMapperOrTypeUnMapperIsNotDefined(context.Map as ReversiveTypeMap);

            TypeMap(context);
        }
Esempio n. 6
0
        private void ReversivePropertyMaps(MapValidator.ValidationContext context)
        {
            foreach (PropertyMapBase current in context.CurrentNode as IEnumerable<PropertyMapBase>)
            {
                Error.MapValidationException_IfPropertyMapperOrPropertyUnMapperIsNotDefined(context.Map, current as ReversivePropertyMap);
            }

            PropertyMaps(context);
        }