예제 #1
0
        string TypeAuthCache_StaticPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
        {
            RuleTypeEntity rt = (RuleTypeEntity)sender;

            if (rt.Resource == null)
            {
                if (rt.Conditions.Any())
                {
                    return("Default {0} should not have conditions".FormatWith(typeof(RuleTypeEntity).NiceName()));
                }

                return(null);
            }

            Type type       = TypeLogic.EntityToType[rt.Resource];
            var  conditions = rt.Conditions.Where(a =>
                                                  a.Condition.FieldInfo != null && /*Not 100% Sync*/
                                                  !TypeConditionLogic.IsDefined(type, a.Condition));

            if (conditions.IsEmpty())
            {
                return(null);
            }

            return("Type {0} has no definitions for the conditions: {1}".FormatWith(type.Name, conditions.CommaAnd(a => a.Condition.Key)));
        }
예제 #2
0
        string?TypeAuthCache_StaticPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
        {
            RuleTypeEntity rt = (RuleTypeEntity)sender;

            if (rt.Resource == null)
            {
                if (rt.Conditions.Any())
                {
                    return("Default {0} should not have conditions".FormatWith(typeof(RuleTypeEntity).NiceName()));
                }

                return(null);
            }

            try
            {
                Type type       = TypeLogic.EntityToType.GetOrThrow(rt.Resource);
                var  conditions = rt.Conditions.Where(a =>
                                                      a.Condition.FieldInfo != null && /*Not 100% Sync*/
                                                      !TypeConditionLogic.IsDefined(type, a.Condition));

                if (conditions.IsEmpty())
                {
                    return(null);
                }

                return("Type {0} has no definitions for the conditions: {1}".FormatWith(type.Name, conditions.CommaAnd(a => a.Condition.Key)));
            }
            catch (Exception ex) when(StartParameters.IgnoredDatabaseMismatches != null)
            {
                //This try { throw } catch is here to alert developers.
                //In production, in some cases its OK to attempt starting an application with a slightly different schema (dynamic entities, green-blue deployments).
                //In development, consider synchronize.
                StartParameters.IgnoredDatabaseMismatches.Add(ex);
                return(null);
            }
        }