I have read this
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/base.
but I still don't understand what this line means.
public CustomAuthorizeAttribute(string role) : base(typeof(CustomAuthorize))
CustomAuthorize is a class that extends IAuthorizationFilter
.
what does base(typeof(CustomAuthorize))
mean?
Is it trying to call the constructor of the IAuthorizationFilter
? why is it using typeof
?
The full class is:
public class CustomAuthorizeAttribute : TypeFilterAttribute
{
public CustomAuthorizeAttribute(string role) : base(typeof(CustomAuthorize))
{
Arguments = new object[] { role };
}
}
public class CustomAuthorize : IAuthorizationFilter
{
private readonly string role;
public CustomAuthorize(string role)
{
this.role = role;
}
public void OnAuthorization(AuthorizationFilterContext context)
{
Some code
The question differs from other similar questions as i want to know specifically what "base(typeof(CustomAuthorize))" means.