public ITransport GetTransport(String protocol)
        {
            if (protocol == null)
            {
                throw new ArgumentException("Protocol cannot be null");
            }
            protocol = protocol.ToLower();

            foreach (ITransport trans in fTransports)
            {
                if (trans.Protocol.Equals(protocol))
                {
                    return(trans);
                }
            }

            // No transport has been created for this protocol yet. Create
            // new one using the TransportPlugin
            TransportPlugin     tp   = Adk.GetTransportProtocol(protocol);
            TransportProperties defs = GetDefaultTransportProperties(protocol);

            ITransport transport = tp.NewInstance(defs);

            fTransports.Add(transport);
            return(transport);
        }
        /// <summary>
        /// Gets the default properties for a transport protocol
        /// </summary>
        /// <remarks>
        ///  Each transport protocol supported by the ADK is represented by a class
        ///  that implements the Transport interface. Transports are identified by
        ///  a string such as "http" or "https". Like Zones, each Transport instance
        ///  is associated with a set of properties specific to the transport
        ///  protocol. Such properties may include IP address, port, SSL security
        ///  attributes, and so on. The default properties for a given transport
        ///  protocol may be obtained by calling this method.
        /// </remarks>
        /// <param name="protocol"></param>
        /// <returns>The default properties for the specified protocol</returns>
        /// <exception cref="AdkTransportException">is thrown if the protocol is not supported
        /// by the ADK</exception>
        public TransportProperties GetDefaultTransportProperties(String protocol)
        {
            //  Already initialized?
            if (fDefaultTransportProps == null)
            {
                fDefaultTransportProps = new List <TransportProperties>();
            }
            else
            {
                foreach (TransportProperties props in fDefaultTransportProps)
                {
                    if (props.Protocol.Equals(protocol))
                    {
                        return(props);
                    }
                }
            }

            // Didn't find the transport properties above. Create a new one and return it
            TransportPlugin tp = Adk.GetTransportProtocol(protocol);

            if (tp == null)
            {
                throw new AdkTransportException("The requested transport protocol: '" + protocol +
                                                "'  is not supported by this instance of the ADK", null);
            }

            TransportProperties properties = tp.CreateProperties();

            properties.Defaults(null);
            fDefaultTransportProps.Add(properties);
            return(properties);
        }
示例#3
0
 /// <summary>
 /// Installs a new TransportProtocol
 /// </summary>
 /// <param name="tp"></param>
 public static void Install(TransportPlugin tp)
 {
     if (tp == null)
     {
         throw new ArgumentNullException("TransportPlugin cannot be null");
     }
     CheckInit();
     sSingleton.fTransports[tp.Protocol.ToLower()] = tp;
 }