// ------------------------------------------------------------------------------
// <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.Interfaces;
using System.Collections.Generic;
using System.Linq;
using Xbim.Common;

//## Custom using statements
//##

// ReSharper disable once CheckNamespace
namespace Xbim.Ifc4x3.DateTimeResource
{
	public partial class @IfcTimeSeries : IIfcTimeSeries
	{

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 1)]
		Ifc4.MeasureResource.IfcLabel IIfcTimeSeries.Name 
		{ 
			get
			{
				return new Ifc4.MeasureResource.IfcLabel(Name);
			} 
			set
			{
				Name = new MeasureResource.IfcLabel(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 2)]
		Ifc4.MeasureResource.IfcText? IIfcTimeSeries.Description 
		{ 
			get
			{
				if (!Description.HasValue) return null;
				return new Ifc4.MeasureResource.IfcText(Description.Value);
			} 
			set
			{
				Description = value.HasValue ? 
					new MeasureResource.IfcText(value.Value) :  
					 new MeasureResource.IfcText?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 3)]
		Ifc4.DateTimeResource.IfcDateTime IIfcTimeSeries.StartTime 
		{ 
			get
			{
				return new Ifc4.DateTimeResource.IfcDateTime(StartTime);
			} 
			set
			{
				StartTime = new IfcDateTime(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 4)]
		Ifc4.DateTimeResource.IfcDateTime IIfcTimeSeries.EndTime 
		{ 
			get
			{
				return new Ifc4.DateTimeResource.IfcDateTime(EndTime);
			} 
			set
			{
				EndTime = new IfcDateTime(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 5)]
		Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum IIfcTimeSeries.TimeSeriesDataType 
		{ 
			get
			{
				//## Custom code to handle enumeration of TimeSeriesDataType
				//##
				switch (TimeSeriesDataType)
				{
					case IfcTimeSeriesDataTypeEnum.CONTINUOUS:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.CONTINUOUS;
					case IfcTimeSeriesDataTypeEnum.DISCRETE:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.DISCRETE;
					case IfcTimeSeriesDataTypeEnum.DISCRETEBINARY:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.DISCRETEBINARY;
					case IfcTimeSeriesDataTypeEnum.PIECEWISEBINARY:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISEBINARY;
					case IfcTimeSeriesDataTypeEnum.PIECEWISECONSTANT:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISECONSTANT;
					case IfcTimeSeriesDataTypeEnum.PIECEWISECONTINUOUS:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISECONTINUOUS;
					case IfcTimeSeriesDataTypeEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of TimeSeriesDataType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.CONTINUOUS:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.CONTINUOUS;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.DISCRETE:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.DISCRETE;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.DISCRETEBINARY:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.DISCRETEBINARY;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISEBINARY:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.PIECEWISEBINARY;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISECONSTANT:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.PIECEWISECONSTANT;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.PIECEWISECONTINUOUS:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.PIECEWISECONTINUOUS;
						return;
					case Ifc4.Interfaces.IfcTimeSeriesDataTypeEnum.NOTDEFINED:
						TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 6)]
		Ifc4.Interfaces.IfcDataOriginEnum IIfcTimeSeries.DataOrigin 
		{ 
			get
			{
				//## Custom code to handle enumeration of DataOrigin
				//##
				switch (DataOrigin)
				{
					case IfcDataOriginEnum.MEASURED:
						return Ifc4.Interfaces.IfcDataOriginEnum.MEASURED;
					case IfcDataOriginEnum.PREDICTED:
						return Ifc4.Interfaces.IfcDataOriginEnum.PREDICTED;
					case IfcDataOriginEnum.SIMULATED:
						return Ifc4.Interfaces.IfcDataOriginEnum.SIMULATED;
					case IfcDataOriginEnum.USERDEFINED:
						//## Optional custom handling of DataOrigin == .USERDEFINED. 
						//##
						return Ifc4.Interfaces.IfcDataOriginEnum.USERDEFINED;
					case IfcDataOriginEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcDataOriginEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of DataOrigin
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcDataOriginEnum.MEASURED:
						DataOrigin = IfcDataOriginEnum.MEASURED;
						return;
					case Ifc4.Interfaces.IfcDataOriginEnum.PREDICTED:
						DataOrigin = IfcDataOriginEnum.PREDICTED;
						return;
					case Ifc4.Interfaces.IfcDataOriginEnum.SIMULATED:
						DataOrigin = IfcDataOriginEnum.SIMULATED;
						return;
					case Ifc4.Interfaces.IfcDataOriginEnum.USERDEFINED:
						DataOrigin = IfcDataOriginEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcDataOriginEnum.NOTDEFINED:
						DataOrigin = IfcDataOriginEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 7)]
		Ifc4.MeasureResource.IfcLabel? IIfcTimeSeries.UserDefinedDataOrigin 
		{ 
			get
			{
				if (!UserDefinedDataOrigin.HasValue) return null;
				return new Ifc4.MeasureResource.IfcLabel(UserDefinedDataOrigin.Value);
			} 
			set
			{
				UserDefinedDataOrigin = value.HasValue ? 
					new MeasureResource.IfcLabel(value.Value) :  
					 new MeasureResource.IfcLabel?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcTimeSeries), 8)]
		IIfcUnit IIfcTimeSeries.Unit 
		{ 
			get
			{
				if (Unit == null) return null;
				var ifcderivedunit = Unit as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
					return ifcderivedunit;
				var ifcmonetaryunit = Unit as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
					return ifcmonetaryunit;
				var ifcnamedunit = Unit as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
					return ifcnamedunit;
				return null;
			} 
			set
			{
				if (value == null)
				{
					Unit = null;
					return;
				}	
				var ifcderivedunit = value as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
				{
					Unit = ifcderivedunit;
					return;
				}
				var ifcmonetaryunit = value as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
				{
					Unit = ifcmonetaryunit;
					return;
				}
				var ifcnamedunit = value as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
				{
					Unit = ifcnamedunit;
					return;
				}
				
			}
		}
		IEnumerable<IIfcExternalReferenceRelationship> IIfcTimeSeries.HasExternalReference 
		{ 
			get
			{
				return Model.Instances.Where<IIfcExternalReferenceRelationship>(e => e.RelatedResourceObjects != null &&  e.RelatedResourceObjects.Contains(this), "RelatedResourceObjects", this);
			} 
		}
	//## Custom code
	//##
	}
}