Esempio n. 1
0
        /// <summary>
        /// Gets the hash.
        /// </summary>
        /// <returns>The hash.</returns>
        /// <param name="result">Result.</param>
        internal static string ToHash(this IDocumentResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var c = (result.Content?.ToString(Cultures.Invariant) ?? string.Empty) +
                    (result.Date == null ? "(none)" : result.Date.Value.ToEpoch().ToString(Cultures.Invariant)) +
                    (result.Slug ?? "(none)") +
                    (result.Draft) +
                    (result.DocumentIdentifier.ProjectId ?? "(none)") +
                    (result.DocumentIdentifier.DocumentType.ToString() ?? "(none)") +
                    (result.DocumentIdentifier.DocumentTypeId ?? "(none)") +
                    (result.DocumentIdentifier.DocumentId ?? "(none)") +
                    ((result.DocumentIdentifier.Index ?? 0).ToString(Cultures.Invariant));

            if (result.OriginalMeta != null)
            {
                c += JsonConvert.SerializeObject(result.OriginalMeta);
            }

            if (result.Meta != null)
            {
                c += JsonConvert.SerializeObject(result.Meta);
            }

            return(HashTools.GetHash(c, HashTools.HashType.SHA1));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the hash.
        /// </summary>
        /// <param name="transformations">Transformations.</param>
        /// <returns>The hash.</returns>
        public static string ToHash(this IEnumerable <DocumentTypeTransformation> transformations)
        {
            if (transformations == null)
            {
                throw new ArgumentNullException(nameof(transformations));
            }

            var c = transformations?.Select(t => t.From + "-" + t.To + "-" + t.Transformations.Select(t2 => t2.ToString())?.ToImplodedString())?.ToImplodedString();

            return(HashTools.GetHash(c, HashTools.HashType.SHA1));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the hash.
        /// </summary>
        /// <param name="documentType">Document type.</param>
        /// <returns>The hash.</returns>
        public static string ToHash(this Database.DocumentDb.Entities.DocumentType documentType)
        {
            if (documentType == null)
            {
                throw new ArgumentNullException(nameof(documentType));
            }

            var c = documentType.Type +
                    documentType.Indexes?.Select(i => i.From + "-" + (i.To == null ? "null" : ((int)i.To).ToString(Cultures.Invariant)) + "-" + i.IsRequired + "-" + i.Type).ToImplodedString() +
                    documentType.Transformations?.Select(t => t.From + "-" + t.To + "-" + t.Transformations.Select(t2 => t2.ToString())?.ToImplodedString())?.ToImplodedString();

            return(HashTools.GetHash(c, HashTools.HashType.SHA1));
        }