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


namespace Xbim.Ifc2x3.GeometryResource
{
	[ExpressType("IfcRectangularTrimmedSurface", 653)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcRectangularTrimmedSurface : IfcBoundedSurface, IInstantiableEntity, IContainsEntityReferences, IEquatable<@IfcRectangularTrimmedSurface>
	{

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

		#region Explicit attribute fields
		private IfcSurface _basisSurface;
		private IfcParameterValue _u1;
		private IfcParameterValue _v1;
		private IfcParameterValue _u2;
		private IfcParameterValue _v2;
		private bool _usense;
		private bool _vsense;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcSurface @BasisSurface 
		{ 
			get 
			{
				if(_activated) return _basisSurface;
				Activate();
				return _basisSurface;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _basisSurface = v, _basisSurface, value,  "BasisSurface", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 4)]
		public IfcParameterValue @U1 
		{ 
			get 
			{
				if(_activated) return _u1;
				Activate();
				return _u1;
			} 
			set
			{
				SetValue( v =>  _u1 = v, _u1, value,  "U1", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcParameterValue @V1 
		{ 
			get 
			{
				if(_activated) return _v1;
				Activate();
				return _v1;
			} 
			set
			{
				SetValue( v =>  _v1 = v, _v1, value,  "V1", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 6)]
		public IfcParameterValue @U2 
		{ 
			get 
			{
				if(_activated) return _u2;
				Activate();
				return _u2;
			} 
			set
			{
				SetValue( v =>  _u2 = v, _u2, value,  "U2", 4);
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 7)]
		public IfcParameterValue @V2 
		{ 
			get 
			{
				if(_activated) return _v2;
				Activate();
				return _v2;
			} 
			set
			{
				SetValue( v =>  _v2 = v, _v2, value,  "V2", 5);
			} 
		}	
		[EntityAttribute(6, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 8)]
		public bool @Usense 
		{ 
			get 
			{
				if(_activated) return _usense;
				Activate();
				return _usense;
			} 
			set
			{
				SetValue( v =>  _usense = v, _usense, value,  "Usense", 6);
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 9)]
		public bool @Vsense 
		{ 
			get 
			{
				if(_activated) return _vsense;
				Activate();
				return _vsense;
			} 
			set
			{
				SetValue( v =>  _vsense = v, _vsense, value,  "Vsense", 7);
			} 
		}	
		#endregion


		#region Derived attributes
		[EntityAttribute(0, EntityAttributeState.Derived, EntityAttributeType.None, EntityAttributeType.None, null, null, 0)]
		public override IfcDimensionCount @Dim 
		{
			get 
			{
				//## Getter for Dim
			    return BasisSurface.Dim;
			    //##
			}
		}

		#endregion


		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_basisSurface = (IfcSurface)(value.EntityVal);
					return;
				case 1: 
					_u1 = value.RealVal;
					return;
				case 2: 
					_v1 = value.RealVal;
					return;
				case 3: 
					_u2 = value.RealVal;
					return;
				case 4: 
					_v2 = value.RealVal;
					return;
				case 5: 
					_usense = value.BooleanVal;
					return;
				case 6: 
					_vsense = value.BooleanVal;
					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(@IfcRectangularTrimmedSurface other)
	    {
	        return this == other;
	    }
        #endregion

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

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