Esempio n. 1
0
        /// <summary>
        /// This function returns a RESTConnector object for the given service and function.
        /// </summary>
        /// <param name="authenticator">Authenticator used to authenticate service.</param>
        /// <param name="function">The name of the function.</param>
        /// <param name="serviceUrl">Service Url to connect to.</param>
        /// <returns>Returns a RESTConnector object or null on error.</returns>
        ///
        public static RESTConnector GetConnector(Authenticator authenticator, string function, string serviceUrl)
        {
            if (string.IsNullOrEmpty(serviceUrl))
            {
                throw new ArgumentNullException("The serviceUrl must not be empty or null.");
            }

            if (Utility.HasBadFirstOrLastCharacter(serviceUrl))
            {
                throw new ArgumentException("The serviceUrl property is invalid. Please remove any surrounding {{, }}, or \" characters.");
            }

            RESTConnector connector = new RESTConnector
            {
                URL            = serviceUrl + function,
                Authentication = authenticator
            };

            authenticator.Authenticate(connector);
            return(connector);
        }