Ejemplo n.º 1
0
        public static string ToEtag <T>(this IResultList <T> items, IEntityWithVersion app = null) where T : IEntity, IEntityWithVersion
        {
            using (Profiler.Trace("CalculateEtag"))
            {
                var unhashed = Unhashed(items, items.Total, app);

                return(unhashed.Sha256Base64());
            }
        }
Ejemplo n.º 2
0
        public static string ToEtag <T>(this T item, IEntityWithVersion app = null) where T : IEntity, IEntityWithVersion
        {
            var result = $"{item.Id};{item.Version}";

            if (app != null)
            {
                result += ";";
                result += app.Version;
            }

            return(result);
        }
Ejemplo n.º 3
0
        private static string Unhashed <T>(IReadOnlyList <T> items, long total, IEntityWithVersion app) where T : IEntity, IEntityWithVersion
        {
            var sb = new StringBuilder((items.Count * (GuidLength + 8)) + 10);

            for (var i = 0; i < items.Count; i++)
            {
                sb.Append(";");
                sb.Append(items[i].ToEtag());
            }

            sb.Append("_");
            sb.Append(total);

            if (app != null)
            {
                sb.Append("_");
                sb.Append(app.Version);
            }

            return(sb.ToString());
        }
Ejemplo n.º 4
0
 private static bool IsFound(IEntityWithVersion entity)
 {
     return(entity.Version > EtagVersion.Empty);
 }