mirror of https://github.com/raandree/NTFSSecurity
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.9 KiB
49 lines
1.9 KiB
// <copyright file="PrivilegeAndAttributesCollection.cs" company="Nick Lowe">
|
|
// Copyright © Nick Lowe 2009
|
|
// </copyright>
|
|
// <author>Nick Lowe</author>
|
|
// <email>nick@int-r.net</email>
|
|
// <url>http://processprivileges.codeplex.com/</url>
|
|
|
|
namespace ProcessPrivileges
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
/// <summary>Read-only collection of privilege and attributes.</summary>
|
|
[Serializable]
|
|
public sealed class PrivilegeAndAttributesCollection : ReadOnlyCollection<PrivilegeAndAttributes>
|
|
{
|
|
internal PrivilegeAndAttributesCollection(IList<PrivilegeAndAttributes> list)
|
|
: base(list)
|
|
{
|
|
}
|
|
|
|
/// <summary>Returns a <see cref="string"/> representation of the collection.</summary>
|
|
/// <returns><see cref="string"/> representation of the collection.</returns>
|
|
public override string ToString()
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
int maxPrivilegeLength = this.Max(privilegeAndAttributes => privilegeAndAttributes.Privilege.ToString().Length);
|
|
foreach (PrivilegeAndAttributes privilegeAndAttributes in this)
|
|
{
|
|
stringBuilder.Append(privilegeAndAttributes.Privilege);
|
|
int paddingLength = maxPrivilegeLength - privilegeAndAttributes.Privilege.ToString().Length;
|
|
char[] padding = new char[paddingLength];
|
|
for (int i = 0; i < paddingLength; i++)
|
|
{
|
|
padding[i] = ' ';
|
|
}
|
|
|
|
stringBuilder.Append(padding);
|
|
stringBuilder.Append(" => ");
|
|
stringBuilder.AppendLine(privilegeAndAttributes.PrivilegeAttributes.ToString());
|
|
}
|
|
|
|
return stringBuilder.ToString();
|
|
}
|
|
}
|
|
}
|