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

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcCurveSegment2D
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcCurveSegment2D : IIfcBoundedCurve
	{
		IIfcCartesianPoint @StartPoint { get;  set; }
		IfcPlaneAngleMeasure @StartDirection { get;  set; }
		IfcPositiveLengthMeasure @SegmentLength { get;  set; }
	
	}
}

namespace Xbim.Ifc4.GeometryResource
{
	[ExpressType("IfcCurveSegment2D", 1342)]
	// ReSharper disable once PartialTypeWithSinglePart
	public abstract partial class @IfcCurveSegment2D : IfcBoundedCurve, IIfcCurveSegment2D, IEquatable<@IfcCurveSegment2D>
	{
		#region IIfcCurveSegment2D explicit implementation
		IIfcCartesianPoint IIfcCurveSegment2D.StartPoint { 
 
 
			get { return @StartPoint; } 
			set { StartPoint = value as IfcCartesianPoint;}
		}	
		IfcPlaneAngleMeasure IIfcCurveSegment2D.StartDirection { 
 
			get { return @StartDirection; } 
			set { StartDirection = value;}
		}	
		IfcPositiveLengthMeasure IIfcCurveSegment2D.SegmentLength { 
 
			get { return @SegmentLength; } 
			set { SegmentLength = value;}
		}	
		#endregion

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

		#region Explicit attribute fields
		private IfcCartesianPoint _startPoint;
		private IfcPlaneAngleMeasure _startDirection;
		private IfcPositiveLengthMeasure _segmentLength;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcCartesianPoint @StartPoint 
		{ 
			get 
			{
				if(_activated) return _startPoint;
				Activate();
				return _startPoint;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _startPoint = v, _startPoint, value,  "StartPoint", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 4)]
		public IfcPlaneAngleMeasure @StartDirection 
		{ 
			get 
			{
				if(_activated) return _startDirection;
				Activate();
				return _startDirection;
			} 
			set
			{
				SetValue( v =>  _startDirection = v, _startDirection, value,  "StartDirection", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcPositiveLengthMeasure @SegmentLength 
		{ 
			get 
			{
				if(_activated) return _segmentLength;
				Activate();
				return _segmentLength;
			} 
			set
			{
				SetValue( v =>  _segmentLength = v, _segmentLength, value,  "SegmentLength", 3);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_startPoint = (IfcCartesianPoint)(value.EntityVal);
					return;
				case 1: 
					_startDirection = value.RealVal;
					return;
				case 2: 
					_segmentLength = 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(@IfcCurveSegment2D other)
	    {
	        return this == other;
	    }
        #endregion

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