/// <summary> /// Creates a MooseBox REST API at the latest version. /// </summary> /// <param name="version">Specific version of the MooseBox REST API to create.</param> /// <param name="baseUrlStr">Base URL address to the MooseBox, which should be "MooseBox."</param> /// <returns>Instance of versioned MooseBox REST API.</returns> internal IMooseBoxRESTAPI Create(Byte version, string baseUrlStr) { IMooseBoxRESTAPI mooseBoxRESTAPI = null; Uri baseUrl = default(Uri); //Parameter Validations. if (string.IsNullOrEmpty(baseUrlStr) == true) { throw new ArgumentNullException("string baseUrlStr"); } if (Uri.IsWellFormedUriString(baseUrlStr, UriKind.RelativeOrAbsolute) == false) { throw new ArgumentException("Invalid Url. Found: " + base.ToString(), "Uri baseUrlStr"); } //Create the base URL. baseUrl = new Uri(baseUrlStr); //Create API based on version. switch (version) { case 1: mooseBoxRESTAPI = new MooseBoxRESTAPI_v1_0(baseUrl); break; default: throw new ArgumentOutOfRangeException("Byte version", string.Format("{0} <= Version <= {1}. Found: {2}", MinVersion, MaxVersion, version)); } Debug.Assert(mooseBoxRESTAPI != null); return(mooseBoxRESTAPI); }
/// <summary> /// Creates a MooseBox REST API at the latest version. /// </summary> /// <param name="version">Specific version of the MooseBox REST API to create.</param> /// <param name="baseUrlStr">Base URL address to the MooseBox, which should be "MooseBox."</param> /// <returns>Instance of versioned MooseBox REST API.</returns> internal IMooseBoxRESTAPI Create(Byte version, string baseUrlStr) { IMooseBoxRESTAPI mooseBoxRESTAPI = null; Uri baseUrl = default(Uri); //Parameter Validations. if (string.IsNullOrEmpty(baseUrlStr) == true) throw new ArgumentNullException("string baseUrlStr"); if (Uri.IsWellFormedUriString(baseUrlStr, UriKind.RelativeOrAbsolute) == false) throw new ArgumentException("Invalid Url. Found: " + base.ToString(), "Uri baseUrlStr"); //Create the base URL. baseUrl = new Uri(baseUrlStr); //Create API based on version. switch(version) { case 1: mooseBoxRESTAPI = new MooseBoxRESTAPI_v1_0(baseUrl); break; default: throw new ArgumentOutOfRangeException("Byte version", string.Format("{0} <= Version <= {1}. Found: {2}", MinVersion, MaxVersion, version)); } Debug.Assert(mooseBoxRESTAPI != null); return mooseBoxRESTAPI; }