Пример #1
0
        public static void Unregister(DN dn)
        {
            lock (Nodes)
            {
                Node node = Node.Root;
                foreach (RDN rdn in dn.RDNs)
                {
                    string nodeText = null;
                    foreach (RDNComponent comp in rdn.Components)
                    {
                        nodeText = comp.ComponentType + "=" + comp.ComponentValue;
                        break;
                    }
                    if (node.Children.ContainsKey(nodeText))
                    {
                        node = node.Children[nodeText];
                    }
                    else
                    {
                        return; // Not found
                    }
                }

                // Remove the node
                node.Remove();
            }
        }
Пример #2
0
 public static Node Register(DN dn, IMBean obj)
 {
     Node node = Node.Root;
     lock (Nodes)
     {
         foreach (RDN rdn in dn.RDNs)
         {
             string nodeText = null;
             foreach (RDNComponent comp in rdn.Components)
             {
                 nodeText = comp.ComponentType + "=" + comp.ComponentValue;
                 break;
             }
             if (node.Children.ContainsKey(nodeText))
             {
                 node = node.Children[nodeText];
             }
             else
             {
                 Node newNode = new Node(nodeText, node);
                 node.Children.Add(newNode.Text, newNode);
                 Node.Nodes.Add(newNode.Id, newNode);
                 node = newNode;
             }
         }
     }
     node.Payload = obj;
     return node;
 }
Пример #3
0
        /// <summary>
        /// Gets a DN object representing a child object of the current DN.
        /// </summary>
        /// <param name="childRDN">a string representing the relative path to the child object</param>
        /// <returns>a DN object representing a child object of the current DN</returns>
        public DN GetChild(string childRDN)
        {
            DN childDN = new DN(childRDN);

            if (childDN.rDNs.Length > 0)
            {
                RDN[] fullPath = new RDN[this.RDNs.Length + childDN.rDNs.Length];

                for (int i = 0; i < childDN.rDNs.Length; i++)
                {
                    fullPath[i] = childDN.rDNs[i];
                }
                for (int j = 0; j < this.rDNs.Length; j++)
                {
                    fullPath[j + childDN.rDNs.Length] = this.rDNs[j];
                }

                return new DN(new RDNList(fullPath), this.CharsToEscape);
            }
            else
            {
                return this;
            }
        }
 public MBeanNameAttribute(string dn)
 {
     this.dn = new DN(dn);
 }
Пример #5
0
        /// <summary>
        /// Checks whether the current DN is a parent object of the specified DN.
        ///
        /// For example:
        /// The DN OU=People,DC=example,DC=com
        /// contains CN=Mike,OU=Marketing,OU=People,DC=example,DC=com
        ///
        /// </summary>
        /// <param name="childDN">The DN object to check against the current object</param>
        /// <returns>true if childDN is a child of the current DN; false otherwise</returns>
        public bool Contains(DN childDN)
        {
            if (childDN.rDNs.Length > this.rDNs.Length)
            {
                int Offset = childDN.rDNs.Length - this.rDNs.Length;

                for (int i = 0; i < this.rDNs.Length; i++)
                {
                    if (childDN.rDNs[i + Offset] != this.rDNs[i])
                        return false;
                }

                return true;
            }
            else
            {
                return false;
            }
        }