public Task Run() { var nativeApiInfo = _nativeApiInfoProvider.Get(MahuaPlatform.Mpq); var nativeApiIn = _httpApiInputModelsGenerator.Generate(new HttpApiInputModelsGeneratorInput { NativeApiInfo = nativeApiInfo, MahuaPlatform = MahuaPlatform.Mpq }); var code = CodeFormatter.FormatCode(nativeApiIn); var filename = Path.Combine(_sourceFileProvider.GetBasePath(), "Newbe.Mahua.InputReceivers.HttpApi/Services/Controllers/MpqController.cs"); File.WriteAllText(filename, code, Encoding.UTF8); return(Task.CompletedTask); }
public Task Run() { var nativeApiInfo = _nativeApiInfoProvider.Get(MahuaPlatform.Mpq); var apiHandler = _apiHandlerGenerator.Generate(new ApiHandlerGeneratorInput { Namespace = "Newbe.Mahua.Mpq", NativeApiInfo = nativeApiInfo, ApiOutBaseName = "MpqApiOutput", ApiHandlerClassName = "MpqMahuaApiHandler", }); var filename = Path.Combine(_sourceFileProvider.GetBasePath(), "Newbe.Mahua.MPQ/MpqMahuaApiHandler.cs"); File.WriteAllText(filename, CodeFormatter.FormatCode(apiHandler), Encoding.UTF8); return(Task.CompletedTask); }
private NativeApiInfo ResolveNativeApiInfo(MahuaPlatform mahuaPlatform) { var basePath = _sourceFileProvider.GetBasePath(); var filePath = mahuaPlatform switch { MahuaPlatform.Cqp => "Newbe.Mahua/NativeApi/ICqpApi.cs", MahuaPlatform.Mpq => "Newbe.Mahua/NativeApi/IMpqApi.cs", MahuaPlatform.QQLight => "Newbe.Mahua/NativeApi/IQQLightApi.cs", MahuaPlatform.Amanda => throw new NotSupportedException(), MahuaPlatform.CleverQQ => throw new NotSupportedException(), _ => throw new ArgumentOutOfRangeException(nameof(mahuaPlatform), mahuaPlatform, null) }; var filename = Path.Combine(basePath, filePath); var apiSourceFile = File.ReadAllText(filename); var nativeApiInfo = _nativeApiInfoResolver.GetMahuaApiInfo(apiSourceFile); return(nativeApiInfo); } }