Exemplo n.º 1
0
        public MixInValidation(DynamicModel mixWith)
        {
            rules = new List <dynamic>();

            errors = new List <dynamic>();

            @this = mixWith;

            if (HasValidationCapabilities(mixWith))
            {
                mixWith.SetUnTrackedMember("Errors", new DynamicFunction(Errors));

                mixWith.SetUnTrackedMember("IsValid", new DynamicFunctionWithParam(IsValid));

                mixWith.SetUnTrackedMember("FirstError", new DynamicFunction(FirstError));

                IEnumerable <dynamic> validationRules = @this.Validates();

                foreach (var validationRule in validationRules)
                {
                    validationRule.Init(mixWith);

                    AddRule(validationRule);
                }
            }
        }
Exemplo n.º 2
0
        private void AddAssociationMethod(DynamicModel model)
        {
            model.SetUnTrackedMember(
                Named,
                Query(model));

            model.SetUnTrackedMember(
                Singular(Named) + "Ids",
                QueryIds(model));
        }
Exemplo n.º 3
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                Query(foreignKeyName, Repository.GetType().Name, through.GetType().Name, ForeignKeyFor(Repository), model));
        }
Exemplo n.º 4
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                new DynamicFunction(() => Repository.SingleWhere(foreignKeyName + " = @0", model.GetMember(Id()))));
        }
Exemplo n.º 5
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(Repository) : ForeignKey;

            string primaryKeyName = string.IsNullOrEmpty(PrimaryKey) ? "Id" : PrimaryKey;

            string whereClause = string.Format("{0} = @0", primaryKeyName);

            model.SetUnTrackedMember(
                Named,
                new DynamicFunction(() => Repository.SingleWhere(whereClause, model.GetMember(foreignKeyName))));
        }
Exemplo n.º 6
0
        public MixInAssociation(DynamicModel mixWith)
        {
            if (!SupportsAssociations(mixWith))
            {
                return;
            }

            IEnumerable <dynamic> associations = (mixWith as dynamic).Associates();

            foreach (dynamic association in associations)
            {
                referencedAssociations.Add(association);
                association.Init(mixWith);
            }

            mixWith.SetUnTrackedMember("AssociationNamed", new DynamicFunctionWithParam(AssociationNamed));
        }
Exemplo n.º 7
0
        public MixInValidation(DynamicModel mixWith)
        {
            rules = new List<dynamic>();

            errors = new List<dynamic>();

            @this = mixWith;

            if (HasValidationCapabilities(mixWith))
            {
                mixWith.SetUnTrackedMember("Errors", new DynamicFunction(Errors));

                mixWith.SetUnTrackedMember("IsValid", new DynamicFunction(IsValid));

                mixWith.SetUnTrackedMember("IsPropertyValid", new DynamicFunctionWithParam(IsValid));

                mixWith.SetUnTrackedMember("FirstError", new DynamicFunction(FirstError));

                IEnumerable<dynamic> validationRules = @this.Validates();

                foreach (var validationRule in validationRules)
                {
                    validationRule.Init(mixWith);

                    AddRule(validationRule);
                }
            }
        }
Exemplo n.º 8
0
        private void AddAssociationMethod(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(
                named,
                Query(fromColumn, toTable, through.GetType().Name, Using ?? ForeignKeyFor(repository), model));

            model.SetUnTrackedMember(
                Singular(named) + "Ids",
                QueryIds(fromColumn, toTable, through.GetType().Name, Using ?? ForeignKeyFor(repository), model));
        }
Exemplo n.º 9
0
        private void AddAssociationMethods(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(named, Query(fromColumn, model));

            model.SetUnTrackedMember(Singular(named) + "Ids", QueryIds(fromColumn, model));
        }
Exemplo n.º 10
0
        private void AddAssociationMethods(DynamicModel model, string fromColumn, string toTable)
        {
            model.SetUnTrackedMember(Named, Query(fromColumn, model));

            model.SetUnTrackedMember(Singular(Named) + "Ids", QueryIds(fromColumn, model));
        }
Exemplo n.º 11
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(Repository) : ForeignKey;

            string primaryKeyName = string.IsNullOrEmpty(PrimaryKey) ? "Id" : PrimaryKey;

            string whereClause = string.Format("{0} = @0", primaryKeyName);

            model.SetUnTrackedMember(
                Named,
                new DynamicFunction(() => Repository.SingleWhere(whereClause, model.GetMember(foreignKeyName))));
        }
Exemplo n.º 12
0
        public MixInAssociation(DynamicModel mixWith)
        {
            if (!SupportsAssociations(mixWith)) return;

            IEnumerable<dynamic> associations = (mixWith as dynamic).Associates();

            foreach (dynamic association in associations)
            {
                referencedAssociations.Add(association);
                association.Init(mixWith);
            }

            mixWith.SetUnTrackedMember("AssociationNamed", new DynamicFunctionWithParam(AssociationNamed));
        }
Exemplo n.º 13
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                Query(foreignKeyName, Repository.GetType().Name, through.GetType().Name, ForeignKeyFor(Repository), model));
        }
Exemplo n.º 14
0
        public void Init(DynamicModel model)
        {
            string foreignKeyName = string.IsNullOrEmpty(ForeignKey) ? ForeignKeyFor(model) : ForeignKey;

            model.SetUnTrackedMember(
                Singular(Repository),
                new DynamicFunction(() => Repository.SingleWhere(foreignKeyName + " = @0", model.GetMember(Id()))));
        }
Exemplo n.º 15
0
        private void AddAssociationMethod(DynamicModel model)
        {
            model.SetUnTrackedMember(
                Named,
                Query(model));

            model.SetUnTrackedMember(
                Singular(Named) + "Ids",
                QueryIds(model));
        }