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

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcAlignmentCurve
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcAlignmentCurve : IIfcBoundedCurve
	{
		IIfcAlignment2DHorizontal @Horizontal { get;  set; }
		IIfcAlignment2DVertical @Vertical { get;  set; }
		IfcLabel? @Tag { get;  set; }
	
	}
}

namespace Xbim.Ifc4.GeometricConstraintResource
{
	[ExpressType("IfcAlignmentCurve", 1347)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcAlignmentCurve : IfcBoundedCurve, IInstantiableEntity, IIfcAlignmentCurve, IContainsEntityReferences, IContainsIndexedReferences, IEquatable<@IfcAlignmentCurve>
	{
		#region IIfcAlignmentCurve explicit implementation
		IIfcAlignment2DHorizontal IIfcAlignmentCurve.Horizontal { 
 
 
			get { return @Horizontal; } 
			set { Horizontal = value as IfcAlignment2DHorizontal;}
		}	
		IIfcAlignment2DVertical IIfcAlignmentCurve.Vertical { 
 
 
			get { return @Vertical; } 
			set { Vertical = value as IfcAlignment2DVertical;}
		}	
		IfcLabel? IIfcAlignmentCurve.Tag { 
 
			get { return @Tag; } 
			set { Tag = value;}
		}	
		#endregion

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

		#region Explicit attribute fields
		private IfcAlignment2DHorizontal _horizontal;
		private IfcAlignment2DVertical _vertical;
		private IfcLabel? _tag;
		#endregion
	
		#region Explicit attribute properties
		[IndexedProperty]
		[EntityAttribute(1, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcAlignment2DHorizontal @Horizontal 
		{ 
			get 
			{
				if(_activated) return _horizontal;
				Activate();
				return _horizontal;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _horizontal = v, _horizontal, value,  "Horizontal", 1);
			} 
		}	
		[IndexedProperty]
		[EntityAttribute(2, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 4)]
		public IfcAlignment2DVertical @Vertical 
		{ 
			get 
			{
				if(_activated) return _vertical;
				Activate();
				return _vertical;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _vertical = v, _vertical, value,  "Vertical", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcLabel? @Tag 
		{ 
			get 
			{
				if(_activated) return _tag;
				Activate();
				return _tag;
			} 
			set
			{
				SetValue( v =>  _tag = v, _tag, value,  "Tag", 3);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_horizontal = (IfcAlignment2DHorizontal)(value.EntityVal);
					return;
				case 1: 
					_vertical = (IfcAlignment2DVertical)(value.EntityVal);
					return;
				case 2: 
					_tag = value.StringVal;
					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(@IfcAlignmentCurve other)
	    {
	        return this == other;
	    }
        #endregion

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


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

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