/// <summary>
        /// Add a MetaProperty
        /// </summary>
        /// <param name="metaProperty">the property to add.</param>
        public void AddProperty(IMetaIndexedProperty metaProperty)
        {
            if (metaProperty is null)
            {
                throw new ArgumentNullException(nameof(metaProperty));
            }
            this.ThrowIfFrozen();

            // check if property exists
            if (this._PropertyByName.ContainsKey(metaProperty.Name))
            {
                throw new ArgumentException("Property already exists.");
            }

            // and add
            metaProperty.MetaEntity = this;
            if (metaProperty.Index < 0)
            {
                metaProperty.Index = this._PropertyByIndex.Count;
                this._PropertyByIndex.Add(metaProperty);
                this._PropertyByName.Add(metaProperty.Name, metaProperty);
            }
            else if (this._PropertyByIndex.Count == metaProperty.Index)
            {
                this._PropertyByIndex.Add(metaProperty);
                this._PropertyByName.Add(metaProperty.Name, metaProperty);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccessorFlexible"/> struct.
 /// </summary>
 /// <param name="metaPropertyArrayProp">the property</param>
 /// <param name="entity">the entity</param>
 public AccessorFlexible(IMetaIndexedProperty metaPropertyArrayProp, IEntityFlexible entity)
 {
     this._MetaProperty = metaPropertyArrayProp;
     this._Entity       = entity;
 }