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

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcRelSpaceBoundary2ndLevel
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcRelSpaceBoundary2ndLevel : IIfcRelSpaceBoundary1stLevel
	{
		IIfcRelSpaceBoundary2ndLevel @CorrespondingBoundary { get;  set; }
		IEnumerable<IIfcRelSpaceBoundary2ndLevel> @Corresponds {  get; }
	
	}
}

namespace Xbim.Ifc4.ProductExtension
{
	[ExpressType("IfcRelSpaceBoundary2ndLevel", 1254)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcRelSpaceBoundary2ndLevel : IfcRelSpaceBoundary1stLevel, IInstantiableEntity, IIfcRelSpaceBoundary2ndLevel, IContainsEntityReferences, IContainsIndexedReferences, IEquatable<@IfcRelSpaceBoundary2ndLevel>
	{
		#region IIfcRelSpaceBoundary2ndLevel explicit implementation
		IIfcRelSpaceBoundary2ndLevel IIfcRelSpaceBoundary2ndLevel.CorrespondingBoundary { 
 
 
			get { return @CorrespondingBoundary; } 
			set { CorrespondingBoundary = value as IfcRelSpaceBoundary2ndLevel;}
		}	
		IEnumerable<IIfcRelSpaceBoundary2ndLevel> IIfcRelSpaceBoundary2ndLevel.Corresponds {  get { return @Corresponds; } }
		#endregion

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

		#region Explicit attribute fields
		private IfcRelSpaceBoundary2ndLevel _correspondingBoundary;
		#endregion
	
		#region Explicit attribute properties
		[IndexedProperty]
		[EntityAttribute(11, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 12)]
		public IfcRelSpaceBoundary2ndLevel @CorrespondingBoundary 
		{ 
			get 
			{
				if(_activated) return _correspondingBoundary;
				Activate();
				return _correspondingBoundary;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _correspondingBoundary = v, _correspondingBoundary, value,  "CorrespondingBoundary", 11);
			} 
		}	
		#endregion



		#region Inverse attributes
		[InverseProperty("CorrespondingBoundary")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { 1 }, 13)]
		public IEnumerable<IfcRelSpaceBoundary2ndLevel> @Corresponds 
		{ 
			get 
			{
				return Model.Instances.Where<IfcRelSpaceBoundary2ndLevel>(e => Equals(e.CorrespondingBoundary), "CorrespondingBoundary", 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: 
				case 5: 
				case 6: 
				case 7: 
				case 8: 
				case 9: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 10: 
					_correspondingBoundary = (IfcRelSpaceBoundary2ndLevel)(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(@IfcRelSpaceBoundary2ndLevel other)
	    {
	        return this == other;
	    }
        #endregion

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


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

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