diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.BL/ObservableEntity.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.BL/ObservableEntity.cs | 100 |
1 files changed, 5 insertions, 95 deletions
diff --git a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs index 656b138b4..982b853f9 100644 --- a/Software/Visual_Studio/Tango.BL/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.BL/ObservableEntity.cs @@ -27,10 +27,6 @@ using Tango.Core.Json; using Newtonsoft.Json.Converters; using Tango.BL.Serialization; using Newtonsoft.Json.Linq; -using Tango.BL.ActionLogs; -using Tango.BL.ValueObjects; -using LiteDB; -using System.Linq.Expressions; namespace Tango.BL { @@ -54,7 +50,7 @@ namespace Tango.BL /// <seealso cref="Tango.Core.ExtendedObject" /> /// <seealso cref="Tango.BL.Entities.IObservableEntity" /> [Serializable] - public abstract class ObservableEntity<T> : ExtendedObject, IObservableEntity, IActionLogComparable where T : class, IObservableEntity + public abstract class ObservableEntity<T> : ExtendedObject, IObservableEntity where T : class, IObservableEntity { #region Events @@ -73,7 +69,6 @@ namespace Tango.BL /// </summary> [Column("ID")] [JsonIgnore] - [BsonIgnore] [ParameterIgnore] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public Int32 ID @@ -113,7 +108,6 @@ namespace Tango.BL /// </summary> [NotMapped] [XmlIgnore] - [BsonIgnore] [JsonIgnore] [ParameterIgnore] public ReadOnlyObservableCollection<ParameterItem> Parameters @@ -135,7 +129,6 @@ namespace Tango.BL /// </summary> [ParameterIgnore] [JsonIgnore] - [BsonIgnore] [NotMapped] public Type ObjectType { @@ -162,15 +155,6 @@ namespace Tango.BL #region Public Methods /// <summary> - /// Marks this entity as modified so all properties are saved. - /// </summary> - /// <param name="context">The context.</param> - public virtual void MarkModified(ObservablesContext context) - { - context.Entry(this).State = EntityState.Modified; - } - - /// <summary> /// Saves the changes on this entity to database. /// </summary> public virtual void Save(ObservablesContext context) @@ -288,7 +272,7 @@ namespace Tango.BL foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) { - if (!prop.PropertyType.IsGenericTypeAndNotNullable()) + if (!prop.PropertyType.IsGenericType) { prop.SetValue(cloned, prop.GetValue(this)); } @@ -352,7 +336,7 @@ namespace Tango.BL /// <param name="context">The context.</param> public virtual void Delete(ObservablesContext context) { - + } #endregion @@ -383,7 +367,7 @@ namespace Tango.BL if (flags.HasFlag(EntitySerializationFlags.IgnoreReferenceTypes)) { - var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => !x.PropertyType.IsPrimitive && !x.PropertyType.IsGenericType && !x.PropertyType.IsNullable() && x.PropertyType != typeof(byte[]) && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime)).ToList(); + var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => !x.PropertyType.IsPrimitive && !x.PropertyType.IsGenericType && x.PropertyType != typeof(byte[]) && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime)).ToList(); foreach (var prop in props) { @@ -393,7 +377,7 @@ namespace Tango.BL if (flags.HasFlag(EntitySerializationFlags.IgnoreCollections)) { - var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericTypeAndNotNullable()).ToList(); + var props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsGenericType).ToList(); foreach (var prop in props) { @@ -521,7 +505,6 @@ namespace Tango.BL [NotMapped] [ParameterIgnore] [XmlIgnore] - [BsonIgnore] [JsonIgnore] public ObservableCollection<String> ValidationErrors { @@ -533,7 +516,6 @@ namespace Tango.BL [NotMapped] [ParameterIgnore] [JsonIgnore] - [BsonIgnore] [XmlIgnore] public bool ValidateOnPropertyChanged { @@ -548,7 +530,6 @@ namespace Tango.BL [NotMapped] [ParameterIgnore] [JsonIgnore] - [BsonIgnore] [XmlIgnore] public bool HasErrors { @@ -639,18 +620,6 @@ namespace Tango.BL #endregion - #region Virtual Methods - - /// <summary> - /// Called when before entity is saved by the context. - /// </summary> - public virtual void OnBeforeSave() - { - - } - - #endregion - #region INotify Property Changed /// <summary> @@ -667,65 +636,6 @@ namespace Tango.BL } } - public void RaisePropertyChanged<F>(Expression<Func<T, F>> expression) - { - MemberExpression member = expression.Body as MemberExpression; - if (member == null) - throw new ArgumentException(string.Format( - "Expression '{0}' refers to a method, not a property.", - expression.ToString())); - - PropertyInfo propInfo = member.Member as PropertyInfo; - if (propInfo == null) - throw new ArgumentException(string.Format( - "Expression '{0}' refers to a field, not a property.", - expression.ToString())); - - RaisePropertyChanged(propInfo.Name); - } - - #endregion - - #region Action Log - - /// <summary> - /// Returns true if the specified property should be ignored during ActionLog comparison. - /// </summary> - /// <param name="propName">Name of the property.</param> - /// <returns></returns> - bool IActionLogComparable.ShouldActionLogIgnore(string propName) - { - return propName == nameof(LastUpdated) || OnShouldActionLogIgnore(propName); - } - - /// <summary> - /// override to specified properties to be ignored when doing ActionLog comparison. - /// </summary> - /// <param name="propName">Name of the property.</param> - /// <returns></returns> - protected virtual bool OnShouldActionLogIgnore(string propName) - { - return false; - } - - /// <summary> - /// Returns an optional custom name for this instance in the comparison tree. - /// </summary> - /// <returns></returns> - string IActionLogComparable.GetActionLogName() - { - return OnGetActionLogName(); - } - - /// <summary> - /// override to specified a custom name for this instance in the ActionLog comparison tree. - /// </summary> - /// <returns></returns> - protected virtual String OnGetActionLogName() - { - return this.GetType().Name; - } - #endregion } } |
