﻿// Decompiled with JetBrains decompiler
// Type: System.Security.AccessControl.AccessRule`1
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 255ABCDF-D9D6-4E3D-BAD4-F74D4CE3D7A8
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

using System;
using System.Runtime;
using System.Security.Principal;

namespace System.Security.AccessControl
{
  /// <typeparam name="T"/>
  public class AccessRule<T> : AccessRule where T : struct
  {
    /// <summary>
    /// Represents a combination of a user’s identity, an access mask, and an access control type.
    /// </summary>
    /// 
    /// <returns>
    /// Returns <see cref="{0}"/>.
    /// </returns>
    public T Rights
    {
      get
      {
        return (T) (ValueType) this.AccessMask;
      }
    }

    /// <summary>
    /// Initializes a new instance of the AccessRule’1 class by using the specified values.
    /// </summary>
    /// <param name="identity">The identity to which the access rule applies.</param><param name="rights">The rights of the access rule.</param><param name="type">The valid access control type.</param>
    public AccessRule(IdentityReference identity, T rights, AccessControlType type)
      : this(identity, (int) (ValueType) rights, false, InheritanceFlags.None, PropagationFlags.None, type)
    {
    }

    /// <param name="identity">The identity to which the access rule applies.</param><param name="rights">The rights of the access rule.</param><param name="type">The valid access control type.</param>
    public AccessRule(string identity, T rights, AccessControlType type)
      : this((IdentityReference) new NTAccount(identity), (int) (ValueType) rights, false, InheritanceFlags.None, PropagationFlags.None, type)
    {
    }

    /// <param name="identity">The identity to which the access rule applies.</param><param name="rights">The rights of the access rule.</param><param name="inheritanceFlags">The inheritance properties of the access rule.</param><param name="propagationFlags">Whether inherited access rules are automatically propagated. The propagation flags are ignored if <paramref name="inheritanceFlags"/> is set to <see cref="F:System.Security.AccessControl.InheritanceFlags.None"/>.</param><param name="type">The valid access control type.</param>
    public AccessRule(IdentityReference identity, T rights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
      : this(identity, (int) (ValueType) rights, false, inheritanceFlags, propagationFlags, type)
    {
    }

    /// <param name="identity">The identity to which the access rule applies.</param><param name="rights">The rights of the access rule.</param><param name="inheritanceFlags">The inheritance properties of the access rule.</param><param name="propagationFlags">Whether inherited access rules are automatically propagated. </param><param name="type">The valid access control type.</param>
    public AccessRule(string identity, T rights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
      : this((IdentityReference) new NTAccount(identity), (int) (ValueType) rights, false, inheritanceFlags, propagationFlags, type)
    {
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    internal AccessRule(IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
      : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags, type)
    {
    }
  }
}
