示例#1
0
        public byte[] CalculateHashForEntity(IEntityWithRedundancyCheck entity)
        {
            var seed       = new StringBuilder();
            var entityType = entity.GetType();

            foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(entityType))
            {
                var fieldMarkedForRc = propertyDescriptor.Attributes
                                       .OfType <FieldMarkedForRedundancyAttribute>()
                                       .FirstOrDefault();

                if (fieldMarkedForRc != null)
                {
                    //TODO: Verificar el orden del armado de la semilla
                    var propertyValueSerialized = Convert.ToString(propertyDescriptor.GetValue(entity) ?? string.Empty);
                    seed.Append(propertyValueSerialized);
                }
            }

            return(_hash.CreateHash(seed.ToString()));
        }
示例#2
0
 private static Type GetEntityType(IEntityWithRedundancyCheck entityWithCRC)
 {
     return(System.Data.Entity.Core.Objects.ObjectContext.GetObjectType(entityWithCRC.GetType()));
 }