Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:KotoriCore.Domains.OperationResult"/> class.
        /// </summary>
        /// <param name="documentType">Document type.</param>
        /// <param name="newResource">If set to <c>true</c> it is a new resource.</param>
        public OperationResult(Database.DocumentDb.Entities.DocumentType documentType, bool newResource)
        {
            var documentTypeUri = new Uri(documentType.Identifier);
            var documentTypeId  = documentTypeUri.ToKotoriDocumentTypeIdentifier();

            Id          = documentTypeId.DocumentTypeId;
            Url         = documentTypeUri.ToAbsoluteUri();
            NewResource = newResource;
        }
Exemple #2
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));
        }