// ------------------------------------------------------------------------------
// <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.Ifc4x3.ProductExtension;
using Xbim.Ifc4x3.MeasureResource;
using System;
using System.Collections.Generic;
using System.Linq;
using Xbim.Common;
using Xbim.Common.Exceptions;
using Xbim.Ifc4x3.SharedBldgElements;
//## Custom using statements
//##


namespace Xbim.Ifc4x3.SharedBldgElements
{
	[ExpressType("IfcRelConnectsPathElements", 668)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcRelConnectsPathElements : IfcRelConnectsElements, IInstantiableEntity, IContainsEntityReferences, IContainsIndexedReferences, IEquatable<@IfcRelConnectsPathElements>
	{

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcRelConnectsPathElements(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_relatingPriorities = new ItemSet<IfcInteger>( this, 0,  8);
			_relatedPriorities = new ItemSet<IfcInteger>( this, 0,  9);
		}

		#region Explicit attribute fields
		private readonly ItemSet<IfcInteger> _relatingPriorities;
		private readonly ItemSet<IfcInteger> _relatedPriorities;
		private IfcConnectionTypeEnum _relatedConnectionType;
		private IfcConnectionTypeEnum _relatingConnectionType;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(8, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 0 }, new int [] { -1 }, 8)]
		public IItemSet<IfcInteger> @RelatingPriorities 
		{ 
			get 
			{
				if(_activated) return _relatingPriorities;
				Activate();
				return _relatingPriorities;
			} 
		}	
		[EntityAttribute(9, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 0 }, new int [] { -1 }, 9)]
		public IItemSet<IfcInteger> @RelatedPriorities 
		{ 
			get 
			{
				if(_activated) return _relatedPriorities;
				Activate();
				return _relatedPriorities;
			} 
		}	
		[EntityAttribute(10, EntityAttributeState.Mandatory, EntityAttributeType.Enum, EntityAttributeType.None, null, null, 10)]
		public IfcConnectionTypeEnum @RelatedConnectionType 
		{ 
			get 
			{
				if(_activated) return _relatedConnectionType;
				Activate();
				return _relatedConnectionType;
			} 
			set
			{
				SetValue( v =>  _relatedConnectionType = v, _relatedConnectionType, value,  "RelatedConnectionType", 10);
			} 
		}	
		[EntityAttribute(11, EntityAttributeState.Mandatory, EntityAttributeType.Enum, EntityAttributeType.None, null, null, 11)]
		public IfcConnectionTypeEnum @RelatingConnectionType 
		{ 
			get 
			{
				if(_activated) return _relatingConnectionType;
				Activate();
				return _relatingConnectionType;
			} 
			set
			{
				SetValue( v =>  _relatingConnectionType = v, _relatingConnectionType, value,  "RelatingConnectionType", 11);
			} 
		}	
		#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: 
				case 5: 
				case 6: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 7: 
					_relatingPriorities.InternalAdd(value.IntegerVal);
					return;
				case 8: 
					_relatedPriorities.InternalAdd(value.IntegerVal);
					return;
				case 9: 
                    _relatedConnectionType = (IfcConnectionTypeEnum) System.Enum.Parse(typeof (IfcConnectionTypeEnum), value.EnumVal, true);
					return;
				case 10: 
                    _relatingConnectionType = (IfcConnectionTypeEnum) System.Enum.Parse(typeof (IfcConnectionTypeEnum), 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(@IfcRelConnectsPathElements other)
	    {
	        return this == other;
	    }
        #endregion

		#region IContainsEntityReferences
		IEnumerable<IPersistEntity> IContainsEntityReferences.References 
		{
			get 
			{
				if (@OwnerHistory != null)
					yield return @OwnerHistory;
				if (@ConnectionGeometry != null)
					yield return @ConnectionGeometry;
				if (@RelatingElement != null)
					yield return @RelatingElement;
				if (@RelatedElement != null)
					yield return @RelatedElement;
			}
		}
		#endregion


		#region IContainsIndexedReferences
        IEnumerable<IPersistEntity> IContainsIndexedReferences.IndexedReferences 
		{ 
			get
			{
				if (@RelatingElement != null)
					yield return @RelatingElement;
				if (@RelatedElement != null)
					yield return @RelatedElement;
				
			} 
		}
		#endregion

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