Exemplo n.º 1
0
        public void AddMemberConstraint(MemberInfo member, Attribute attribute)
        {
            List <Attribute> constraints;

            if (!membersAttributesDictionary.TryGetValue(member, out constraints))
            {
                constraints = new List <Attribute>();
                membersAttributesDictionary.Add(member, constraints);
            }
            Attribute found = constraints.Find(x => x.TypeId.Equals(attribute.TypeId));

            if (found == null || AttributeUtils.AttributeAllowsMultiple(attribute))
            {
#if NETFX
                log.Debug(string.Format("For class {0} Adding member {1} to dictionary with attribute {2}", EntityType.FullName,
                                        member.Name, attribute));
#else
                Log.Debug("For class {0} Adding member {1} to dictionary with attribute {2}", EntityType.FullName,
                          member.Name, attribute);
#endif
                membersAttributesDictionary[member].Add(attribute);
            }
            else
            {
#if NETFX
                log.Debug("Duplicated Attribute avoided: Class:" + typeof(T).FullName + " Member:" + member.Name + " Attribute:"
                          + attribute);
#else
                Log.Debug("Duplicated Attribute avoided: Class: {0} Member: {1} Attribute: {2}", typeof(T).FullName,
                          member.Name, attribute);
#endif
            }
        }
Exemplo n.º 2
0
        protected static void CombineAttribute(IEnumerable <Attribute> origin, List <Attribute> dest)
        {
            foreach (Attribute ma in origin)
            {
                Attribute found = dest.Find(attribute => ma.TypeId.Equals(attribute.TypeId));

                if (found != null && !AttributeUtils.AttributeAllowsMultiple(ma))
                {
                    dest.Remove(found);
                }

                dest.Add(ma);
            }
        }
Exemplo n.º 3
0
        public void AttributeCannotBeMultiplied()
        {
            LengthAttribute lenghtAttribute = new LengthAttribute();

            Assert.AreEqual(false, (AttributeUtils.AttributeAllowsMultiple(lenghtAttribute)));
        }
Exemplo n.º 4
0
        public void AttributeCanBeMultiplied()
        {
            PatternAttribute patternAttribute = new PatternAttribute();

            Assert.AreEqual(true, (AttributeUtils.AttributeAllowsMultiple(patternAttribute)));
        }