Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

FileSystemAccessRule2.cs 2.9 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Alphaleonis.Win32.Filesystem;
  2. using System.Security.AccessControl;
  3. namespace Security2
  4. {
  5. public partial class FileSystemAccessRule2
  6. {
  7. #region Properties
  8. private FileSystemAccessRule fileSystemAccessRule;
  9. private string fullName;
  10. private bool inheritanceEnabled;
  11. private string inheritedFrom;
  12. public string Name { get { return System.IO.Path.GetFileName(fullName); } }
  13. public string FullName { get { return fullName; } set { fullName = value; } }
  14. public bool InheritanceEnabled { get { return inheritanceEnabled; } set { inheritanceEnabled = value; } }
  15. public string InheritedFrom { get { return inheritedFrom; } set { inheritedFrom = value; } }
  16. public AccessControlType AccessControlType { get { return fileSystemAccessRule.AccessControlType; } }
  17. public FileSystemRights2 AccessRights { get { return (FileSystemRights2)fileSystemAccessRule.FileSystemRights; } }
  18. public IdentityReference2 Account { get { return fileSystemAccessRule.IdentityReference; } }
  19. public InheritanceFlags InheritanceFlags { get { return fileSystemAccessRule.InheritanceFlags; } }
  20. public bool IsInherited { get { return fileSystemAccessRule.IsInherited; } }
  21. public PropagationFlags PropagationFlags { get { return fileSystemAccessRule.PropagationFlags; } }
  22. #endregion
  23. public FileSystemAccessRule2(FileSystemAccessRule fileSystemAccessRule)
  24. {
  25. this.fileSystemAccessRule = fileSystemAccessRule;
  26. }
  27. public FileSystemAccessRule2(FileSystemAccessRule fileSystemAccessRule, FileSystemInfo item)
  28. {
  29. this.fileSystemAccessRule = fileSystemAccessRule;
  30. this.fullName = item.FullName;
  31. }
  32. public FileSystemAccessRule2(FileSystemAccessRule fileSystemAccessRule, string path)
  33. {
  34. this.fileSystemAccessRule = fileSystemAccessRule;
  35. }
  36. public static implicit operator FileSystemAccessRule(FileSystemAccessRule2 ace2)
  37. {
  38. return ace2.fileSystemAccessRule;
  39. }
  40. public static implicit operator FileSystemAccessRule2(FileSystemAccessRule ace)
  41. {
  42. return new FileSystemAccessRule2(ace);
  43. }
  44. //REQUIRED BECAUSE OF CONVERSION OPERATORS
  45. public override bool Equals(object obj)
  46. {
  47. return fileSystemAccessRule == (FileSystemAccessRule)obj;
  48. }
  49. public override int GetHashCode()
  50. {
  51. return fileSystemAccessRule.GetHashCode();
  52. }
  53. public override string ToString()
  54. {
  55. return string.Format("{0} '{1}' ({2})",
  56. AccessControlType.ToString()[0],
  57. Account.AccountName,
  58. AccessRights.ToString()
  59. );
  60. }
  61. public SimpleFileSystemAccessRule ToSimpleFileSystemAccessRule2()
  62. {
  63. return new SimpleFileSystemAccessRule(fullName, Account, AccessRights);
  64. }
  65. }
  66. }