示例#1
0
        public static async Task <MyConfig> LoadDaemonConfig(this ISimpleConfigFile simpleConfigFile)
        {
            var config = await simpleConfigFile.ReadFile <MyConfig>(null).ConfigureAwait(false);

            if (config == null)
            {
                config = new MyConfig();
                config.ProcessInfos.Add(new SimpleProcessInfo()
                {
                    ProcessName = "FooClient", ExePath = "FooClient.exe", ExeArgs = null
                });
                config.ServiceInfo = new WindowServiceInfo()
                {
                    ServiceName = "MockService", ServicePath = "FooClientWs.exe", ServiceFriendlyName = "000-MockService"
                };
                await simpleConfigFile.SaveFile(config).ConfigureAwait(false);
            }
            return(config);
        }
        public static string GetDefaultConfigFilePath <T>(this ISimpleConfigFile simpleConfigFile)
        {
            var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, typeof(T).Name + ".json");

            return(filePath);
        }
        public static Task SaveFile <T>(this ISimpleConfigFile simpleConfigFile, T value) where T : ISimpleConfig
        {
            var filePath = GetDefaultConfigFilePath <T>(simpleConfigFile);

            return(simpleConfigFile.SaveFile(filePath, value));
        }
        public static Task <T> ReadFile <T>(this ISimpleConfigFile simpleConfigFile, T defaultValue) where T : ISimpleConfig
        {
            var filePath = GetDefaultConfigFilePath <T>(simpleConfigFile);

            return(simpleConfigFile.ReadFile(filePath, defaultValue));
        }
示例#5
0
 public MainVo(ISimpleConfigFile simpleConfigFile, IWebApiTester webApiHelper)
 {
     SimpleConfigFile = simpleConfigFile;
     WebApiHelper     = webApiHelper;
     SimpleLog        = SimpleLogFactory.Instance.CreateLogFor(this);
 }