// ------------------------------------------------------------------------------
// <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.ExternalReferenceResource
{
	public partial class @IfcClassificationReference : IIfcClassificationReference
	{

		[CrossSchemaAttribute(typeof(IIfcClassificationReference), 4)]
		IIfcClassificationReferenceSelect IIfcClassificationReference.ReferencedSource 
		{ 
			get
			{
				if (ReferencedSource == null) return null;
				var ifcclassification = ReferencedSource as IfcClassification;
				if (ifcclassification != null) 
					return ifcclassification;
				var ifcclassificationreference = ReferencedSource as IfcClassificationReference;
				if (ifcclassificationreference != null) 
					return ifcclassificationreference;
				return null;
			} 
			set
			{
				if (value == null)
				{
					ReferencedSource = null;
					return;
				}	
				var ifcclassification = value as IfcClassification;
				if (ifcclassification != null) 
				{
					ReferencedSource = ifcclassification;
					return;
				}
				var ifcclassificationreference = value as IfcClassificationReference;
				if (ifcclassificationreference != null) 
				{
					ReferencedSource = ifcclassificationreference;
					return;
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcClassificationReference), 5)]
		Ifc4.MeasureResource.IfcText? IIfcClassificationReference.Description 
		{ 
			get
			{
				if (!Description.HasValue) return null;
				return new Ifc4.MeasureResource.IfcText(Description.Value);
			} 
			set
			{
				Description = value.HasValue ? 
					new MeasureResource.IfcText(value.Value) :  
					 new MeasureResource.IfcText?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcClassificationReference), 6)]
		Ifc4.MeasureResource.IfcIdentifier? IIfcClassificationReference.Sort 
		{ 
			get
			{
				if (!Sort.HasValue) return null;
				return new Ifc4.MeasureResource.IfcIdentifier(Sort.Value);
			} 
			set
			{
				Sort = value.HasValue ? 
					new MeasureResource.IfcIdentifier(value.Value) :  
					 new MeasureResource.IfcIdentifier?() ;
				
			}
		}
		IEnumerable<IIfcRelAssociatesClassification> IIfcClassificationReference.ClassificationRefForObjects 
		{ 
			get
			{
				return Model.Instances.Where<IIfcRelAssociatesClassification>(e => (e.RelatingClassification as IfcClassificationReference) == this, "RelatingClassification", this);
			} 
		}
		IEnumerable<IIfcClassificationReference> IIfcClassificationReference.HasReferences 
		{ 
			get
			{
				return Model.Instances.Where<IIfcClassificationReference>(e => (e.ReferencedSource as IfcClassificationReference) == this, "ReferencedSource", this);
			} 
		}
	//## Custom code
	//##
	}
}