예제 #1
0
        /// <summary>
        /// Create a DiscoveryAgent Factory for the scheme.  If we do not support the agent protocol,
        /// an NMSConnectionException will be thrown.
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        private static IDiscoveryAgentFactory CreateAgentFactory(Uri location)
        {
            string scheme = location.Scheme;

            if (string.IsNullOrEmpty(scheme))
            {
                throw new NMSConnectionException(String.Format("Discovery Agent scheme invalid: [{0}]", location.ToString()));
            }

            IDiscoveryAgentFactory factory = null;

            try
            {
                factory = NewInstance(scheme.ToLower());
            }
            catch (NMSConnectionException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new NMSConnectionException("Error creating discovery agent.", e);
            }

            if (null == factory)
            {
                throw new NMSConnectionException("Unable to create a discovery agent.");
            }

            return(factory);
        }
예제 #2
0
        public static IDiscoveryAgent CreateAgent(Uri location)
        {
            IDiscoveryAgentFactory tf = DiscoveryAgentFactory.CreateAgentFactory(location);

            return(tf.CreateAgent(location));
        }