123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
-
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace MBIRevitBase.Config
- {
- public class ApiConfig
- {
- public static string m_AlgorithmUrl;
- public static string AlgorithmUrl()
- {
- if (string.IsNullOrWhiteSpace(m_AlgorithmUrl))
- {
- string ip=GetAppSettingsConfig("IP");
- string port= GetAppSettingsConfig("Port");
-
-
- string path = ApiConfig.GetAppSettingsConfig("Path");
- m_AlgorithmUrl = $"{ip}:{port}{path}";
- File.AppendAllText("D:\\log.txt",m_AlgorithmUrl);
- }
- return m_AlgorithmUrl;
- }
-
-
-
-
-
- public static string GetAppSettingsConfig(string key)
- {
- string codeBase = Assembly.GetExecutingAssembly().CodeBase;
- UriBuilder uri = new UriBuilder(codeBase);
- string path = Uri.UnescapeDataString(uri.Path);
- string addString = ConfigurationManager.OpenExeConfiguration(path).AppSettings.Settings[key].Value.ToString();
- return addString;
- }
- }
- }
|