RemoveAce() public method

public RemoveAce ( int index ) : void
index int
return void
Beispiel #1
0
        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++;
                }
            }
        }
Beispiel #2
0
        /// <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));
        }