// ------------------------------------------------------------------------------
// <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.CostResource
{
	public partial class @IfcCurrencyRelationship : IIfcCurrencyRelationship
	{

		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 3)]
		IIfcMonetaryUnit IIfcCurrencyRelationship.RelatingMonetaryUnit 
		{ 
			get
			{
				return RelatingMonetaryUnit;
			} 
			set
			{
				RelatingMonetaryUnit = value as MeasureResource.IfcMonetaryUnit;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 4)]
		IIfcMonetaryUnit IIfcCurrencyRelationship.RelatedMonetaryUnit 
		{ 
			get
			{
				return RelatedMonetaryUnit;
			} 
			set
			{
				RelatedMonetaryUnit = value as MeasureResource.IfcMonetaryUnit;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 5)]
		Ifc4.MeasureResource.IfcPositiveRatioMeasure IIfcCurrencyRelationship.ExchangeRate 
		{ 
			get
			{
				return new Ifc4.MeasureResource.IfcPositiveRatioMeasure(ExchangeRate);
			} 
			set
			{
				ExchangeRate = new MeasureResource.IfcPositiveRatioMeasure(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 6)]
		Ifc4.DateTimeResource.IfcDateTime? IIfcCurrencyRelationship.RateDateTime 
		{ 
			get
			{
				//## Handle return of RateDateTime for which no match was found
			    return RateDateTime != null
			        ? new Ifc4.DateTimeResource.IfcDateTime(RateDateTime.ToISODateTimeString())
			        : null;
			    //##
			} 
			set
			{
				//## Handle setting of RateDateTime for which no match was found
                if (!value.HasValue)
                {
                    RateDateTime = null;
                    return;
                }
                System.DateTime d = value.Value;
                RateDateTime = Model.Instances.New<DateTimeResource.IfcDateAndTime>(dt =>
                {
                    dt.DateComponent = Model.Instances.New<DateTimeResource.IfcCalendarDate>(date =>
                    {
                        date.YearComponent = d.Year;
                        date.MonthComponent = d.Month;
                        date.DayComponent = d.Day;
                    });
                    dt.TimeComponent = Model.Instances.New<DateTimeResource.IfcLocalTime>(t =>
                    {
                        t.HourComponent = d.Hour;
                        t.MinuteComponent = d.Minute;
                        t.SecondComponent = d.Second;
                    });
                });
				//##
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 7)]
		IIfcLibraryInformation IIfcCurrencyRelationship.RateSource 
		{ 
			get
			{
				return RateSource;
			} 
			set
			{
				RateSource = value as ExternalReferenceResource.IfcLibraryInformation;
				
			}
		}

		private  Ifc4.MeasureResource.IfcLabel? _name;


		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 1)]
		Ifc4.MeasureResource.IfcLabel? IIfcResourceLevelRelationship.Name 
		{ 
			get
			{
				return _name;
			} 
			set
			{
				SetValue(v => _name = v, _name, value, "Name", -1);
				
			}
		}

		private  Ifc4.MeasureResource.IfcText? _description;


		[CrossSchemaAttribute(typeof(IIfcCurrencyRelationship), 2)]
		Ifc4.MeasureResource.IfcText? IIfcResourceLevelRelationship.Description 
		{ 
			get
			{
				return _description;
			} 
			set
			{
				SetValue(v => _description = v, _description, value, "Description", -2);
				
			}
		}
	//## Custom code
	//##
	}
}