示例#1
0
        public AttributeDefinition(
            Type type,
            IAttribute attributeValue,
            Func <ILanguage, String> attributeNameGetter,
            Xml.Attribute xml)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (attributeValue == null)
            {
                throw new ArgumentNullException(nameof(attributeValue));
            }
            if (!type.IsInstanceOfType(attributeValue))
            {
                throw new InvalidCastException();
            }
            if (attributeNameGetter == null)
            {
                throw new ArgumentNullException(nameof(attributeNameGetter));
            }
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }

            Type                 = type;
            AttributeValue       = attributeValue;
            _attributeNameGetter = attributeNameGetter;
            Xml            = xml;
            XmlType        = xml.GetType();
            XmlElementName = XmlType.Name.Replace("Attribute", "");
        }
示例#2
0
 public static void RegisterAttribute <AttributeT>(
     AttributeT value,
     Func <ILanguage, String> attributeNameGetter,
     Xml.Attribute xml)
     where AttributeT : IAttribute
 {
     Attributes.Define(new AttributeDefinition(typeof(AttributeT), value, attributeNameGetter, xml));
 }