// ------------------------------------------------------------------------------
// <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.GeometryResource;
using Xbim.Ifc4.MeasureResource;
using Xbim.Ifc4.PresentationAppearanceResource;
using System;
using System.Collections.Generic;
using System.Linq;
using Xbim.Common;
using Xbim.Common.Exceptions;
using Xbim.Ifc4.Interfaces;
using Xbim.Ifc4.PresentationOrganizationResource;
//## Custom using statements
//##

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcLightSource
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcLightSource : IIfcGeometricRepresentationItem
	{
		IfcLabel? @Name { get;  set; }
		IIfcColourRgb @LightColour { get;  set; }
		IfcNormalisedRatioMeasure? @AmbientIntensity { get;  set; }
		IfcNormalisedRatioMeasure? @Intensity { get;  set; }
	
	}
}

namespace Xbim.Ifc4.PresentationOrganizationResource
{
	[ExpressType("IfcLightSource", 755)]
	// ReSharper disable once PartialTypeWithSinglePart
	public abstract partial class @IfcLightSource : IfcGeometricRepresentationItem, IIfcLightSource, IEquatable<@IfcLightSource>
	{
		#region IIfcLightSource explicit implementation
		IfcLabel? IIfcLightSource.Name { 
 
			get { return @Name; } 
			set { Name = value;}
		}	
		IIfcColourRgb IIfcLightSource.LightColour { 
 
 
			get { return @LightColour; } 
			set { LightColour = value as IfcColourRgb;}
		}	
		IfcNormalisedRatioMeasure? IIfcLightSource.AmbientIntensity { 
 
			get { return @AmbientIntensity; } 
			set { AmbientIntensity = value;}
		}	
		IfcNormalisedRatioMeasure? IIfcLightSource.Intensity { 
 
			get { return @Intensity; } 
			set { Intensity = value;}
		}	
		#endregion

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcLightSource(IModel model, int label, bool activated) : base(model, label, activated)  
		{
		}

		#region Explicit attribute fields
		private IfcLabel? _name;
		private IfcColourRgb _lightColour;
		private IfcNormalisedRatioMeasure? _ambientIntensity;
		private IfcNormalisedRatioMeasure? _intensity;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 3)]
		public IfcLabel? @Name 
		{ 
			get 
			{
				if(_activated) return _name;
				Activate();
				return _name;
			} 
			set
			{
				SetValue( v =>  _name = v, _name, value,  "Name", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 4)]
		public IfcColourRgb @LightColour 
		{ 
			get 
			{
				if(_activated) return _lightColour;
				Activate();
				return _lightColour;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _lightColour = v, _lightColour, value,  "LightColour", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcNormalisedRatioMeasure? @AmbientIntensity 
		{ 
			get 
			{
				if(_activated) return _ambientIntensity;
				Activate();
				return _ambientIntensity;
			} 
			set
			{
				SetValue( v =>  _ambientIntensity = v, _ambientIntensity, value,  "AmbientIntensity", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 6)]
		public IfcNormalisedRatioMeasure? @Intensity 
		{ 
			get 
			{
				if(_activated) return _intensity;
				Activate();
				return _intensity;
			} 
			set
			{
				SetValue( v =>  _intensity = v, _intensity, value,  "Intensity", 4);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_name = value.StringVal;
					return;
				case 1: 
					_lightColour = (IfcColourRgb)(value.EntityVal);
					return;
				case 2: 
					_ambientIntensity = value.RealVal;
					return;
				case 3: 
					_intensity = value.RealVal;
					return;
				default:
					throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
			}
		}
		#endregion

		#region Equality comparers and operators
        public bool Equals(@IfcLightSource other)
	    {
	        return this == other;
	    }
        #endregion

		#region Custom code (will survive code regeneration)
		//## Custom code
		//##
		#endregion
	}
}