Ejemplo n.º 1
0
 public override bool Connect(string gateway)
 {
     try
     {
         var node = _gatewayProvider.GetClusterNode(gateway);
         _instance = new HttpClient()
         {
             BaseAddress = new Uri(node.Address)
         };
         _instance.DefaultRequestHeaders.Accept.Clear();
         _instance.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         this.OnConnected?.Invoke(_instance);
         return(true);
     }
     catch { }
     return(false);
 }
Ejemplo n.º 2
0
 public override bool Connect(string gateway)
 {
     try
     {
         var node = _gatewayProvider.GetClusterNode(gateway);
         if (node.Details.TryGetValue("contract", out string list))
         {
             var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(list);
             _instance = (ICommunicationObject)Activator.CreateInstance(_instance_type, _endpointConfigName, dict[_interface_type.FullName]);
             this.OnConnected?.Invoke(_instance);
             return(true);
         }
     }
     catch (Exception ex)
     {
     }
     return(false);
 }