void MergeExplicitAces() { int explicitCount = GetCanonicalExplicitAceCount(); for (int i = 0; i < explicitCount - 1;) { GenericAce mergedAce = MergeExplicitAcePair(raw_acl [i], raw_acl [i + 1]); if (null != mergedAce) { raw_acl [i] = mergedAce; raw_acl.RemoveAce(i + 1); explicitCount--; } else { i++; } } }
/// <summary>Canonicalizes the specified Access Control List.</summary> /// <param name="acl">The Access Control List.</param> public static void Canonicalize(this RawAcl acl) { if (acl == null) { throw new ArgumentNullException(nameof(acl)); } // Extract aces to list var aces = new Collections.Generic.List <GenericAce>(acl.Cast <GenericAce>()); // Sort aces based on canonical order aces.Sort((a, b) => Collections.Generic.Comparer <byte> .Default.Compare(GetComparisonValue(a), GetComparisonValue(b))); // Add sorted aces back to ACL while (acl.Count > 0) { acl.RemoveAce(0); } var aceIndex = 0; aces.ForEach(ace => acl.InsertAce(aceIndex++, ace)); }