public Acl Canonicalize()
        {
            Acl acl = Clone();

            acl.Canonicalize(true);
            return(acl);
        }
        /// <summary>
        /// Gets an indication if this ACL is canonical.
        /// </summary>
        /// <remarks>Canonical means that deny ACEs are before allow ACEs.</remarks>
        /// <param name="dacl">True to canonicalize a DACL, otherwise a SACL.</param>
        /// <returns>True if the ACL is canonical.</returns>
        public bool IsCanonical(bool dacl)
        {
            Acl acl = Clone();

            acl.Canonicalize(dacl);
            if (acl.Count != Count)
            {
                return(false);
            }

            for (int i = 0; i < acl.Count; ++i)
            {
                if (!ReferenceEquals(this[i], acl[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
        /// <summary>
        /// Gets an indication if this ACL is canonical.
        /// </summary>
        /// <remarks>Canonical means that deny ACEs are before allow ACEs.</remarks>
        /// <param name="dacl">True to canonicalize a DACL, otherwise a SACL.</param>
        /// <returns>True if the ACL is canonical.</returns>
        public bool IsCanonical(bool dacl)
        {
            Acl acl       = Clone();
            var ace_order = acl.ToArray();

            acl.Canonicalize(dacl);
            if (acl.Count != ace_order.Length)
            {
                return(false);
            }

            for (int i = 0; i < acl.Count; ++i)
            {
                if (!ReferenceEquals(ace_order[i], acl[i]))
                {
                    return(false);
                }
            }
            return(true);
        }