Пример #1
0
        /// <summary>
        /// Deletes some entries.
        /// </summary>
        /// <param name="entries">The entries to delete.</param>
        protected override void DeleteEntries(AclEntry[] entries)
        {
            lock (this)
            {
                AclEntry[] allEntries = LoadDataInternal( );

                StringBuilder sb = new StringBuilder(10000);
                foreach (AclEntry originalEntry in allEntries)
                {
                    // If the current entry is not contained in the entries array, then preserve it
                    bool delete = false;
                    foreach (AclEntry entryToDelete in entries)
                    {
                        if (AclEntry.Equals(originalEntry, entryToDelete))
                        {
                            delete = true;
                            break;
                        }
                    }

                    if (!delete)
                    {
                        sb.Append(DumpAclEntry(originalEntry));
                        sb.Append("\r\n");
                    }
                }

                File.WriteAllText(_file, sb.ToString( ));
            }
        }
Пример #2
0
        public void Equals()
        {
            AclEntry entry = new AclEntry("Res", "Action", "U.User", Value.Grant);

            Assert.IsFalse(entry.Equals(null), "Equals should return false (testing null)");
            Assert.IsFalse(entry.Equals("blah"), "Equals should return false (testing a string)");
            Assert.IsFalse(entry.Equals(new AclEntry("Res1", "Action", "U.User", Value.Grant)), "Equals should return false");
            Assert.IsFalse(entry.Equals(new AclEntry("Res", "Action1", "U.User", Value.Grant)), "Equals should return false");
            Assert.IsFalse(entry.Equals(new AclEntry("Res", "Action", "U.User1", Value.Grant)), "Equals should return false");
            Assert.IsTrue(entry.Equals(new AclEntry("Res", "Action", "U.User", Value.Deny)), "Equals should return true");
            Assert.IsTrue(entry.Equals(new AclEntry("Res", "Action", "U.User", Value.Grant)), "Equals should return true");
            Assert.IsTrue(entry.Equals(entry), "Equals should return true");
        }
Пример #3
0
        public void Equals()
        {
            AclEntry entry = new AclEntry("Res", "Action", "U.User", Value.Grant);

            Assert.IsFalse(entry.Equals(null), "Equals should return false (testing null)");
            Assert.IsFalse(entry.Equals("blah"), "Equals should return false (testing a string)");
            Assert.IsFalse(entry.Equals(new AclEntry("Res1", "Action", "U.User", Value.Grant)), "Equals should return false");
            Assert.IsFalse(entry.Equals(new AclEntry("Res", "Action1", "U.User", Value.Grant)), "Equals should return false");
            Assert.IsFalse(entry.Equals(new AclEntry("Res", "Action", "U.User1", Value.Grant)), "Equals should return false");
            Assert.IsTrue(entry.Equals(new AclEntry("Res", "Action", "U.User", Value.Deny)), "Equals should return true");
            Assert.IsTrue(entry.Equals(new AclEntry("Res", "Action", "U.User", Value.Grant)), "Equals should return true");
            Assert.IsTrue(entry.Equals(entry), "Equals should return true");
        }