public static List <AuditEntityConfiguration> GetAllEntityConfigurations()
        {
#if NETFRAMEWORK
            using (new Profiling.Profiler(nameof(AuditEntityConfiguration), Profiling.AppDevSymbolType.ClassOperation, nameof(AuditEntityConfiguration.GetAllEntityConfigurations)))
            {
#endif
            var entities = new List <AuditEntityConfiguration>();

            foreach (var currentClassType in _auditableTypes)
            {
                if (SkipEntity(Common.GetTypeName(currentClassType, false)))
                {
                    continue;
                }

                var newEntity = new AuditEntityConfiguration();
                newEntity = new AuditEntityConfiguration
                {
                    FullName   = Common.GetTypeName(currentClassType, true),
                    ShortName  = Common.GetTypeName(currentClassType, false),
                    Properties = AuditPropertyConfiguration.GetAuditEntityProperties(currentClassType).ToList()
                };
                entities?.Add(newEntity);
            }
            return(entities);

#if NETFRAMEWORK
        }
#endif
        }
 public virtual void RemoveProperties(AuditPropertyConfiguration __item)
 {
     if (__item != null)
     {
         __item.Entity = null;
     }
 }
 public virtual void InternalRemoveProperties(AuditPropertyConfiguration __item)
 {
     if (__item == null)
     {
         return;
     }
     properties?.Remove(__item);
 }
 public virtual void InternalAddProperties(AuditPropertyConfiguration __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     properties?.Add(__item);
 }
 public virtual void AddProperties(AuditPropertyConfiguration __item)
 {
     if (__item == null)
     {
         return;
     }
     if (__item.Entity != this)
     {
         __item.Entity = this;
     }
 }
        public static List <AuditPropertyConfiguration> GetAuditEntityProperties(Type runtimeEntityProperty)
        {
#if NETFRAMEWORK
            using (new Profiling.Profiler(nameof(AuditPropertyConfiguration), Profiling.AppDevSymbolType.ClassOperation, "GetAuditEntityProperties"))
            {
#endif
            var repo = ServiceLocator.Current.GetInstance <IRepositoryBuilder>().CreateRetrieveRepository();

            List <AuditPropertyConfiguration> properties     = new List <AuditPropertyConfiguration>();
            AuditPropertyConfiguration newproperty           = new AuditPropertyConfiguration();
            List <AuditEntityConfiguration> existingEntities = repo.GetAll <AuditEntityConfiguration>();
            AuditEntityConfiguration existingEntity          = new AuditEntityConfiguration();
            foreach (var currentProperty in MambaRuntimeType.FromPropertiesList(runtimeEntityProperty.GetProperties()) ?? Enumerable.Empty <MambaRuntimeType>())
            {
                if ((SkipProperty(currentProperty.Name)))
                {
                    continue;
                }
                newproperty           = new AuditPropertyConfiguration();
                existingEntity        = existingEntities?.FirstOrDefault((a) => a.FullName == Common.GetTypeName(runtimeEntityProperty, true));
                newproperty.Name      = currentProperty.Name;
                newproperty.IsComplex = ((Common.IsPropertyPrimitiveOrSimple(currentProperty)) == false);
                if ((currentProperty.PropertyType.GenericTypeArguments.Length > 0) && (currentProperty.PropertyType.GenericTypeArguments.ToList().FirstOrDefault() != null))
                {
                    newproperty.DataType = Common.GetTypeName(currentProperty.PropertyType.GenericTypeArguments.ToList().FirstOrDefault(), true);
                }
                else
                {
                    newproperty.DataType = Common.GetTypeName(currentProperty.PropertyType, true);
                }
                if (newproperty?.DataType == "System.String")
                {
                    newproperty.IsCollection = false;
                }
                else
                {
                    newproperty.IsCollection = Common.IsPropertyCollection(currentProperty);
                }
                if (existingEntity != null && existingEntity?.Properties?.FirstOrDefault((x) => x.Name == currentProperty.Name) != null)
                {
                    newproperty.IsAuditable = (existingEntity?.Properties?.FirstOrDefault((x) => x.Name == currentProperty.Name)?.IsAuditable ?? false);
                }
                else
                {
                    newproperty.IsAuditable = false;
                }
                properties?.Add(newproperty);
            }
            return(properties);

#if NETFRAMEWORK
        }
#endif
        }
        public virtual void UpdateAuditPropertyConfiguration(AuditPropertyConfiguration tmp)
        {
#if NETFRAMEWORK
            using (new Profiling.Profiler(nameof(AuditEntityConfiguration), Profiling.AppDevSymbolType.ClassOperation, nameof(AuditEntityConfiguration.SkipEntity)))
            {
#endif
            IsAuditable  = tmp?.IsAuditable ?? false;
            IsCollection = tmp?.IsCollection ?? false;
            IsComplex    = tmp?.IsComplex ?? false;
            DataType     = tmp?.DataType ?? "";
#if NETFRAMEWORK
        }
#endif
        }
 public virtual void SetPropertiesAt(AuditPropertyConfiguration __item, int __index)
 {
     if (__item == null)
     {
         properties[__index].Entity = null;
     }
     else
     {
         properties[__index] = __item;
         if (__item.Entity != this)
         {
             __item.Entity = this;
         }
     }
 }
 public virtual void AddAtIndexProperties(int index, AuditPropertyConfiguration __item)
 {
     if (__item == null)
     {
         return;
     }
     properties?.Insert(index, __item);
     disableInternalAdditions = true;
     try
     {
         if (__item.Entity != this)
         {
             __item.Entity = this;
         }
     }
     finally
     {
         disableInternalAdditions = false;
     }
 }
        public virtual void UpdateAuditEntityConfiguration(AuditEntityConfiguration newEntityConfiguration, IAuditingRepository repo = null)
        {
            repo = repo ?? ServiceLocator.Current.GetInstance <IRepositoryBuilder>().CreateAuditingRepository();

#if NETFRAMEWORK
            using (new Profiling.Profiler(nameof(AuditEntityConfiguration), Profiling.AppDevSymbolType.ClassOperation, nameof(AuditEntityConfiguration.UpdateAuditEntityConfiguration)))
            {
#endif
            var newPropertyConfiguration = new AuditPropertyConfiguration();
            var newProperties            = newEntityConfiguration.Properties;

            Properties?.ForEach(oldPropertyConfiguration =>
            {
                newPropertyConfiguration = newProperties?
                                           .FirstOrDefault(a => a.Name == oldPropertyConfiguration?.Name);
                if (newPropertyConfiguration == null)
                {
                    repo.DeleteAuditPropertyConfiguration(oldPropertyConfiguration);
                }
                else
                {
                    oldPropertyConfiguration?.UpdateAuditPropertyConfiguration(newPropertyConfiguration);
                    newProperties?.RemoveAll(c => c.Name == newPropertyConfiguration.Name);
                }
            });

            if (newProperties.Any())
            {
                this?.AddProperties(newProperties);
            }

            repo.Save(this);
#if NETFRAMEWORK
        }
#endif
        }
 /// <summary>
 ///     Returns true if self and the provided entity have the same Id values
 ///     and the Ids are not of the default Id value
 /// </summary>
 protected bool HasSameNonDefaultIdAs(AuditPropertyConfiguration compareTo)
 {
     return(!IsTransient() && !compareTo.IsTransient() && Id.Equals(compareTo.Id));
 }
 /// <summary>
 /// Copies the current object to a new instance
 /// </summary>
 /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
 /// <param name="copiedObjects">Objects that should be reused</param>
 /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
 /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
 /// <param name="copy">Optional - An existing [AuditPropertyConfiguration] instance to use as the destination.</param>
 /// <returns>A copy of the object</returns>
 public virtual AuditPropertyConfiguration Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, AuditPropertyConfiguration copy = null)
 {
     if (copiedObjects == null)
     {
         copiedObjects = new Hashtable();
     }
     if (copy == null && copiedObjects.Contains(this))
     {
         return((AuditPropertyConfiguration)copiedObjects[this]);
     }
     copy = copy ?? new AuditPropertyConfiguration();
     if (!asNew)
     {
         copy.TransientId = TransientId;
         copy.Id          = Id;
     }
     copy.Name         = Name;
     copy.DataType     = DataType;
     copy.IsAuditable  = IsAuditable;
     copy.IsComplex    = IsComplex;
     copy.IsCollection = IsCollection;
     if (!copiedObjects.Contains(this))
     {
         copiedObjects.Add(this, copy);
     }
     if (deep && entity != null)
     {
         if (!copiedObjects.Contains(entity))
         {
             if (asNew && reuseNestedObjects)
             {
                 copy.Entity = Entity;
             }
             else if (asNew)
             {
                 copy.Entity = Entity.Copy(deep, copiedObjects, true);
             }
             else
             {
                 copy.entity = entity.Copy(deep, copiedObjects, false);
             }
         }
         else
         {
             if (asNew)
             {
                 copy.Entity = (AuditEntityConfiguration)copiedObjects[Entity];
             }
             else
             {
                 copy.entity = (AuditEntityConfiguration)copiedObjects[Entity];
             }
         }
     }
     return(copy);
 }