// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool Xbim.CodeGeneration 
//  
//     Changes to this file may cause incorrect behaviour and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

using Xbim.Ifc4.Interfaces;
using Xbim.Ifc4.MeasureResource;
using System;
using System.Collections.Generic;
using System.Linq;
using Xbim.Common;
using Xbim.Common.Exceptions;
using Xbim.Ifc4.GeometryResource;
//## Custom using statements
//##

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcBSplineCurveWithKnots
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcBSplineCurveWithKnots : IIfcBSplineCurve
	{
		IItemSet<IfcInteger> @KnotMultiplicities { get; }
		IItemSet<IfcParameterValue> @Knots { get; }
		IfcKnotType @KnotSpec { get;  set; }
		IfcInteger @UpperIndexOnKnots  { get ; }
	
	}
}

namespace Xbim.Ifc4.GeometryResource
{
	[ExpressType("IfcBSplineCurveWithKnots", 1101)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcBSplineCurveWithKnots : IfcBSplineCurve, IInstantiableEntity, IIfcBSplineCurveWithKnots, IContainsEntityReferences, IEquatable<@IfcBSplineCurveWithKnots>
	{
		#region IIfcBSplineCurveWithKnots explicit implementation
		IItemSet<IfcInteger> IIfcBSplineCurveWithKnots.KnotMultiplicities { 
			get { return @KnotMultiplicities; } 
		}	
		IItemSet<IfcParameterValue> IIfcBSplineCurveWithKnots.Knots { 
			get { return @Knots; } 
		}	
		IfcKnotType IIfcBSplineCurveWithKnots.KnotSpec { 
 
			get { return @KnotSpec; } 
			set { KnotSpec = value;}
		}	
		IfcInteger IIfcBSplineCurveWithKnots.@UpperIndexOnKnots  { get { return @UpperIndexOnKnots; } }
		#endregion

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcBSplineCurveWithKnots(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_knotMultiplicities = new ItemSet<IfcInteger>( this, 0,  6);
			_knots = new ItemSet<IfcParameterValue>( this, 0,  7);
		}

		#region Explicit attribute fields
		private readonly ItemSet<IfcInteger> _knotMultiplicities;
		private readonly ItemSet<IfcParameterValue> _knots;
		private IfcKnotType _knotSpec;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(6, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 8)]
		public IItemSet<IfcInteger> @KnotMultiplicities 
		{ 
			get 
			{
				if(_activated) return _knotMultiplicities;
				Activate();
				return _knotMultiplicities;
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 9)]
		public IItemSet<IfcParameterValue> @Knots 
		{ 
			get 
			{
				if(_activated) return _knots;
				Activate();
				return _knots;
			} 
		}	
		[EntityAttribute(8, EntityAttributeState.Mandatory, EntityAttributeType.Enum, EntityAttributeType.None, null, null, 10)]
		public IfcKnotType @KnotSpec 
		{ 
			get 
			{
				if(_activated) return _knotSpec;
				Activate();
				return _knotSpec;
			} 
			set
			{
				SetValue( v =>  _knotSpec = v, _knotSpec, value,  "KnotSpec", 8);
			} 
		}	
		#endregion


		#region Derived attributes
		[EntityAttribute(0, EntityAttributeState.Derived, EntityAttributeType.None, EntityAttributeType.None, null, null, 0)]
		public IfcInteger @UpperIndexOnKnots 
		{
			get 
			{
				//## Getter for UpperIndexOnKnots
			    return Knots.Count;
			    //##
			}
		}

		#endregion


		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
				case 1: 
				case 2: 
				case 3: 
				case 4: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 5: 
					_knotMultiplicities.InternalAdd(value.IntegerVal);
					return;
				case 6: 
					_knots.InternalAdd(value.RealVal);
					return;
				case 7: 
                    _knotSpec = (IfcKnotType) System.Enum.Parse(typeof (IfcKnotType), value.EnumVal, true);
					return;
				default:
					throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
			}
		}
		#endregion

		#region Equality comparers and operators
        public bool Equals(@IfcBSplineCurveWithKnots other)
	    {
	        return this == other;
	    }
        #endregion

		#region IContainsEntityReferences
		IEnumerable<IPersistEntity> IContainsEntityReferences.References 
		{
			get 
			{
				foreach(var entity in @ControlPointsList)
					yield return entity;
			}
		}
		#endregion

		#region Custom code (will survive code regeneration)
		//## Custom code
		//##
		#endregion
	}
}