Ejemplo n.º 1
0
 public static ValidatorBase ClassValidator(this object source)
 {
     if (source is Type)
     {
         return(new ClassValidator(s_VE.GetClassValidator((Type)source)));
     }
     return(new ClassValidator(s_VE.GetClassValidator(source.GetType())));
 }
Ejemplo n.º 2
0
        private void GivingRulesFor(string propertyName, out ITagableRule minAttribute, out ITagableRule maxAttribute)
        {
            IClassValidator         cv = ve.GetClassValidator(typeof(EntityXml));
            IEnumerable <Attribute> ma = cv.GetMemberConstraints(propertyName);

            minAttribute = (ITagableRule)ma.First(a => a.TypeId == minTypeId);
            maxAttribute = (ITagableRule)ma.First(a => a.TypeId == maxTypeId);
        }
 private static void ApplyValidatorToDDL(PersistentClass persistentClass, ValidatorEngine ve)
 {
     try
     {
         IClassValidator classValidator = ve.GetClassValidator(persistentClass.MappedClass);
         classValidator.Apply(persistentClass);
     }
     catch (Exception ex)
     {
         log.Warn(
             string.Format("Unable to apply constraints on DDL for [MappedClass={0}]", persistentClass.MappedClass.FullName), ex);
     }
 }
Ejemplo n.º 4
0
 private static void ApplyValidatorToDDL(PersistentClass persistentClass, ValidatorEngine ve)
 {
     try
     {
         IClassValidator classValidator = ve.GetClassValidator(persistentClass.MappedClass);
         classValidator.Apply(persistentClass);
     }
     catch (Exception ex)
     {
         log.Warn(
             string.Format("Unable to apply constraints on DDL for [MappedClass={0}]", persistentClass.MappedClass.FullName), ex);
     }
 }
Ejemplo n.º 5
0
        private static void ConfigureValidatorFromDDL(PersistentClass persistentClass, ValidatorEngine ve)
        {
            try
            {
                if (persistentClass.MappedClass == null)
                {
                    return;
                }
                IClassValidator classValidator = ve.GetClassValidator(persistentClass.MappedClass);
                classValidator.ConfigureFrom(persistentClass.PropertyClosureIterator);
            }
            catch (Exception ex)
            {
#if NETFX
                log.Warn(
                    string.Format("Unable to auto generate validators from mapping for [MappedClass={0}]", persistentClass.MappedClass.FullName), ex);
#else
                Log.Warn(ex, "Unable to auto generate validators from mapping for [MappedClass={0}]", persistentClass.MappedClass.FullName);
#endif
            }
        }
Ejemplo n.º 6
0
        private static void ApplyValidatorToDDL(PersistentClass persistentClass, ValidatorEngine ve)
        {
            try
            {
                if (!persistentClass.HasPocoRepresentation)
                {
                    return;
                }
                IClassValidator classValidator = ve.GetClassValidator(persistentClass.MappedClass);
                classValidator.Apply(persistentClass);
            }
            catch (Exception ex)
            {
#if NETFX
                log.Warn(
                    string.Format("Unable to apply constraints on DDL for [MappedClass={0}]", persistentClass.MappedClass.FullName), ex);
#else
                Log.Warn(ex, "Unable to apply constraints on DDL for [MappedClass={0}]", persistentClass.MappedClass.FullName);
#endif
            }
        }
 public override IClassValidator GetClassValidator(System.Type type)
 {
     return(ve.GetClassValidator(type));
 }