﻿// Decompiled with JetBrains decompiler
// Type: System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute
// 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;
using System.Runtime;

namespace System.Web.UI.WebControls.WebParts
{
  /// <summary>
  /// Identifies the callback method in a server control acting as the consumer in a Web Parts connection, and enables developers to specify details about the consumer's connection point.
  /// </summary>
  [AttributeUsage(AttributeTargets.Method)]
  public class ConnectionConsumerAttribute : Attribute
  {
    private string _displayName;
    private string _id;
    private Type _connectionPointType;
    private bool _allowsMultipleConnections;

    /// <summary>
    /// Gets or sets a value that indicates whether the connection point allows multiple connections.
    /// </summary>
    /// 
    /// <returns>
    /// true if the connection point accepts multiple connections; otherwise, false.
    /// </returns>
    public bool AllowsMultipleConnections
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._allowsMultipleConnections;
      }
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set
      {
        this._allowsMultipleConnections = value;
      }
    }

    /// <summary>
    /// Gets a string that represents the unique identity of the consumer connection point.
    /// </summary>
    /// 
    /// <returns>
    /// The unique ID assigned to the consumer connection point. The default value is <see cref="F:System.String.Empty"/>.
    /// </returns>
    public string ID
    {
      get
      {
        if (this._id == null)
          return string.Empty;
        return this._id;
      }
    }

    /// <summary>
    /// Gets the friendly name of the consumer connection point.
    /// </summary>
    /// 
    /// <returns>
    /// A string containing a friendly display name for the consumer connection point.
    /// </returns>
    public virtual string DisplayName
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.DisplayNameValue;
      }
    }

    /// <summary>
    /// Gets or sets the string used as the value of the <see cref="P:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute.DisplayName"/> property, for use in localization scenarios.
    /// </summary>
    /// 
    /// <returns>
    /// A string that is used as the value of <see cref="P:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute.DisplayName"/>.
    /// </returns>
    protected string DisplayNameValue
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._displayName;
      }
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set
      {
        this._displayName = value;
      }
    }

    /// <summary>
    /// Gets the connection point type of the consumer connection point.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Type"/> that indicates the type of the connection point.
    /// </returns>
    /// <exception cref="T:System.InvalidOperationException">An invalid connection point type (one that does not derive from the <see cref="T:System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint"/> class) was used.</exception>
    public Type ConnectionPointType
    {
      get
      {
        if (WebPartUtil.IsConnectionPointTypeValid(this._connectionPointType, true))
          return this._connectionPointType;
        throw new InvalidOperationException(System.Web.SR.GetString("ConnectionConsumerAttribute_InvalidConnectionPointType", new object[1]
        {
          (object) this._connectionPointType.Name
        }));
      }
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute"/> class, specifying a display name for the consumer connection point.
    /// </summary>
    /// <param name="displayName">A string that contains a friendly name for the consumer connection point to display in the user interface (UI).</param><exception cref="T:System.ArgumentNullException"><paramref name="displayName"/> is null. </exception>
    public ConnectionConsumerAttribute(string displayName)
    {
      if (string.IsNullOrEmpty(displayName))
        throw new ArgumentNullException("displayName");
      this._displayName = displayName;
      this._allowsMultipleConnections = false;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute"/> class, specifying a display name and an ID for the consumer connection point.
    /// </summary>
    /// <param name="displayName">A string that contains a friendly name for the consumer connection point to display in the user interface (UI).</param><param name="id">The <see cref="P:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute.ID"/>, a unique string value assigned to the consumer connection point.</param><exception cref="T:System.ArgumentNullException"><paramref name="displayName"/> or <paramref name="id"/> is null. </exception>
    public ConnectionConsumerAttribute(string displayName, string id)
      : this(displayName)
    {
      if (string.IsNullOrEmpty(id))
        throw new ArgumentNullException("id");
      this._id = id;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute"/> class, specifying a display name and a specific type of connection point object to use for the consumer connection point.
    /// </summary>
    /// <param name="displayName">A string that contains a friendly name for the consumer connection point to display in the user interface (UI).</param><param name="connectionPointType">A <see cref="T:System.Type"/> that derives from <see cref="T:System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint"/>, and that you want to specify as the type of connection point object to use with a specific callback method.</param><exception cref="T:System.ArgumentNullException"><paramref name="displayName"/> or<paramref name=" connectionPointType"/> is null. </exception><exception cref="T:System.ArgumentException"><paramref name="connectionPointType"/> is not valid.</exception>
    public ConnectionConsumerAttribute(string displayName, Type connectionPointType)
      : this(displayName)
    {
      if (connectionPointType == (Type) null)
        throw new ArgumentNullException("connectionPointType");
      this._connectionPointType = connectionPointType;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute"/> class, specifying a display name, an ID, and a specific type of connection point object to use for the consumer connection point.
    /// </summary>
    /// <param name="displayName">A string that contains a friendly name for the consumer connection point to display in the user interface (UI).</param><param name="id">The <see cref="P:System.Web.UI.WebControls.WebParts.ConnectionConsumerAttribute.ID"/>, a unique string value assigned to the consumer connection point.</param><param name="connectionPointType">A <see cref="T:System.Type"/> that derives from <see cref="T:System.Web.UI.WebControls.WebParts.ConsumerConnectionPoint"/>, and that you want to specify as the type of connection point object to use with a specific callback method.</param><exception cref="T:System.ArgumentNullException"><paramref name="displayName"/>, <paramref name="id"/>, or<paramref name=" connectionPointType"/> is null. </exception><exception cref="T:System.ArgumentException"><paramref name="connectionPointType"/> is not valid.</exception>
    public ConnectionConsumerAttribute(string displayName, string id, Type connectionPointType)
      : this(displayName, connectionPointType)
    {
      if (string.IsNullOrEmpty(id))
        throw new ArgumentNullException("id");
      this._id = id;
    }
  }
}
