Exemple #1
0
        /// <summary>
        /// Creates a new instance of the attribute inside the given key
        /// so it can be modified without affecting this class's internal list.
        /// Once modified, pass it into <see cref="SetAttribute(string, IAttribute)"/>
        /// to modify the value.
        /// </summary>
        public TAttr CloneAttributeAsType <TAttr>(string key) where TAttr : IAttribute
        {
            this.KeyCheck(key);

            TAttr attr = AttributeFactory.CreateAttribute <TAttr>();

            if (attr.AttributeType != this.attributes[key].AttributeType)
            {
                throw new InvalidOperationException(
                          "Attribute Types not compatible, need to pass in the correct attribute type for key '" + key + "'"
                          );
            }

            attr.Deserialize(this.attributes[key].Serialize());

            return(attr);
        }
Exemple #2
0
 /// <summary>
 /// Adds a new key that is set to an empty instance.
 /// Internal since we only do this when creating a new Asset that
 /// consumers of the API will use.
 /// </summary>
 internal void AddEmptyAttribute(string newKey, AttributeTypes attributeType)
 {
     this.attributes[newKey] = AttributeFactory.CreateAttribute(attributeType);
 }