// ------------------------------------------------------------------------------
// <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.ElectricalDomain
{
	public partial class @IfcElectricApplianceType : IIfcElectricApplianceType
	{

		[CrossSchemaAttribute(typeof(IIfcElectricApplianceType), 10)]
		Ifc4.Interfaces.IfcElectricApplianceTypeEnum IIfcElectricApplianceType.PredefinedType 
		{ 
			get
			{
				//## Custom code to handle enumeration of PredefinedType
				//##
				switch (PredefinedType)
				{
					case IfcElectricApplianceTypeEnum.COMPUTER:
						//## Handle translation of COMPUTER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.DIRECTWATERHEATER:
						//## Handle translation of DIRECTWATERHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.DISHWASHER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.DISHWASHER;
					case IfcElectricApplianceTypeEnum.ELECTRICCOOKER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.ELECTRICCOOKER;
					case IfcElectricApplianceTypeEnum.ELECTRICHEATER:
						//## Handle translation of ELECTRICHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.FACSIMILE:
						//## Handle translation of FACSIMILE member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.FREESTANDINGFAN:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREESTANDINGFAN;
					case IfcElectricApplianceTypeEnum.FREEZER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREEZER;
					case IfcElectricApplianceTypeEnum.FRIDGE_FREEZER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FRIDGE_FREEZER;
					case IfcElectricApplianceTypeEnum.HANDDRYER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.HANDDRYER;
					case IfcElectricApplianceTypeEnum.INDIRECTWATERHEATER:
						//## Handle translation of INDIRECTWATERHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.MICROWAVE:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.MICROWAVE;
					case IfcElectricApplianceTypeEnum.PHOTOCOPIER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.PHOTOCOPIER;
					case IfcElectricApplianceTypeEnum.PRINTER:
						//## Handle translation of PRINTER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.REFRIGERATOR:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.REFRIGERATOR;
					case IfcElectricApplianceTypeEnum.RADIANTHEATER:
						//## Handle translation of RADIANTHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.SCANNER:
						//## Handle translation of SCANNER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.TELEPHONE:
						//## Handle translation of TELEPHONE member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.TUMBLEDRYER:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.TUMBLEDRYER;
					case IfcElectricApplianceTypeEnum.TV:
						//## Handle translation of TV member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.VENDINGMACHINE:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.VENDINGMACHINE;
					case IfcElectricApplianceTypeEnum.WASHINGMACHINE:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.WASHINGMACHINE;
					case IfcElectricApplianceTypeEnum.WATERHEATER:
						//## Handle translation of WATERHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.WATERCOOLER:
						//## Handle translation of WATERCOOLER member from IfcElectricApplianceTypeEnum in property PredefinedType
                        return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
						//##
					case IfcElectricApplianceTypeEnum.USERDEFINED:
						//## Optional custom handling of PredefinedType == .USERDEFINED. 
                        if (ElementType.HasValue)
                        {
                            Ifc4.Interfaces.IfcElectricApplianceTypeEnum result;
                            if (System.Enum.TryParse(ElementType.Value, false, out result))
                                return result;
                        }
						//##
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED;
					case IfcElectricApplianceTypeEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcElectricApplianceTypeEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of PredefinedType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.DISHWASHER:
						PredefinedType = IfcElectricApplianceTypeEnum.DISHWASHER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.ELECTRICCOOKER:
						PredefinedType = IfcElectricApplianceTypeEnum.ELECTRICCOOKER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREESTANDINGELECTRICHEATER:
						//## Handle setting of FREESTANDINGELECTRICHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcElectricApplianceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREESTANDINGFAN:
						PredefinedType = IfcElectricApplianceTypeEnum.FREESTANDINGFAN;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREESTANDINGWATERHEATER:
						//## Handle setting of FREESTANDINGWATERHEATER member from IfcElectricApplianceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcElectricApplianceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREESTANDINGWATERCOOLER:
						//## Handle setting of FREESTANDINGWATERCOOLER member from IfcElectricApplianceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcElectricApplianceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FREEZER:
						PredefinedType = IfcElectricApplianceTypeEnum.FREEZER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.FRIDGE_FREEZER:
						PredefinedType = IfcElectricApplianceTypeEnum.FRIDGE_FREEZER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.HANDDRYER:
						PredefinedType = IfcElectricApplianceTypeEnum.HANDDRYER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.KITCHENMACHINE:
						//## Handle setting of KITCHENMACHINE member from IfcElectricApplianceTypeEnum in property PredefinedType
						ElementType = value.ToString();
                        PredefinedType = IfcElectricApplianceTypeEnum.USERDEFINED;
				        return;
						//##
										case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.MICROWAVE:
						PredefinedType = IfcElectricApplianceTypeEnum.MICROWAVE;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.PHOTOCOPIER:
						PredefinedType = IfcElectricApplianceTypeEnum.PHOTOCOPIER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.REFRIGERATOR:
						PredefinedType = IfcElectricApplianceTypeEnum.REFRIGERATOR;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.TUMBLEDRYER:
						PredefinedType = IfcElectricApplianceTypeEnum.TUMBLEDRYER;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.VENDINGMACHINE:
						PredefinedType = IfcElectricApplianceTypeEnum.VENDINGMACHINE;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.WASHINGMACHINE:
						PredefinedType = IfcElectricApplianceTypeEnum.WASHINGMACHINE;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.USERDEFINED:
						PredefinedType = IfcElectricApplianceTypeEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcElectricApplianceTypeEnum.NOTDEFINED:
						PredefinedType = IfcElectricApplianceTypeEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}
	//## Custom code
        Ifc4.MeasureResource.IfcLabel? IIfcElementType.ElementType
        {
            get
            {
                switch (PredefinedType)
                {
                    case IfcElectricApplianceTypeEnum.COMPUTER:
                    case IfcElectricApplianceTypeEnum.DIRECTWATERHEATER:
                    case IfcElectricApplianceTypeEnum.ELECTRICHEATER:
                    case IfcElectricApplianceTypeEnum.FACSIMILE:
                    case IfcElectricApplianceTypeEnum.INDIRECTWATERHEATER:
                    case IfcElectricApplianceTypeEnum.PRINTER:
                    case IfcElectricApplianceTypeEnum.RADIANTHEATER:
                    case IfcElectricApplianceTypeEnum.SCANNER:
                    case IfcElectricApplianceTypeEnum.TELEPHONE:
                    case IfcElectricApplianceTypeEnum.TV:
                    case IfcElectricApplianceTypeEnum.WATERHEATER:
                    case IfcElectricApplianceTypeEnum.WATERCOOLER:
                        return new Ifc4.MeasureResource.IfcLabel(System.Enum.GetName(typeof(IfcElectricApplianceTypeEnum), PredefinedType));
                }
                return !ElementType.HasValue ? null : new Ifc4.MeasureResource.IfcLabel(ElementType.Value);
            }
            set
            {
                ElementType = value.HasValue
                    ? value.Value.ToString()
                    : null;

                if (!value.HasValue)
                    return;

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