﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Management.WebAuthenticationFailureAuditEvent
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System.Collections.Generic;
using System.Runtime;

namespace System.Web.Management
{
  /// <summary>
  /// Provides information about ASP.NET authentication failures.
  /// </summary>
  public class WebAuthenticationFailureAuditEvent : WebFailureAuditEvent
  {
    private string _nameToAuthenticate;

    /// <summary>
    /// Gets the name of the user to authenticate.
    /// </summary>
    /// 
    /// <returns>
    /// The name of the user to authenticate.
    /// </returns>
    public string NameToAuthenticate
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._nameToAuthenticate;
      }
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.Management.WebAuthenticationFailureAuditEvent"/> class with the specified event parameters.
    /// </summary>
    /// <param name="message">The event description. </param><param name="eventSource">The object that is the source of the event.</param><param name="eventCode">The <see cref="T:System.Web.Management.WebEventCodes"/> value associated with the event.</param><param name="nameToAuthenticate">The name of the user to authenticate.</param>
    protected internal WebAuthenticationFailureAuditEvent(string message, object eventSource, int eventCode, string nameToAuthenticate)
      : base(message, eventSource, eventCode)
    {
      this.Init(nameToAuthenticate);
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.Management.WebAuthenticationFailureAuditEvent"/> class with the specified event parameters.
    /// </summary>
    /// <param name="message">The event description. </param><param name="eventSource">The object that is the source of the event. </param><param name="eventCode">The code associated with the event. When you implement a custom event, the event code must be greater than <see cref="F:System.Web.Management.WebEventCodes.WebExtendedBase"/>.</param><param name="eventDetailCode">The <see cref="T:System.Web.Management.WebEventCodes"/> value that specifies the detailed identifier for the event.</param><param name="nameToAuthenticate">The name of the user to authenticate. </param>
    protected internal WebAuthenticationFailureAuditEvent(string message, object eventSource, int eventCode, int eventDetailCode, string nameToAuthenticate)
      : base(message, eventSource, eventCode, eventDetailCode)
    {
      this.Init(nameToAuthenticate);
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    internal WebAuthenticationFailureAuditEvent()
    {
    }

    internal override void GenerateFieldsForMarshal(List<WebEventFieldData> fields)
    {
      base.GenerateFieldsForMarshal(fields);
      fields.Add(new WebEventFieldData("NameToAuthenticate", this.NameToAuthenticate, WebEventFieldType.String));
    }

    internal override void FormatToString(WebEventFormatter formatter, bool includeAppInfo)
    {
      base.FormatToString(formatter, includeAppInfo);
      formatter.AppendLine(string.Empty);
      formatter.AppendLine(WebBaseEvent.FormatResourceStringWithCache("Webevent_event_name_to_authenticate", this._nameToAuthenticate));
    }

    private void Init(string name)
    {
      this._nameToAuthenticate = name;
    }
  }
}
