// ------------------------------------------------------------------------------
// <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.StructuralElementsDomain
{
	public partial class @IfcReinforcingMeshType : IIfcReinforcingMeshType
	{

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 10)]
		Ifc4.Interfaces.IfcReinforcingMeshTypeEnum IIfcReinforcingMeshType.PredefinedType 
		{ 
			get
			{
				//## Custom code to handle enumeration of PredefinedType
				//##
				switch (PredefinedType)
				{
					case IfcReinforcingMeshTypeEnum.USERDEFINED:
						//## Optional custom handling of PredefinedType == .USERDEFINED. 
						//##
						return Ifc4.Interfaces.IfcReinforcingMeshTypeEnum.USERDEFINED;
					case IfcReinforcingMeshTypeEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcReinforcingMeshTypeEnum.NOTDEFINED;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of PredefinedType
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcReinforcingMeshTypeEnum.USERDEFINED:
						PredefinedType = IfcReinforcingMeshTypeEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcReinforcingMeshTypeEnum.NOTDEFINED:
						PredefinedType = IfcReinforcingMeshTypeEnum.NOTDEFINED;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

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

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 12)]
		Ifc4.MeasureResource.IfcPositiveLengthMeasure? IIfcReinforcingMeshType.MeshWidth 
		{ 
			get
			{
				if (!MeshWidth.HasValue) return null;
				return new Ifc4.MeasureResource.IfcPositiveLengthMeasure(MeshWidth.Value);
			} 
			set
			{
				MeshWidth = value.HasValue ? 
					new MeasureResource.IfcPositiveLengthMeasure(value.Value) :  
					 new MeasureResource.IfcPositiveLengthMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 13)]
		Ifc4.MeasureResource.IfcPositiveLengthMeasure? IIfcReinforcingMeshType.LongitudinalBarNominalDiameter 
		{ 
			get
			{
				if (!LongitudinalBarNominalDiameter.HasValue) return null;
				return new Ifc4.MeasureResource.IfcPositiveLengthMeasure(LongitudinalBarNominalDiameter.Value);
			} 
			set
			{
				LongitudinalBarNominalDiameter = value.HasValue ? 
					new MeasureResource.IfcPositiveLengthMeasure(value.Value) :  
					 new MeasureResource.IfcPositiveLengthMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 14)]
		Ifc4.MeasureResource.IfcPositiveLengthMeasure? IIfcReinforcingMeshType.TransverseBarNominalDiameter 
		{ 
			get
			{
				if (!TransverseBarNominalDiameter.HasValue) return null;
				return new Ifc4.MeasureResource.IfcPositiveLengthMeasure(TransverseBarNominalDiameter.Value);
			} 
			set
			{
				TransverseBarNominalDiameter = value.HasValue ? 
					new MeasureResource.IfcPositiveLengthMeasure(value.Value) :  
					 new MeasureResource.IfcPositiveLengthMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 15)]
		Ifc4.MeasureResource.IfcAreaMeasure? IIfcReinforcingMeshType.LongitudinalBarCrossSectionArea 
		{ 
			get
			{
				if (!LongitudinalBarCrossSectionArea.HasValue) return null;
				return new Ifc4.MeasureResource.IfcAreaMeasure(LongitudinalBarCrossSectionArea.Value);
			} 
			set
			{
				LongitudinalBarCrossSectionArea = value.HasValue ? 
					new MeasureResource.IfcAreaMeasure(value.Value) :  
					 new MeasureResource.IfcAreaMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 16)]
		Ifc4.MeasureResource.IfcAreaMeasure? IIfcReinforcingMeshType.TransverseBarCrossSectionArea 
		{ 
			get
			{
				if (!TransverseBarCrossSectionArea.HasValue) return null;
				return new Ifc4.MeasureResource.IfcAreaMeasure(TransverseBarCrossSectionArea.Value);
			} 
			set
			{
				TransverseBarCrossSectionArea = value.HasValue ? 
					new MeasureResource.IfcAreaMeasure(value.Value) :  
					 new MeasureResource.IfcAreaMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 17)]
		Ifc4.MeasureResource.IfcPositiveLengthMeasure? IIfcReinforcingMeshType.LongitudinalBarSpacing 
		{ 
			get
			{
				if (!LongitudinalBarSpacing.HasValue) return null;
				return new Ifc4.MeasureResource.IfcPositiveLengthMeasure(LongitudinalBarSpacing.Value);
			} 
			set
			{
				LongitudinalBarSpacing = value.HasValue ? 
					new MeasureResource.IfcPositiveLengthMeasure(value.Value) :  
					 new MeasureResource.IfcPositiveLengthMeasure?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 18)]
		Ifc4.MeasureResource.IfcPositiveLengthMeasure? IIfcReinforcingMeshType.TransverseBarSpacing 
		{ 
			get
			{
				if (!TransverseBarSpacing.HasValue) return null;
				return new Ifc4.MeasureResource.IfcPositiveLengthMeasure(TransverseBarSpacing.Value);
			} 
			set
			{
				TransverseBarSpacing = value.HasValue ? 
					new MeasureResource.IfcPositiveLengthMeasure(value.Value) :  
					 new MeasureResource.IfcPositiveLengthMeasure?() ;
				
			}
		}

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

		[CrossSchemaAttribute(typeof(IIfcReinforcingMeshType), 20)]
		IItemSet<IIfcBendingParameterSelect> IIfcReinforcingMeshType.BendingParameters 
		{ 
			get
			{
			
				return _bendingParametersIfc4 ?? (_bendingParametersIfc4 = new Common.Collections.ExtendedItemSet<IfcBendingParameterSelect, IIfcBendingParameterSelect>(
                    BendingParameters, 
                    new ItemSet<IIfcBendingParameterSelect>(this, 0, -20), 
					BendingParametersToIfc4, 
                    BendingParametersToIfc2X3));
			} 
		}

		//private field to hold any extended data
		private IItemSet<IIfcBendingParameterSelect> _bendingParametersIfc4;
		//transformation function to convert/cast IFC2x3 data to appear as IFC4
		private static IIfcBendingParameterSelect BendingParametersToIfc4 (IfcBendingParameterSelect member)
		{
			if (member == null) 
				return null;
			switch (member.GetType().Name)
			{
				case "IfcLengthMeasure":
					return new Ifc4.MeasureResource.IfcLengthMeasure((MeasureResource.IfcLengthMeasure)member);
				case "IfcPlaneAngleMeasure":
					return new Ifc4.MeasureResource.IfcPlaneAngleMeasure((MeasureResource.IfcPlaneAngleMeasure)member);
				default:
					throw new System.NotSupportedException();
			}
		}

		//transformation function to convert/cast IFC4 data to appear as IFC2x3 if possible
		private static IfcBendingParameterSelect BendingParametersToIfc2X3 (IIfcBendingParameterSelect member){
			if (member == null) 
				return null;
			var name = member.GetType().Name;
			switch (name)
			{
				case "IfcLengthMeasure":
					return new MeasureResource.IfcLengthMeasure((Ifc4.MeasureResource.IfcLengthMeasure)member);
				case "IfcPlaneAngleMeasure":
					return new MeasureResource.IfcPlaneAngleMeasure((Ifc4.MeasureResource.IfcPlaneAngleMeasure)member);
				default:
					throw new System.NotSupportedException();
			}
		}
	//## Custom code
	//##
	}
}