// ------------------------------------------------------------------------------
// <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 @IfcDocumentInformation : IIfcDocumentInformation
	{

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 1)]
		Ifc4.MeasureResource.IfcIdentifier IIfcDocumentInformation.Identification 
		{ 
			get
			{
				return new Ifc4.MeasureResource.IfcIdentifier(Identification);
			} 
			set
			{
				Identification = new MeasureResource.IfcIdentifier(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 2)]
		Ifc4.MeasureResource.IfcLabel IIfcDocumentInformation.Name 
		{ 
			get
			{
				return new Ifc4.MeasureResource.IfcLabel(Name);
			} 
			set
			{
				Name = new MeasureResource.IfcLabel(value);
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 3)]
		Ifc4.MeasureResource.IfcText? IIfcDocumentInformation.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(IIfcDocumentInformation), 4)]
		Ifc4.ExternalReferenceResource.IfcURIReference? IIfcDocumentInformation.Location 
		{ 
			get
			{
				if (!Location.HasValue) return null;
				return new Ifc4.ExternalReferenceResource.IfcURIReference(Location.Value);
			} 
			set
			{
				Location = value.HasValue ? 
					new MeasureResource.IfcURIReference(value.Value) :  
					 new MeasureResource.IfcURIReference?() ;
				
			}
		}

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

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

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

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

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 9)]
		IIfcActorSelect IIfcDocumentInformation.DocumentOwner 
		{ 
			get
			{
				if (DocumentOwner == null) return null;
				var ifcorganization = DocumentOwner as ActorResource.IfcOrganization;
				if (ifcorganization != null) 
					return ifcorganization;
				var ifcperson = DocumentOwner as ActorResource.IfcPerson;
				if (ifcperson != null) 
					return ifcperson;
				var ifcpersonandorganization = DocumentOwner as ActorResource.IfcPersonAndOrganization;
				if (ifcpersonandorganization != null) 
					return ifcpersonandorganization;
				return null;
			} 
			set
			{
				if (value == null)
				{
					DocumentOwner = null;
					return;
				}	
				var ifcorganization = value as ActorResource.IfcOrganization;
				if (ifcorganization != null) 
				{
					DocumentOwner = ifcorganization;
					return;
				}
				var ifcperson = value as ActorResource.IfcPerson;
				if (ifcperson != null) 
				{
					DocumentOwner = ifcperson;
					return;
				}
				var ifcpersonandorganization = value as ActorResource.IfcPersonAndOrganization;
				if (ifcpersonandorganization != null) 
				{
					DocumentOwner = ifcpersonandorganization;
					return;
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 10)]
		IItemSet<IIfcActorSelect> IIfcDocumentInformation.Editors 
		{ 
			get
			{
			
				return new Common.Collections.ProxyItemSet<ActorResource.IfcActorSelect, IIfcActorSelect>(Editors);
			} 
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 11)]
		Ifc4.DateTimeResource.IfcDateTime? IIfcDocumentInformation.CreationTime 
		{ 
			get
			{
				if (!CreationTime.HasValue) return null;
				return new Ifc4.DateTimeResource.IfcDateTime(CreationTime.Value);
			} 
			set
			{
				CreationTime = value.HasValue ? 
					new DateTimeResource.IfcDateTime(value.Value) :  
					 new DateTimeResource.IfcDateTime?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 12)]
		Ifc4.DateTimeResource.IfcDateTime? IIfcDocumentInformation.LastRevisionTime 
		{ 
			get
			{
				if (!LastRevisionTime.HasValue) return null;
				return new Ifc4.DateTimeResource.IfcDateTime(LastRevisionTime.Value);
			} 
			set
			{
				LastRevisionTime = value.HasValue ? 
					new DateTimeResource.IfcDateTime(value.Value) :  
					 new DateTimeResource.IfcDateTime?() ;
				
			}
		}

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

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 14)]
		Ifc4.DateTimeResource.IfcDate? IIfcDocumentInformation.ValidFrom 
		{ 
			get
			{
				if (!ValidFrom.HasValue) return null;
				return new Ifc4.DateTimeResource.IfcDate(ValidFrom.Value);
			} 
			set
			{
				ValidFrom = value.HasValue ? 
					new DateTimeResource.IfcDate(value.Value) :  
					 new DateTimeResource.IfcDate?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 15)]
		Ifc4.DateTimeResource.IfcDate? IIfcDocumentInformation.ValidUntil 
		{ 
			get
			{
				if (!ValidUntil.HasValue) return null;
				return new Ifc4.DateTimeResource.IfcDate(ValidUntil.Value);
			} 
			set
			{
				ValidUntil = value.HasValue ? 
					new DateTimeResource.IfcDate(value.Value) :  
					 new DateTimeResource.IfcDate?() ;
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 16)]
		Ifc4.Interfaces.IfcDocumentConfidentialityEnum? IIfcDocumentInformation.Confidentiality 
		{ 
			get
			{
				//## Custom code to handle enumeration of Confidentiality
				//##
				switch (Confidentiality)
				{
					case IfcDocumentConfidentialityEnum.CONFIDENTIAL:
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.CONFIDENTIAL;
					case IfcDocumentConfidentialityEnum.PERSONAL:
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.PERSONAL;
					case IfcDocumentConfidentialityEnum.PUBLIC:
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.PUBLIC;
					case IfcDocumentConfidentialityEnum.RESTRICTED:
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.RESTRICTED;
					case IfcDocumentConfidentialityEnum.USERDEFINED:
						//## Optional custom handling of Confidentiality == .USERDEFINED. 
						//##
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.USERDEFINED;
					case IfcDocumentConfidentialityEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcDocumentConfidentialityEnum.NOTDEFINED;
					case null: 
						return null;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of Confidentiality
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.PUBLIC:
						Confidentiality = IfcDocumentConfidentialityEnum.PUBLIC;
						return;
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.RESTRICTED:
						Confidentiality = IfcDocumentConfidentialityEnum.RESTRICTED;
						return;
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.CONFIDENTIAL:
						Confidentiality = IfcDocumentConfidentialityEnum.CONFIDENTIAL;
						return;
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.PERSONAL:
						Confidentiality = IfcDocumentConfidentialityEnum.PERSONAL;
						return;
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.USERDEFINED:
						Confidentiality = IfcDocumentConfidentialityEnum.USERDEFINED;
						return;
					case Ifc4.Interfaces.IfcDocumentConfidentialityEnum.NOTDEFINED:
						Confidentiality = IfcDocumentConfidentialityEnum.NOTDEFINED;
						return;
					
					case null:
						Confidentiality = null;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}

		[CrossSchemaAttribute(typeof(IIfcDocumentInformation), 17)]
		Ifc4.Interfaces.IfcDocumentStatusEnum? IIfcDocumentInformation.Status 
		{ 
			get
			{
				//## Custom code to handle enumeration of Status
				//##
				switch (Status)
				{
					case IfcDocumentStatusEnum.DRAFT:
						return Ifc4.Interfaces.IfcDocumentStatusEnum.DRAFT;
					case IfcDocumentStatusEnum.FINAL:
						return Ifc4.Interfaces.IfcDocumentStatusEnum.FINAL;
					case IfcDocumentStatusEnum.FINALDRAFT:
						return Ifc4.Interfaces.IfcDocumentStatusEnum.FINALDRAFT;
					case IfcDocumentStatusEnum.REVISION:
						return Ifc4.Interfaces.IfcDocumentStatusEnum.REVISION;
					case IfcDocumentStatusEnum.NOTDEFINED:
						return Ifc4.Interfaces.IfcDocumentStatusEnum.NOTDEFINED;
					case null: 
						return null;
					
					default:
						throw new System.ArgumentOutOfRangeException();
				}
			} 
			set
			{
				//## Custom code to handle setting of enumeration of Status
				//##
				switch (value)
				{
					case Ifc4.Interfaces.IfcDocumentStatusEnum.DRAFT:
						Status = IfcDocumentStatusEnum.DRAFT;
						return;
					case Ifc4.Interfaces.IfcDocumentStatusEnum.FINALDRAFT:
						Status = IfcDocumentStatusEnum.FINALDRAFT;
						return;
					case Ifc4.Interfaces.IfcDocumentStatusEnum.FINAL:
						Status = IfcDocumentStatusEnum.FINAL;
						return;
					case Ifc4.Interfaces.IfcDocumentStatusEnum.REVISION:
						Status = IfcDocumentStatusEnum.REVISION;
						return;
					case Ifc4.Interfaces.IfcDocumentStatusEnum.NOTDEFINED:
						Status = IfcDocumentStatusEnum.NOTDEFINED;
						return;
					
					case null:
						Status = null;
						return;
					default:
						throw new System.ArgumentOutOfRangeException();
				}
				
			}
		}
		IEnumerable<IIfcRelAssociatesDocument> IIfcDocumentInformation.DocumentInfoForObjects 
		{ 
			get
			{
				return Model.Instances.Where<IIfcRelAssociatesDocument>(e => (e.RelatingDocument as IfcDocumentInformation) == this, "RelatingDocument", this);
			} 
		}
		IEnumerable<IIfcDocumentReference> IIfcDocumentInformation.HasDocumentReferences 
		{ 
			get
			{
				return Model.Instances.Where<IIfcDocumentReference>(e => (e.ReferencedDocument as IfcDocumentInformation) == this, "ReferencedDocument", this);
			} 
		}
		IEnumerable<IIfcDocumentInformationRelationship> IIfcDocumentInformation.IsPointedTo 
		{ 
			get
			{
				return Model.Instances.Where<IIfcDocumentInformationRelationship>(e => e.RelatedDocuments != null &&  e.RelatedDocuments.Contains(this), "RelatedDocuments", this);
			} 
		}
		IEnumerable<IIfcDocumentInformationRelationship> IIfcDocumentInformation.IsPointer 
		{ 
			get
			{
				return Model.Instances.Where<IIfcDocumentInformationRelationship>(e => (e.RelatingDocument as IfcDocumentInformation) == this, "RelatingDocument", this);
			} 
		}
	//## Custom code
	//##
	}
}