ConnectionProviderAttribute.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / UI / WebParts / ConnectionProviderAttribute.cs / 1 / ConnectionProviderAttribute.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls.WebParts { 
 
    using System;
    using System.ComponentModel; 
    using System.Reflection;
    using System.Security.Permissions;

    [AttributeUsage(AttributeTargets.Method)] 
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
    public class ConnectionProviderAttribute : Attribute { 

        private string _displayName; 
        private string _id;
        private Type _connectionPointType;
        private bool _allowsMultipleConnections;
 
        public ConnectionProviderAttribute(string displayName) {
            if (String.IsNullOrEmpty(displayName)) { 
                throw new ArgumentNullException("displayName"); 
            }
 
            _displayName = displayName;
            _allowsMultipleConnections = true;
        }
 
        public ConnectionProviderAttribute(string displayName, string id) : this(displayName) {
            if (String.IsNullOrEmpty(id)) { 
                throw new ArgumentNullException("id"); 
            }
 
            _id = id;
        }

        public ConnectionProviderAttribute(string displayName, Type connectionPointType) : this(displayName) { 
            if (connectionPointType == null) {
                throw new ArgumentNullException("connectionPointType"); 
            } 

            _connectionPointType = connectionPointType; 
        }

        public ConnectionProviderAttribute(string displayName, string id, Type connectionPointType) : this(displayName, connectionPointType) {
            if (String.IsNullOrEmpty(id)) { 
                throw new ArgumentNullException("id");
            } 
 
            _id = id;
        } 

        public bool AllowsMultipleConnections {
            get {
                return _allowsMultipleConnections; 
            }
            set { 
                _allowsMultipleConnections = value; 
            }
        } 

        public string ID {
            get {
                return (_id != null) ? _id : String.Empty; 
            }
        } 
 
        public virtual string DisplayName {
            get { 
                return DisplayNameValue;
            }
        }
 
        protected string DisplayNameValue {
            get { 
                return _displayName; 
            }
            set { 
                _displayName = value;
            }
        }
 
        public Type ConnectionPointType {
            get { 
                if (WebPartUtil.IsConnectionPointTypeValid(_connectionPointType, /*isConsumer*/ false)) { 
                    return _connectionPointType;
                } 
                else {
                    throw new InvalidOperationException(SR.GetString(
                        SR.ConnectionProviderAttribute_InvalidConnectionPointType, _connectionPointType.Name));
                } 
            }
        } 
    } 
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls.WebParts { 
 
    using System;
    using System.ComponentModel; 
    using System.Reflection;
    using System.Security.Permissions;

    [AttributeUsage(AttributeTargets.Method)] 
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] 
    public class ConnectionProviderAttribute : Attribute { 

        private string _displayName; 
        private string _id;
        private Type _connectionPointType;
        private bool _allowsMultipleConnections;
 
        public ConnectionProviderAttribute(string displayName) {
            if (String.IsNullOrEmpty(displayName)) { 
                throw new ArgumentNullException("displayName"); 
            }
 
            _displayName = displayName;
            _allowsMultipleConnections = true;
        }
 
        public ConnectionProviderAttribute(string displayName, string id) : this(displayName) {
            if (String.IsNullOrEmpty(id)) { 
                throw new ArgumentNullException("id"); 
            }
 
            _id = id;
        }

        public ConnectionProviderAttribute(string displayName, Type connectionPointType) : this(displayName) { 
            if (connectionPointType == null) {
                throw new ArgumentNullException("connectionPointType"); 
            } 

            _connectionPointType = connectionPointType; 
        }

        public ConnectionProviderAttribute(string displayName, string id, Type connectionPointType) : this(displayName, connectionPointType) {
            if (String.IsNullOrEmpty(id)) { 
                throw new ArgumentNullException("id");
            } 
 
            _id = id;
        } 

        public bool AllowsMultipleConnections {
            get {
                return _allowsMultipleConnections; 
            }
            set { 
                _allowsMultipleConnections = value; 
            }
        } 

        public string ID {
            get {
                return (_id != null) ? _id : String.Empty; 
            }
        } 
 
        public virtual string DisplayName {
            get { 
                return DisplayNameValue;
            }
        }
 
        protected string DisplayNameValue {
            get { 
                return _displayName; 
            }
            set { 
                _displayName = value;
            }
        }
 
        public Type ConnectionPointType {
            get { 
                if (WebPartUtil.IsConnectionPointTypeValid(_connectionPointType, /*isConsumer*/ false)) { 
                    return _connectionPointType;
                } 
                else {
                    throw new InvalidOperationException(SR.GetString(
                        SR.ConnectionProviderAttribute_InvalidConnectionPointType, _connectionPointType.Name));
                } 
            }
        } 
    } 
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK