Ejemplo n.º 1
0
        public void AddInterface(IInterface iface, string name)
        {
            if (iface == null || name == null)
                throw new ArgumentNullException ();

            if (this.interfaces.Contains (iface))
                throw new ArgumentException ();

            if (this.interfaces.Count (_ => _.Name == name) != 0)
                throw new ArgumentException ();

            if (this.OnBeforeAddInterface != null)
                this.OnBeforeAddInterface.Invoke (this, iface);

            this.interfaces.Add (iface);
            iface.SetName (name);
            // iface.SetDevice (this);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   ��������� ���������� ��������� � ����������.
        /// </summary>
        /// <param name = "iface">���������� ���������, ������� ����� ��������.</param>
        /// <param name = "name">�������� ����������.</param>
        /// <remarks>
        ///   � �������� �������� ���������� ������������ �������� � <paramref name = "name" /> ���.
        ///   ����� ���������� ���������� � ���������� ��� ������������� ��������� ���.
        /// </remarks>
        /// <exception cref = "ArgumentNullException"><paramref name = "iface" /> �������� <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "name" /> �������� <c>null</c>.</exception>
        /// <exception cref = "InterfaceAlreadyAttachedToDeviceException">��������� ��� �������� � ����������.</exception>
        /// <exception cref = "InterfaceNameMustBeUniqueException">��� ���������� �� ��������� � �������� ����������.</exception>
        public virtual void AddInterface(IInterface iface, string name)
        {
            if (iface.Device != null)
                throw new InterfaceAlreadyAttachedToDeviceException (iface.Name);

            if (this.interfaces.ContainsKey (name))
                throw new InterfaceNameMustBeUniqueException (name, this.Name);

            if (this.OnBeforeAddInterface != null) {
                try {
                    this.OnBeforeAddInterface.Invoke (this, iface);
                }
                catch {}
            }

            this.interfaces.Add (name, iface);
            iface.SetName (name);
            iface.SetDevice (this);
        }