/DMS/Implementacion/PaucarpataSolution/PPR.Data/t_cap_clasifica.cs

http://ppp-eym.googlecode.com/ · C# · 238 lines · 208 code · 22 blank · 8 comment · 42 complexity · 8bb655c898a1b9dfcf306221a165b4e6 MD5 · raw file

  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated from a template.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Collections.ObjectModel;
  12. using System.Collections.Specialized;
  13. using System.ComponentModel;
  14. using System.Globalization;
  15. using System.Runtime.Serialization;
  16. namespace PPR.Data
  17. {
  18. [DataContract(IsReference = true)]
  19. [KnownType(typeof(t_cap_cargos))]
  20. public partial class t_cap_clasifica: IObjectWithChangeTracker, INotifyPropertyChanged
  21. {
  22. #region Primitive Properties
  23. [DataMember]
  24. public int id_clas
  25. {
  26. get { return _id_clas; }
  27. set
  28. {
  29. if (_id_clas != value)
  30. {
  31. if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
  32. {
  33. throw new InvalidOperationException("The property 'id_clas' is part of the object's key and cannot be changed. Changes to key properties can only be made when the object is not being tracked or is in the Added state.");
  34. }
  35. _id_clas = value;
  36. OnPropertyChanged("id_clas");
  37. }
  38. }
  39. }
  40. private int _id_clas;
  41. [DataMember]
  42. public string codigo
  43. {
  44. get { return _codigo; }
  45. set
  46. {
  47. if (_codigo != value)
  48. {
  49. _codigo = value;
  50. OnPropertyChanged("codigo");
  51. }
  52. }
  53. }
  54. private string _codigo;
  55. [DataMember]
  56. public string descripcion
  57. {
  58. get { return _descripcion; }
  59. set
  60. {
  61. if (_descripcion != value)
  62. {
  63. _descripcion = value;
  64. OnPropertyChanged("descripcion");
  65. }
  66. }
  67. }
  68. private string _descripcion;
  69. #endregion
  70. #region Navigation Properties
  71. [DataMember]
  72. public TrackableCollection<t_cap_cargos> t_cap_cargos
  73. {
  74. get
  75. {
  76. if (_t_cap_cargos == null)
  77. {
  78. _t_cap_cargos = new TrackableCollection<t_cap_cargos>();
  79. _t_cap_cargos.CollectionChanged += Fixupt_cap_cargos;
  80. }
  81. return _t_cap_cargos;
  82. }
  83. set
  84. {
  85. if (!ReferenceEquals(_t_cap_cargos, value))
  86. {
  87. if (ChangeTracker.ChangeTrackingEnabled)
  88. {
  89. throw new InvalidOperationException("Cannot set the FixupChangeTrackingCollection when ChangeTracking is enabled");
  90. }
  91. if (_t_cap_cargos != null)
  92. {
  93. _t_cap_cargos.CollectionChanged -= Fixupt_cap_cargos;
  94. }
  95. _t_cap_cargos = value;
  96. if (_t_cap_cargos != null)
  97. {
  98. _t_cap_cargos.CollectionChanged += Fixupt_cap_cargos;
  99. }
  100. OnNavigationPropertyChanged("t_cap_cargos");
  101. }
  102. }
  103. }
  104. private TrackableCollection<t_cap_cargos> _t_cap_cargos;
  105. #endregion
  106. #region ChangeTracking
  107. protected virtual void OnPropertyChanged(String propertyName)
  108. {
  109. if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
  110. {
  111. ChangeTracker.State = ObjectState.Modified;
  112. }
  113. if (_propertyChanged != null)
  114. {
  115. _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
  116. }
  117. }
  118. protected virtual void OnNavigationPropertyChanged(String propertyName)
  119. {
  120. if (_propertyChanged != null)
  121. {
  122. _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
  123. }
  124. }
  125. event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
  126. private event PropertyChangedEventHandler _propertyChanged;
  127. private ObjectChangeTracker _changeTracker;
  128. [DataMember]
  129. public ObjectChangeTracker ChangeTracker
  130. {
  131. get
  132. {
  133. if (_changeTracker == null)
  134. {
  135. _changeTracker = new ObjectChangeTracker();
  136. _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
  137. }
  138. return _changeTracker;
  139. }
  140. set
  141. {
  142. if(_changeTracker != null)
  143. {
  144. _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
  145. }
  146. _changeTracker = value;
  147. if(_changeTracker != null)
  148. {
  149. _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
  150. }
  151. }
  152. }
  153. private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
  154. {
  155. if (e.NewState == ObjectState.Deleted)
  156. {
  157. ClearNavigationProperties();
  158. }
  159. }
  160. protected bool IsDeserializing { get; private set; }
  161. [OnDeserializing]
  162. public void OnDeserializingMethod(StreamingContext context)
  163. {
  164. IsDeserializing = true;
  165. }
  166. [OnDeserialized]
  167. public void OnDeserializedMethod(StreamingContext context)
  168. {
  169. IsDeserializing = false;
  170. ChangeTracker.ChangeTrackingEnabled = true;
  171. }
  172. protected virtual void ClearNavigationProperties()
  173. {
  174. t_cap_cargos.Clear();
  175. }
  176. #endregion
  177. #region Association Fixup
  178. private void Fixupt_cap_cargos(object sender, NotifyCollectionChangedEventArgs e)
  179. {
  180. if (IsDeserializing)
  181. {
  182. return;
  183. }
  184. if (e.NewItems != null)
  185. {
  186. foreach (t_cap_cargos item in e.NewItems)
  187. {
  188. item.t_cap_clasifica = this;
  189. if (ChangeTracker.ChangeTrackingEnabled)
  190. {
  191. if (!item.ChangeTracker.ChangeTrackingEnabled)
  192. {
  193. item.StartTracking();
  194. }
  195. ChangeTracker.RecordAdditionToCollectionProperties("t_cap_cargos", item);
  196. }
  197. }
  198. }
  199. if (e.OldItems != null)
  200. {
  201. foreach (t_cap_cargos item in e.OldItems)
  202. {
  203. if (ReferenceEquals(item.t_cap_clasifica, this))
  204. {
  205. item.t_cap_clasifica = null;
  206. }
  207. if (ChangeTracker.ChangeTrackingEnabled)
  208. {
  209. ChangeTracker.RecordRemovalFromCollectionProperties("t_cap_cargos", item);
  210. }
  211. }
  212. }
  213. }
  214. #endregion
  215. }
  216. }