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


namespace Xbim.Ifc4x3.PresentationAppearanceResource
{
	[ExpressType("IfcFillAreaStyleHatching", 462)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcFillAreaStyleHatching : IfcGeometricRepresentationItem, IInstantiableEntity, IfcFillStyleSelect, IContainsEntityReferences, IEquatable<@IfcFillAreaStyleHatching>
	{

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

		#region Explicit attribute fields
		private IfcCurveStyle _hatchLineAppearance;
		private IfcHatchLineDistanceSelect _startOfNextHatchLine;
		private IfcCartesianPoint _pointOfReferenceHatchLine;
		private IfcCartesianPoint _patternStart;
		private IfcPlaneAngleMeasure _hatchLineAngle;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcCurveStyle @HatchLineAppearance 
		{ 
			get 
			{
				if(_activated) return _hatchLineAppearance;
				Activate();
				return _hatchLineAppearance;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _hatchLineAppearance = v, _hatchLineAppearance, value,  "HatchLineAppearance", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 4)]
		public IfcHatchLineDistanceSelect @StartOfNextHatchLine 
		{ 
			get 
			{
				if(_activated) return _startOfNextHatchLine;
				Activate();
				return _startOfNextHatchLine;
			} 
			set
			{
				var entity = value as IPersistEntity;
				if (entity != null && !(ReferenceEquals(Model, entity.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _startOfNextHatchLine = v, _startOfNextHatchLine, value,  "StartOfNextHatchLine", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 5)]
		public IfcCartesianPoint @PointOfReferenceHatchLine 
		{ 
			get 
			{
				if(_activated) return _pointOfReferenceHatchLine;
				Activate();
				return _pointOfReferenceHatchLine;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _pointOfReferenceHatchLine = v, _pointOfReferenceHatchLine, value,  "PointOfReferenceHatchLine", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 6)]
		public IfcCartesianPoint @PatternStart 
		{ 
			get 
			{
				if(_activated) return _patternStart;
				Activate();
				return _patternStart;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _patternStart = v, _patternStart, value,  "PatternStart", 4);
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 7)]
		public IfcPlaneAngleMeasure @HatchLineAngle 
		{ 
			get 
			{
				if(_activated) return _hatchLineAngle;
				Activate();
				return _hatchLineAngle;
			} 
			set
			{
				SetValue( v =>  _hatchLineAngle = v, _hatchLineAngle, value,  "HatchLineAngle", 5);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_hatchLineAppearance = (IfcCurveStyle)(value.EntityVal);
					return;
				case 1: 
					_startOfNextHatchLine = (IfcHatchLineDistanceSelect)(value.EntityVal);
					return;
				case 2: 
					_pointOfReferenceHatchLine = (IfcCartesianPoint)(value.EntityVal);
					return;
				case 3: 
					_patternStart = (IfcCartesianPoint)(value.EntityVal);
					return;
				case 4: 
					_hatchLineAngle = 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(@IfcFillAreaStyleHatching other)
	    {
	        return this == other;
	    }
        #endregion

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

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