WingApplicationBuilder.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Reflection;
  5. using System.Linq;
  6. using JsonRpcLite.InProcess;
  7. using JsonRpcLite.Network;
  8. using JsonRpcLite.Rpc;
  9. using WingServerCommon.Service;
  10. using WingServerCommon.Log;
  11. using WingServerCommon.Config;
  12. using WingServerCommon.Config.Parameters;
  13. using System.Runtime.Loader;
  14. using WingCloudServer.Loader;
  15. namespace WingCloudServer
  16. {
  17. internal class WingApplicationBuilder
  18. {
  19. public WingApplicationBuilder(string[] args)
  20. {
  21. //TODO args ? when to use
  22. }
  23. /// <summary>
  24. /// Start server to load all service
  25. /// </summary>
  26. internal WingApplication Build()
  27. {
  28. //=========================================================================//
  29. /// TODO workaround fixed, we need a better solution
  30. AssemblyLoadContext.Default.Resolving += (a,b)=>{
  31. //自定义依赖文件存放路径
  32. var dependenciesPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Dependencies");
  33. return Assembly.LoadFrom(Path.Combine(dependenciesPath, $"{b.Name}.dll"));
  34. };
  35. //=========================================================================//
  36. //启动短信服务 //TODO Why we need sms tool in server ? or move to sms service ?
  37. ProcessStarter.StartTool("Sms.Tool"); //Should be actived by deploy service in the future
  38. Logger.WriteLineInfo($"Process Sms.Tool started!");
  39. var app = new WingApplication();
  40. return app;
  41. }
  42. }
  43. }