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


namespace Xbim.Ifc4x3.RepresentationResource
{
	[ExpressType("IfcRigidOperation", 1480)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcRigidOperation : IfcCoordinateOperation, IInstantiableEntity, IContainsEntityReferences, IContainsIndexedReferences, IEquatable<@IfcRigidOperation>
	{

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcRigidOperation(IModel model, int label, bool activated) : base(model, label, activated)  
		{
		}

		#region Explicit attribute fields
		private IfcMeasureValue _firstCoordinate;
		private IfcMeasureValue _secondCoordinate;
		private IfcLengthMeasure? _height;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(3, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcMeasureValue @FirstCoordinate 
		{ 
			get 
			{
				if(_activated) return _firstCoordinate;
				Activate();
				return _firstCoordinate;
			} 
			set
			{
				SetValue( v =>  _firstCoordinate = v, _firstCoordinate, value,  "FirstCoordinate", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 4)]
		public IfcMeasureValue @SecondCoordinate 
		{ 
			get 
			{
				if(_activated) return _secondCoordinate;
				Activate();
				return _secondCoordinate;
			} 
			set
			{
				SetValue( v =>  _secondCoordinate = v, _secondCoordinate, value,  "SecondCoordinate", 4);
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcLengthMeasure? @Height 
		{ 
			get 
			{
				if(_activated) return _height;
				Activate();
				return _height;
			} 
			set
			{
				SetValue( v =>  _height = v, _height, value,  "Height", 5);
			} 
		}	
		#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: 
					_firstCoordinate = (IfcMeasureValue)(value.EntityVal);
					return;
				case 3: 
					_secondCoordinate = (IfcMeasureValue)(value.EntityVal);
					return;
				case 4: 
					_height = value.RealVal;
					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(@IfcRigidOperation other)
	    {
	        return this == other;
	    }
        #endregion

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


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

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