// ------------------------------------------------------------------------------
// <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.Kernel
{
	public partial class @IfcSimplePropertyTemplate : IIfcSimplePropertyTemplate
	{

		[CrossSchemaAttribute(typeof(IIfcSimplePropertyTemplate), 5)]
		Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum? IIfcSimplePropertyTemplate.TemplateType 
		{ 
			get
			{
				//## Custom code to handle enumeration of TemplateType
				//##
				switch (TemplateType)
				{
					case IfcSimplePropertyTemplateTypeEnum.P_BOUNDEDVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_BOUNDEDVALUE;
					case IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE;
					case IfcSimplePropertyTemplateTypeEnum.P_LISTVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_LISTVALUE;
					case IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE;
					case IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE;
					case IfcSimplePropertyTemplateTypeEnum.P_TABLEVALUE:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_TABLEVALUE;
					case IfcSimplePropertyTemplateTypeEnum.Q_AREA:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_AREA;
					case IfcSimplePropertyTemplateTypeEnum.Q_COUNT:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_COUNT;
					case IfcSimplePropertyTemplateTypeEnum.Q_LENGTH:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_LENGTH;
					case IfcSimplePropertyTemplateTypeEnum.Q_NUMBER:
						//## Handle translation of Q_NUMBER member from IfcSimplePropertyTemplateTypeEnum in property TemplateType
						//TODO: Handle translation of Q_NUMBER member from IfcSimplePropertyTemplateTypeEnum in property TemplateType
						throw new System.NotImplementedException();
						//##
					case IfcSimplePropertyTemplateTypeEnum.Q_TIME:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_TIME;
					case IfcSimplePropertyTemplateTypeEnum.Q_VOLUME:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_VOLUME;
					case IfcSimplePropertyTemplateTypeEnum.Q_WEIGHT:
						return Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_WEIGHT;
					case null: 
						return null;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of TemplateType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_ENUMERATEDVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_BOUNDEDVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_BOUNDEDVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_LISTVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_LISTVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_TABLEVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_TABLEVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.P_REFERENCEVALUE;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_LENGTH:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_LENGTH;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_AREA:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_AREA;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_VOLUME:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_VOLUME;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_COUNT:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_COUNT;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_WEIGHT:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_WEIGHT;
						return;
					case Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.Q_TIME:
						TemplateType = IfcSimplePropertyTemplateTypeEnum.Q_TIME;
						return;
					
					case null:
						TemplateType = null;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

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

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

		[CrossSchemaAttribute(typeof(IIfcSimplePropertyTemplate), 8)]
		IIfcPropertyEnumeration IIfcSimplePropertyTemplate.Enumerators 
		{ 
			get
			{
				return Enumerators;
			} 
			set
			{
				Enumerators = value as PropertyResource.IfcPropertyEnumeration;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcSimplePropertyTemplate), 9)]
		IIfcUnit IIfcSimplePropertyTemplate.PrimaryUnit 
		{ 
			get
			{
				if (PrimaryUnit == null) return null;
				var ifcderivedunit = PrimaryUnit as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
					return ifcderivedunit;
				var ifcmonetaryunit = PrimaryUnit as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
					return ifcmonetaryunit;
				var ifcnamedunit = PrimaryUnit as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
					return ifcnamedunit;
				return null;
			} 
			set
			{
				if (value == null)
				{
					PrimaryUnit = null;
					return;
				}	
				var ifcderivedunit = value as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
				{
					PrimaryUnit = ifcderivedunit;
					return;
				}
				var ifcmonetaryunit = value as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
				{
					PrimaryUnit = ifcmonetaryunit;
					return;
				}
				var ifcnamedunit = value as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
				{
					PrimaryUnit = ifcnamedunit;
					return;
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcSimplePropertyTemplate), 10)]
		IIfcUnit IIfcSimplePropertyTemplate.SecondaryUnit 
		{ 
			get
			{
				if (SecondaryUnit == null) return null;
				var ifcderivedunit = SecondaryUnit as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
					return ifcderivedunit;
				var ifcmonetaryunit = SecondaryUnit as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
					return ifcmonetaryunit;
				var ifcnamedunit = SecondaryUnit as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
					return ifcnamedunit;
				return null;
			} 
			set
			{
				if (value == null)
				{
					SecondaryUnit = null;
					return;
				}	
				var ifcderivedunit = value as MeasureResource.IfcDerivedUnit;
				if (ifcderivedunit != null) 
				{
					SecondaryUnit = ifcderivedunit;
					return;
				}
				var ifcmonetaryunit = value as MeasureResource.IfcMonetaryUnit;
				if (ifcmonetaryunit != null) 
				{
					SecondaryUnit = ifcmonetaryunit;
					return;
				}
				var ifcnamedunit = value as MeasureResource.IfcNamedUnit;
				if (ifcnamedunit != null) 
				{
					SecondaryUnit = ifcnamedunit;
					return;
				}
				
			}
		}

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

		[CrossSchemaAttribute(typeof(IIfcSimplePropertyTemplate), 12)]
		Ifc4.Interfaces.IfcStateEnum? IIfcSimplePropertyTemplate.AccessState 
		{ 
			get
			{
				//## Custom code to handle enumeration of AccessState
				//##
				switch (AccessState)
				{
					case UtilityResource.IfcStateEnum.LOCKED:
						return Ifc4.Interfaces.IfcStateEnum.LOCKED;
					case UtilityResource.IfcStateEnum.READONLY:
						return Ifc4.Interfaces.IfcStateEnum.READONLY;
					case UtilityResource.IfcStateEnum.READONLYLOCKED:
						return Ifc4.Interfaces.IfcStateEnum.READONLYLOCKED;
					case UtilityResource.IfcStateEnum.READWRITE:
						return Ifc4.Interfaces.IfcStateEnum.READWRITE;
					case UtilityResource.IfcStateEnum.READWRITELOCKED:
						return Ifc4.Interfaces.IfcStateEnum.READWRITELOCKED;
					case null: 
						return null;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of AccessState
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcStateEnum.READWRITE:
						AccessState = UtilityResource.IfcStateEnum.READWRITE;
						return;
					case Ifc4.Interfaces.IfcStateEnum.READONLY:
						AccessState = UtilityResource.IfcStateEnum.READONLY;
						return;
					case Ifc4.Interfaces.IfcStateEnum.LOCKED:
						AccessState = UtilityResource.IfcStateEnum.LOCKED;
						return;
					case Ifc4.Interfaces.IfcStateEnum.READWRITELOCKED:
						AccessState = UtilityResource.IfcStateEnum.READWRITELOCKED;
						return;
					case Ifc4.Interfaces.IfcStateEnum.READONLYLOCKED:
						AccessState = UtilityResource.IfcStateEnum.READONLYLOCKED;
						return;
					
					case null:
						AccessState = null;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}
	//## Custom code
	//##
	}
}