//---------------------------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated by T4Model template for T4 (https://github.com/linq2db/linq2db).
//    Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------------------------------

#pragma warning disable 1573, 1591
#nullable enable

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;

using Tests.T4.Model;

namespace Tests.T4.Model
{
	public partial class TestClass3 : IEditableObject
	{
		public TestClass3()
		{
			AcceptChanges();
		}

		#region EditableLong1 : long

		private long  _currentEditableLong1 = 12345;
		private long _originalEditableLong1 = 12345;
		public  long          EditableLong1
		{
			get { return _currentEditableLong1; }
			set { _currentEditableLong1 = value; }
		}

		#region EditableObject support

		public void AcceptEditableLong1Changes()
		{
			_originalEditableLong1 = _currentEditableLong1;
		}

		public void RejectEditableLong1Changes()
		{
			EditableLong1 = _originalEditableLong1;
		}

		public bool IsEditableLong1Dirty
		{
			get { return _currentEditableLong1 != _originalEditableLong1; }
		}

		#endregion

		#endregion

		#region EditableInt1 : int

		private int  _currentEditableInt1;
		private int _originalEditableInt1;
		public  int          EditableInt1
		{
			get { return _currentEditableInt1; }
			set { _currentEditableInt1 = value; }
		}

		#region EditableObject support

		public void AcceptEditableInt1Changes()
		{
			_originalEditableInt1 = _currentEditableInt1;
		}

		public void RejectEditableInt1Changes()
		{
			EditableInt1 = _originalEditableInt1;
		}

		public bool IsEditableInt1Dirty
		{
			get { return _currentEditableInt1 != _originalEditableInt1; }
		}

		#endregion

		#endregion

		#region EditableInt3 : int

		private int  _currentEditableInt3;
		private int _originalEditableInt3;
		public  int          EditableInt3
		{
			get { return _currentEditableInt3; }
			set { _currentEditableInt3 = value; }
		}

		#region EditableObject support

		public void AcceptEditableInt3Changes()
		{
			_originalEditableInt3 = _currentEditableInt3;
		}

		public void RejectEditableInt3Changes()
		{
			EditableInt3 = _originalEditableInt3;
		}

		public bool IsEditableInt3Dirty
		{
			get { return _currentEditableInt3 != _originalEditableInt3; }
		}

		#endregion

		#endregion

		#region EditableDouble1 : double

		private double  _currentEditableDouble1;
		private double _originalEditableDouble1;
		public  double          EditableDouble1
		{
			get { return _currentEditableDouble1; }
			set { _currentEditableDouble1 = value; }
		}

		#region EditableObject support

		public void AcceptEditableDouble1Changes()
		{
			_originalEditableDouble1 = _currentEditableDouble1;
		}

		public void RejectEditableDouble1Changes()
		{
			EditableDouble1 = _originalEditableDouble1;
		}

		public bool IsEditableDouble1Dirty
		{
			get { return Math.Abs(_currentEditableDouble1 - _originalEditableDouble1) <= 16 * Double.Epsilon * Math.Max(Math.Abs(_currentEditableDouble1), Math.Abs(_originalEditableDouble1)); }
		}

		#endregion

		#endregion

		public List<string?>? Field4;

		public List<string>? Field5;

		public List<string?> Field6 = new List<string?>();

		public List<string> Field7 = new List<string>();

		#region EditableObject support

		partial void BeforeAcceptChanges();
		partial void AfterAcceptChanges ();

		public virtual void AcceptChanges()
		{
			BeforeAcceptChanges();

			AcceptEditableLong1Changes();
			AcceptEditableInt1Changes();
			AcceptEditableInt3Changes();
			AcceptEditableDouble1Changes();

			AfterAcceptChanges();
		}

		partial void BeforeRejectChanges();
		partial void AfterRejectChanges ();

		public virtual void RejectChanges()
		{
			BeforeRejectChanges();

			RejectEditableLong1Changes();
			RejectEditableInt1Changes();
			RejectEditableInt3Changes();
			RejectEditableDouble1Changes();

			AfterRejectChanges();
		}

		public virtual bool IsDirty
		{
			get
			{
				return
					IsEditableLong1Dirty   ||
					IsEditableInt1Dirty    ||
					IsEditableInt3Dirty    ||
					IsEditableDouble1Dirty;
			}
		}

		#endregion

		#region IEditableObject support

		private bool _isEditing;
		public bool  IsEditing { get { return _isEditing; } }

		public virtual void BeginEdit () { AcceptChanges(); _isEditing = true; }
		public virtual void CancelEdit() { _isEditing = false; RejectChanges(); }
		public virtual void EndEdit   () { _isEditing = false; AcceptChanges(); }

		#endregion
	}
}
