// ------------------------------------------------------------------------------
// <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.BuildingcontrolsDomain
{
	public partial class @IfcControllerType : IIfcControllerType
	{

		[CrossSchemaAttribute(typeof(IIfcControllerType), 10)]
		Ifc4.Interfaces.IfcControllerTypeEnum IIfcControllerType.PredefinedType 
		{ 
			get
			{
				//## Custom code to handle enumeration of PredefinedType
				//##
				switch (PredefinedType)
				{
					case IfcControllerTypeEnum.FLOATING:
						return Ifc4.Interfaces.IfcControllerTypeEnum.FLOATING;
					case IfcControllerTypeEnum.PROPORTIONAL:
						return Ifc4.Interfaces.IfcControllerTypeEnum.PROPORTIONAL;
					case IfcControllerTypeEnum.PROPORTIONALINTEGRAL:
						//## Handle translation of PROPORTIONALINTEGRAL member from IfcControllerTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcControllerTypeEnum.USERDEFINED;
						//##
					case IfcControllerTypeEnum.PROPORTIONALINTEGRALDERIVATIVE:
						//## Handle translation of PROPORTIONALINTEGRALDERIVATIVE member from IfcControllerTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcControllerTypeEnum.USERDEFINED;
						//##
					case IfcControllerTypeEnum.TIMEDTWOPOSITION:
						//## Handle translation of TIMEDTWOPOSITION member from IfcControllerTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcControllerTypeEnum.USERDEFINED;
						//##
					case IfcControllerTypeEnum.TWOPOSITION:
						return Ifc4.Interfaces.IfcControllerTypeEnum.TWOPOSITION;
					case IfcControllerTypeEnum.USERDEFINED:
						//## Optional custom handling of PredefinedType == .USERDEFINED. 
                        if (ElementType.HasValue)
                        {
                            Ifc4.Interfaces.IfcControllerTypeEnum result;
                            if (System.Enum.TryParse(ElementType.Value, false, out result))
                                return result;
                        }
						//##
						return Ifc4.Interfaces.IfcControllerTypeEnum.USERDEFINED;
					case IfcControllerTypeEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcControllerTypeEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of PredefinedType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcControllerTypeEnum.FLOATING:
						PredefinedType = IfcControllerTypeEnum.FLOATING;
						return;
					case Ifc4.Interfaces.IfcControllerTypeEnum.PROGRAMMABLE:
						//## Handle setting of PROGRAMMABLE member from IfcControllerTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcControllerTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcControllerTypeEnum.PROPORTIONAL:
						PredefinedType = IfcControllerTypeEnum.PROPORTIONAL;
						return;
					case Ifc4.Interfaces.IfcControllerTypeEnum.MULTIPOSITION:
						//## Handle setting of MULTIPOSITION member from IfcControllerTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcControllerTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcControllerTypeEnum.TWOPOSITION:
						PredefinedType = IfcControllerTypeEnum.TWOPOSITION;
						return;
					case Ifc4.Interfaces.IfcControllerTypeEnum.USERDEFINED:
						PredefinedType = IfcControllerTypeEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcControllerTypeEnum.NOTDEFINED:
						PredefinedType = IfcControllerTypeEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}
	//## Custom code
        Ifc4.MeasureResource.IfcLabel? IIfcElementType.ElementType
        {
            get
            {
                switch (PredefinedType)
                {
                    case IfcControllerTypeEnum.PROPORTIONALINTEGRAL:
                        return new Ifc4.MeasureResource.IfcLabel("PROPORTIONALINTEGRAL");
                    case IfcControllerTypeEnum.PROPORTIONALINTEGRALDERIVATIVE:
                        return new Ifc4.MeasureResource.IfcLabel("PROPORTIONALINTEGRALDERIVATIVE");
                    case IfcControllerTypeEnum.TIMEDTWOPOSITION:
                        return new Ifc4.MeasureResource.IfcLabel("TIMEDTWOPOSITION");
                }
                return !ElementType.HasValue ? null : new Ifc4.MeasureResource.IfcLabel(ElementType.Value);
            }
            set
            {
                ElementType = value.HasValue
                    ? value.Value.ToString()
                    : null;

                if (!value.HasValue)
                    return;

                IfcControllerTypeEnum e;
                if (System.Enum.TryParse(value.Value.ToString(), true, out e))
                    PredefinedType = e;
            }
        }
	//##
	}
}