コード例 #1
0
 public void AddElement(MetaDescription instance)
 {
     if (Elements.Add(instance))
     {
         instance.Package = this;
     }
 }
コード例 #2
0
        public override void CheckContraints(Warnings warnings)
        {
            int container = AllAttributes().Count(property => property.IsContainer);

            if (container > 1)
            {
                warnings.Add("May not have more than one container", this);
            }
            if (!MetaRepository.IsValidName(Name))
            {
                warnings.Add("Name must be alphanumeric", this);
            }
            if (this != OBJECT && this != STRING && this != BOOLEAN && this != DATE && this != NUMBER)
            {
                if (_nestingPackage == null)
                {
                    warnings.Add("Must be owned by a package", this);
                }
                if (SuperClass == null)
                {
                    warnings.Add("Must have a superclass", this);
                }
                if (SuperClass == STRING && SuperClass == BOOLEAN && SuperClass == NUMBER)
                {
                    warnings.Add("May not have primitive superclass", this);
                }
            }
            else
            {
                //Assert nestingPackage == null;
                //Assert superclass == null;
                //Assert attributes.isEmpty();
            }

            var set = new HashSet <MetaDescription>
            {
                this
            };

            for (MetaDescription each = this; each == null; each = each.SuperClass)
            {
                if (!set.Add(each))
                {
                    warnings.Add("Superclass chain may not be circular", this);
                    break;
                }
            }
        }
コード例 #3
0
 internal void SetOwningMetaDescription(MetaDescription owner)
 {
     _declaringClass = owner;
     _declaringClass.AddOwnedAttribute(this);
 }
コード例 #4
0
 /// <summary>
 /// Answer if this is a subclass of type. This is, if type is a superclass of
 /// this: <code>A.conformsTo(B) -> A is B or A extends B</code>.
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool ConformsTo(MetaDescription type)
 {
     return(this == type || (SuperClass != null && SuperClass.ConformsTo(type)));
 }