示例#1
0
        /// <summary>
        /// Allow user to add an attribute with a name, a type and a visibility
        /// </summary>
        /// <param name="name">Name of the attribute to add</param>
        /// <param name="attrType">Type of the attribute to add</param>
        /// <param name="visibility">Visibility of the attribute (INTERNAL, EXTERNAL)</param>
        public void AddAttribute(string name, DataType attrType, Global.AccessMode visibility)
        {
            if (attrType == this)
            {
                throw new InvalidOperationException("Cannot set an attribute of the same type");
            }

            ObjectType atType = attrType as ObjectType;

            if (atType != null && atType.HasAttributeOfType(this, true))
            {
                throw new InvalidOperationException("Circular reference detected: cannot add an attribute of type " + attrType.Name + " in " + Name);
            }

            attributes.Declare(attrType, name, visibility);
        }
示例#2
0
 /// <summary>
 /// Allow user to change an attribute visibility
 /// </summary>
 /// <param name="name">Name of the attribute</param>
 /// <param name="visibility">Visibility to set</param>
 public void ChangeAttributeVisibility(string name, Global.AccessMode visibility)
 {
     attributes.ChangeVisibility(name, visibility);
 }