Exemplo n.º 1
0
        /// <summary>
        /// Return a child <b>IXmlElement</b> of the given <b>IXmlElement</b>
        /// that can be used to  create and configure a new
        /// <b>IConnectionInitiator</b>.
        /// </summary>
        /// <remarks>
        /// The given <b>IXmlElement</b> must have a child element with one
        /// of the following names:
        /// <list type="number">
        /// <item>
        /// tcp-initiator: used to create and configure a new TcpInitiator
        /// </item>
        /// </list>
        /// </remarks>
        /// <param name="xml">
        /// The parent <b>IXmlElement</b> of the <b>IXmlElement</b> used to
        /// create and configure a new <b>IConnectionInitiator</b>.
        /// </param>
        /// <returns>
        /// A child <b>IXmlElement</b> that can be used to create and
        /// configure a new <b>IConnectionInitiator</b> or <c>null</c> if no
        /// such <b>IXmlElement</b> exists.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// If the given <b>IXmlElement</b> does not have a valid
        /// <b>IConnectionInitiator</b> configuration child element.
        /// </exception>
        public static IXmlElement FindInitiatorConfig(IXmlElement xml)
        {
            IXmlElement xmlConfig = xml.Name.Equals("initiator-config")
                    ? xml : xml.GetSafeElement("initiator-config");

            if (xmlConfig.GetElement("tcp-initiator") != null)
            {
                return((IXmlElement)xmlConfig.Clone());
            }

            throw new ArgumentException("the \"initiator-config\" element is either"
                                        + " missing, empty, or does not contain a valid transport-specific"
                                        + " child element:\n" + xml);
        }