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


namespace Xbim.Ifc2x3.ArchitectureDomain
{
	[ExpressType("IfcSpaceProgram", 709)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcSpaceProgram : IfcControl, IInstantiableEntity, IContainsEntityReferences, IEquatable<@IfcSpaceProgram>
	{

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

		#region Explicit attribute fields
		private IfcIdentifier _spaceProgramIdentifier;
		private IfcAreaMeasure? _maxRequiredArea;
		private IfcAreaMeasure? _minRequiredArea;
		private IfcSpatialStructureElement _requestedLocation;
		private IfcAreaMeasure _standardRequiredArea;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(6, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 12)]
		public IfcIdentifier @SpaceProgramIdentifier 
		{ 
			get 
			{
				if(_activated) return _spaceProgramIdentifier;
				Activate();
				return _spaceProgramIdentifier;
			} 
			set
			{
				SetValue( v =>  _spaceProgramIdentifier = v, _spaceProgramIdentifier, value,  "SpaceProgramIdentifier", 6);
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 13)]
		public IfcAreaMeasure? @MaxRequiredArea 
		{ 
			get 
			{
				if(_activated) return _maxRequiredArea;
				Activate();
				return _maxRequiredArea;
			} 
			set
			{
				SetValue( v =>  _maxRequiredArea = v, _maxRequiredArea, value,  "MaxRequiredArea", 7);
			} 
		}	
		[EntityAttribute(8, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 14)]
		public IfcAreaMeasure? @MinRequiredArea 
		{ 
			get 
			{
				if(_activated) return _minRequiredArea;
				Activate();
				return _minRequiredArea;
			} 
			set
			{
				SetValue( v =>  _minRequiredArea = v, _minRequiredArea, value,  "MinRequiredArea", 8);
			} 
		}	
		[EntityAttribute(9, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 15)]
		public IfcSpatialStructureElement @RequestedLocation 
		{ 
			get 
			{
				if(_activated) return _requestedLocation;
				Activate();
				return _requestedLocation;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _requestedLocation = v, _requestedLocation, value,  "RequestedLocation", 9);
			} 
		}	
		[EntityAttribute(10, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 16)]
		public IfcAreaMeasure @StandardRequiredArea 
		{ 
			get 
			{
				if(_activated) return _standardRequiredArea;
				Activate();
				return _standardRequiredArea;
			} 
			set
			{
				SetValue( v =>  _standardRequiredArea = v, _standardRequiredArea, value,  "StandardRequiredArea", 10);
			} 
		}	
		#endregion



		#region Inverse attributes
		[InverseProperty("RelatedSpaceProgram")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 17)]
		public IEnumerable<IfcRelInteractionRequirements> @HasInteractionReqsFrom 
		{ 
			get 
			{
				return Model.Instances.Where<IfcRelInteractionRequirements>(e => Equals(e.RelatedSpaceProgram), "RelatedSpaceProgram", this);
			} 
		}
		[InverseProperty("RelatingSpaceProgram")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 18)]
		public IEnumerable<IfcRelInteractionRequirements> @HasInteractionReqsTo 
		{ 
			get 
			{
				return Model.Instances.Where<IfcRelInteractionRequirements>(e => Equals(e.RelatingSpaceProgram), "RelatingSpaceProgram", this);
			} 
		}
		#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: 
					_spaceProgramIdentifier = value.StringVal;
					return;
				case 6: 
					_maxRequiredArea = value.RealVal;
					return;
				case 7: 
					_minRequiredArea = value.RealVal;
					return;
				case 8: 
					_requestedLocation = (IfcSpatialStructureElement)(value.EntityVal);
					return;
				case 9: 
					_standardRequiredArea = 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(@IfcSpaceProgram other)
	    {
	        return this == other;
	    }
        #endregion

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

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