示例#1
0
 /// <summary>
 /// This method authenticates and authorizes each requests by hostname, port and token
 /// </summary>
 /// <param name="hostName">host that serves the API</param>
 /// <param name="port">endpoint of connection</param>
 /// <param name="token">token authentication</param>
 protected AbstractApiWrapper(string hostName, int port, string suffix, string token, LightDomain lightDomain, Boolean stub = false)
 {
     _token    = token;
     _endpoint = $"{hostName}{((port > 0) ? ":" + port.ToString() + "/" : "/")}{((!string.IsNullOrEmpty(suffix)) ? suffix + "/" : "")}";
     // Defines apiname for use of stubs according to hostname
     _apiname     = hostName.Replace("http://", "");
     _lightDomain = lightDomain;
     _suffix      = suffix;
     _stub        = stub;
 }
        /// <summary>
        /// Method for create a instance of LightDomain objects
        /// </summary>
        /// <typeparam name="T">Type of LightDomain</typeparam>
        /// <returns></returns>
        protected T Factory <T>() where T : LightDomain, new()
        {
            ///Verify if there's erros
            if (_inputValidationErrors.Count > 0)
            {
                /// Throws the error code from errors list of input validation to View Model
                throw new InvalidInputException(_inputValidationErrors);
            }
            var domain = LightDomain.FactoryDomain <T>();

            domain.Telemetry      = Telemetry;
            domain.Cache          = Cache;
            domain.CritictHandler = _criticHandler;
            return(domain);
        }
示例#3
0
 /// <summary>
 /// Initilizes API from fixed hostname, port and token
 /// </summary>
 /// <param name="hostName">host that serves the API</param>
 /// <param name="port">endpoint of connection</param>
 /// <param name="token">token authentication</param>
 public LightApi(string hostName, int port, string suffix, string token, LightDomain lightDomain) : base(hostName, port, suffix, token, lightDomain)
 {
 }