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


namespace Xbim.Ifc4x3.ProfileResource
{
	[ExpressType("IfcOpenCrossProfileDef", 1466)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcOpenCrossProfileDef : IfcProfileDef, IInstantiableEntity, IContainsEntityReferences, IEquatable<@IfcOpenCrossProfileDef>
	{

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcOpenCrossProfileDef(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_widths = new ItemSet<IfcNonNegativeLengthMeasure>( this, 0,  4);
			_slopes = new ItemSet<IfcPlaneAngleMeasure>( this, 0,  5);
			_tags = new OptionalItemSet<IfcLabel>( this, 0,  6);
		}

		#region Explicit attribute fields
		private IfcBoolean _horizontalWidths;
		private readonly ItemSet<IfcNonNegativeLengthMeasure> _widths;
		private readonly ItemSet<IfcPlaneAngleMeasure> _slopes;
		private readonly OptionalItemSet<IfcLabel> _tags;
		private IfcCartesianPoint _offsetPoint;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(3, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcBoolean @HorizontalWidths 
		{ 
			get 
			{
				if(_activated) return _horizontalWidths;
				Activate();
				return _horizontalWidths;
			} 
			set
			{
				SetValue( v =>  _horizontalWidths = v, _horizontalWidths, value,  "HorizontalWidths", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 1 }, new int [] { -1 }, 6)]
		public IItemSet<IfcNonNegativeLengthMeasure> @Widths 
		{ 
			get 
			{
				if(_activated) return _widths;
				Activate();
				return _widths;
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.None, new int [] { 1 }, new int [] { -1 }, 7)]
		public IItemSet<IfcPlaneAngleMeasure> @Slopes 
		{ 
			get 
			{
				if(_activated) return _slopes;
				Activate();
				return _slopes;
			} 
		}	
		[EntityAttribute(6, EntityAttributeState.Optional, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 8)]
		public IOptionalItemSet<IfcLabel> @Tags 
		{ 
			get 
			{
				if(_activated) return _tags;
				Activate();
				return _tags;
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 9)]
		public IfcCartesianPoint @OffsetPoint 
		{ 
			get 
			{
				if(_activated) return _offsetPoint;
				Activate();
				return _offsetPoint;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _offsetPoint = v, _offsetPoint, value,  "OffsetPoint", 7);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
				case 1: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 2: 
					_horizontalWidths = value.BooleanVal;
					return;
				case 3: 
					_widths.InternalAdd(value.RealVal);
					return;
				case 4: 
					_slopes.InternalAdd(value.RealVal);
					return;
				case 5: 
					_tags.InternalAdd(value.StringVal);
					return;
				case 6: 
					_offsetPoint = (IfcCartesianPoint)(value.EntityVal);
					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(@IfcOpenCrossProfileDef other)
	    {
	        return this == other;
	    }
        #endregion

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

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