// ------------------------------------------------------------------------------
// <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;

// ReSharper disable once CheckNamespace
namespace Xbim.Ifc2x3.ProductExtension
{
	public partial class @IfcSpaceType : IIfcSpaceType
	{

		[CrossSchemaAttribute(typeof(IIfcSpaceType), 10)]
		Ifc4.Interfaces.IfcSpaceTypeEnum IIfcSpaceType.PredefinedType 
		{ 
			get
			{
				//## Custom code to handle enumeration of PredefinedType
				//##
				switch (PredefinedType)
				{
					case IfcSpaceTypeEnum.USERDEFINED:
						//## Optional custom handling of PredefinedType == .USERDEFINED. 
                        if (ElementType.HasValue)
                        {
                            Ifc4.Interfaces.IfcSpaceTypeEnum result;
                            if (System.Enum.TryParse(ElementType.Value, false, out result))
                                return result;
                        }
						//##
						return Ifc4.Interfaces.IfcSpaceTypeEnum.USERDEFINED;
					case IfcSpaceTypeEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcSpaceTypeEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of PredefinedType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcSpaceTypeEnum.SPACE:
						//## Handle setting of SPACE member from IfcSpaceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcSpaceTypeEnum.PARKING:
						//## Handle setting of PARKING member from IfcSpaceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcSpaceTypeEnum.GFA:
						//## Handle setting of GFA member from IfcSpaceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcSpaceTypeEnum.INTERNAL:
						//## Handle setting of INTERNAL member from IfcSpaceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcSpaceTypeEnum.EXTERNAL:
						//## Handle setting of EXTERNAL member from IfcSpaceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcSpaceTypeEnum.USERDEFINED:
						PredefinedType = IfcSpaceTypeEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcSpaceTypeEnum.NOTDEFINED:
						PredefinedType = IfcSpaceTypeEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

		private  Ifc4.MeasureResource.IfcLabel? _longName;


		[CrossSchemaAttribute(typeof(IIfcSpaceType), 11)]
		Ifc4.MeasureResource.IfcLabel? IIfcSpaceType.LongName 
		{ 
			get
			{
				return _longName;
			} 
			set
			{
				SetValue(v => _longName = v, _longName, value, "LongName", -11);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcSpaceType), 9)]
		Ifc4.MeasureResource.IfcLabel? IIfcSpatialElementType.ElementType 
		{ 
			get
			{
				if (!ElementType.HasValue) return null;
				return new Ifc4.MeasureResource.IfcLabel(ElementType.Value);
			} 
			set
			{
				ElementType = value.HasValue ? 
					new MeasureResource.IfcLabel(value.Value) :  
					 new MeasureResource.IfcLabel?() ;
				
			}
		}
	//## Custom code
	//##
	}
}