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


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

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcCostSchedule(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_targetUsers = new OptionalItemSet<IfcActorSelect>( this, 0,  10);
		}

		#region Explicit attribute fields
		private IfcActorSelect _submittedBy;
		private IfcActorSelect _preparedBy;
		private IfcDateTimeSelect _submittedOn;
		private IfcLabel? _status;
		private readonly OptionalItemSet<IfcActorSelect> _targetUsers;
		private IfcDateTimeSelect _updateDate;
		private IfcIdentifier _iD;
		private IfcCostScheduleTypeEnum _predefinedType;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(6, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 12)]
		public IfcActorSelect @SubmittedBy 
		{ 
			get 
			{
				if(_activated) return _submittedBy;
				Activate();
				return _submittedBy;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _submittedBy = v, _submittedBy, value,  "SubmittedBy", 6);
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 13)]
		public IfcActorSelect @PreparedBy 
		{ 
			get 
			{
				if(_activated) return _preparedBy;
				Activate();
				return _preparedBy;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _preparedBy = v, _preparedBy, value,  "PreparedBy", 7);
			} 
		}	
		[EntityAttribute(8, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 14)]
		public IfcDateTimeSelect @SubmittedOn 
		{ 
			get 
			{
				if(_activated) return _submittedOn;
				Activate();
				return _submittedOn;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _submittedOn = v, _submittedOn, value,  "SubmittedOn", 8);
			} 
		}	
		[EntityAttribute(9, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 15)]
		public IfcLabel? @Status 
		{ 
			get 
			{
				if(_activated) return _status;
				Activate();
				return _status;
			} 
			set
			{
				SetValue( v =>  _status = v, _status, value,  "Status", 9);
			} 
		}	
		[EntityAttribute(10, EntityAttributeState.Optional, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 1 }, new int [] { -1 }, 16)]
		public IOptionalItemSet<IfcActorSelect> @TargetUsers 
		{ 
			get 
			{
				if(_activated) return _targetUsers;
				Activate();
				return _targetUsers;
			} 
		}	
		[EntityAttribute(11, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 17)]
		public IfcDateTimeSelect @UpdateDate 
		{ 
			get 
			{
				if(_activated) return _updateDate;
				Activate();
				return _updateDate;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _updateDate = v, _updateDate, value,  "UpdateDate", 11);
			} 
		}	
		[EntityAttribute(12, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 18)]
		public IfcIdentifier @ID 
		{ 
			get 
			{
				if(_activated) return _iD;
				Activate();
				return _iD;
			} 
			set
			{
				SetValue( v =>  _iD = v, _iD, value,  "ID", 12);
			} 
		}	
		[EntityAttribute(13, EntityAttributeState.Mandatory, EntityAttributeType.Enum, EntityAttributeType.None, null, null, 19)]
		public IfcCostScheduleTypeEnum @PredefinedType 
		{ 
			get 
			{
				if(_activated) return _predefinedType;
				Activate();
				return _predefinedType;
			} 
			set
			{
				SetValue( v =>  _predefinedType = v, _predefinedType, value,  "PredefinedType", 13);
			} 
		}	
		#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: 
					_submittedBy = (IfcActorSelect)(value.EntityVal);
					return;
				case 6: 
					_preparedBy = (IfcActorSelect)(value.EntityVal);
					return;
				case 7: 
					_submittedOn = (IfcDateTimeSelect)(value.EntityVal);
					return;
				case 8: 
					_status = value.StringVal;
					return;
				case 9: 
					_targetUsers.InternalAdd((IfcActorSelect)value.EntityVal);
					return;
				case 10: 
					_updateDate = (IfcDateTimeSelect)(value.EntityVal);
					return;
				case 11: 
					_iD = value.StringVal;
					return;
				case 12: 
                    _predefinedType = (IfcCostScheduleTypeEnum) System.Enum.Parse(typeof (IfcCostScheduleTypeEnum), value.EnumVal, true);
					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(@IfcCostSchedule other)
	    {
	        return this == other;
	    }
        #endregion

		#region IContainsEntityReferences
		IEnumerable<IPersistEntity> IContainsEntityReferences.References 
		{
			get 
			{
				if (@OwnerHistory != null)
					yield return @OwnerHistory;
				if (@SubmittedBy != null)
					yield return @SubmittedBy;
				if (@PreparedBy != null)
					yield return @PreparedBy;
				if (@SubmittedOn != null)
					yield return @SubmittedOn;
				foreach(var entity in @TargetUsers)
					yield return entity;
				if (@UpdateDate != null)
					yield return @UpdateDate;
			}
		}
		#endregion

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