Beispiel #1
0
 /// <summary>
 /// Loads registration info from a file
 /// </summary>
 /// <param name="filePath">full file path to load from</param>
 /// <returns>the loaded registration info</returns>
 public static WebServiceRegistrationInfo LoadFromFile(string filePath)
 {
     try
     {
         WebServiceRegistrationInfo result = null;
         using (TextReader reader = new StreamReader(filePath))
         {
             result = (WebServiceRegistrationInfo)_serializer.Deserialize(reader);
             reader.Close();
         }
         return(result);
     }
     catch (InvalidOperationException)
     {
     }
     return(new WebServiceRegistrationInfo());
 }
 private static void LoadConfigurations(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         path = LongPath.Combine(AssemblyExtensions.ApplicationDirectory, "WebServiceLibraries");
     }
     try
     {
         var allFiles = LongPathDirectory.EnumerateFiles(path, "*.config", System.IO.SearchOption.AllDirectories);
         foreach (var file in allFiles)
         {
             try
             {
                 var info    = WebServiceRegistrationInfo.LoadFromFile(file);
                 var gllName = LongPath.ChangeExtension(file, ".gll");
                 if (info.RegisteredVIs != null)
                 {
                     foreach (var item in info.RegisteredVIs)
                     {
                         if (item.Type == WebServiceType.HttpGetMethod)
                         {
                             var registeredExecutable = new RegisteredHttpGetVI(
                                 _connectionManager,
                                 _httpServer,
                                 gllName,
                                 item.VIComponentName,
                                 item.UrlPath);
                             _connectionManager.AddConnectionType(registeredExecutable);
                         }
                     }
                 }
             }
             catch (Exception e)
             {
                 Log.LogError(0, e, $"Failed to load configuration: {file}");
             }
         }
     }
     catch (Exception enumerateException)
     {
         Log.LogError(0, enumerateException, "Failed to enumerate configuration files");
     }
 }