Ejemplo n.º 1
0
        /// <summary>
        /// The Create method creates a new instance of an endpoint
        /// implementation, based on the settings that are found in
        /// a section of a configuration metabase.
        /// </summary>
        /// <param name="settings">
        /// The section of a configuration metabase that contains
        /// configuration details for a specific endpoint type.
        /// </param>
        /// <returns>
        /// The resulting IPC endpoint.
        /// </returns>
        public static IVfxEndpoint Create(XmlDocument settings)
        {
            IVfxEndpoint result = null;

            // REC: Retrieve the endpoint type from the provided
            // settings and determine whether or not an instance
            // of that type can be created:
            XPathNavigator    xpn = settings.CreateNavigator();
            XPathNodeIterator xpi = xpn.Select("/Endpoint");

            if ((xpi.Count == 1) && (xpi.MoveNext()))
            {
                string requestedType = xpi.Current.GetAttribute("type", "");
                if (!string.IsNullOrEmpty(requestedType))
                {
                    switch (requestedType)
                    {
                    case "Tcp.Acceptor":
                        result = new VfxTcpServerEndpoint();
                        break;

                    case "Tcp.Connector":
                        result = new VfxTcpClientEndpoint();
                        break;
                    }
                }
                else
                {
                    throw new ArgumentException("An endpoint type must be specified.");
                }
            }

            if (result == null)
            {
                throw new ArgumentException("The specified endpoint type is not supported.");
            }

            result.Initialize(settings);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The Create method creates a new instance of an endpoint
        /// implementation, based on the settings that are found in
        /// a section of a configuration metabase.
        /// </summary>
        /// <param name="settings">
        /// The section of a configuration metabase that contains 
        /// configuration details for a specific endpoint type.
        /// </param>
        /// <returns>
        /// The resulting IPC endpoint.
        /// </returns>
        public static IVfxEndpoint Create(XmlDocument settings)
        {
            IVfxEndpoint result = null;

            // REC: Retrieve the endpoint type from the provided
            // settings and determine whether or not an instance
            // of that type can be created:
            XPathNavigator xpn = settings.CreateNavigator();
            XPathNodeIterator xpi = xpn.Select("/Endpoint");
            if ((xpi.Count == 1) && (xpi.MoveNext()))
            {
                string requestedType = xpi.Current.GetAttribute("type", "");
                if (!string.IsNullOrEmpty(requestedType))
                {
                    switch (requestedType)
                    {
                        case "Tcp.Acceptor":
                            result = new VfxTcpServerEndpoint();
                            break;
                        case "Tcp.Connector":
                            result = new VfxTcpClientEndpoint();
                            break;
                    }
                }
                else
                {
                    throw new ArgumentException("An endpoint type must be specified.");
                }

            }

            if(result == null)
            {
                throw new ArgumentException("The specified endpoint type is not supported.");
            }

            result.Initialize(settings);
            return result;
        }