diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-17 01:34:51 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-17 01:34:51 +0200 |
| commit | 6b59b18966fa95b24d8813752f5a1ba1fd730660 (patch) | |
| tree | 2745287dca8601cc44e31ed689866086cf6fdc09 /Software/Visual_Studio/Utilities/Tango.WebClientGenerator | |
| parent | 7d746ab2f2979794c46f7f54a7f7100080993086 (diff) | |
| download | Tango-6b59b18966fa95b24d8813752f5a1ba1fd730660.tar.gz Tango-6b59b18966fa95b24d8813752f5a1ba1fd730660.zip | |
Started basic design of FSE skeletons.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.WebClientGenerator')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs | 26 | ||||
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Tango.WebClientGenerator.csproj | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs index 6bbcd1884..b05e6e311 100644 --- a/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs @@ -21,6 +21,9 @@ namespace Tango.WebClientGenerator //Generate Machine Studio client. GenerateWebClient<MachineStudio.Common.Web.LoginRequest, MachineStudio.Common.Web.LoginResponse, MachineService.Controllers.MachineStudioController>("Tango.MachineStudio.Common.Web", "MachineStudioWebClientBase", PathHelper.GetSolutionFolder() + @"\MachineStudio\Tango.MachineStudio.Common\Web"); + + //Generate FSE client. + GenerateWebClientV2<FSE.Web.Messages.LoginRequest, FSE.Web.Messages.LoginResponse, MachineService.Controllers.FSEController>("Tango.FSE.Common.Web", "FSEWebClientBase", PathHelper.GetSolutionFolder() + @"\FSE\Tango.FSE.Common\Web"); } private static void GenerateWebClient<TLoginRequest, TLoginResponse, TController>(String nameSpace, String name, String path) where TLoginRequest : WebRequestMessage where TLoginResponse : WebTokenResponse where TController : TangoController @@ -45,5 +48,28 @@ namespace Tango.WebClientGenerator String code = model.GenerateCode(); File.WriteAllText(Path.Combine(path, name + ".cs"), code); } + + private static void GenerateWebClientV2<TLoginRequest, TLoginResponse, TController>(String nameSpace, String name, String path) where TLoginRequest : WebRequestMessage where TLoginResponse : WebTokenResponse where TController : TangoController + { + TangoWebClientv2CodeFile model = new TangoWebClientv2CodeFile(); + model.Namespace = nameSpace; + model.ControllerName = typeof(TController).Name.Replace("Controller", ""); + model.Name = name; + model.LoginRequest = typeof(TLoginRequest).FullName; + model.LoginResponse = typeof(TLoginResponse).FullName; + + foreach (var action in typeof(TController).GetMethods().Where(x => typeof(WebResponseMessage).IsAssignableFrom(x.ReturnType) && x.Name != "Login")) + { + model.Actions.Add(new TangoWebClientv2CodeFile.ControllerAction() + { + Name = action.Name, + Request = action.GetParameters()[0].ParameterType.FullName, + Response = action.ReturnType.FullName, + }); + } + + String code = model.GenerateCode(); + File.WriteAllText(Path.Combine(path, name + ".cs"), code); + } } } diff --git a/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Tango.WebClientGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Tango.WebClientGenerator.csproj index da8738617..e589db6be 100644 --- a/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Tango.WebClientGenerator.csproj +++ b/Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Tango.WebClientGenerator.csproj @@ -53,6 +53,10 @@ <None Include="packages.config" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\FSE\Tango.FSE.Web\Tango.FSE.Web.csproj"> + <Project>{d6f7d31d-7f8c-45e2-ae0a-fbbd1f5f9d5f}</Project> + <Name>Tango.FSE.Web</Name> + </ProjectReference> <ProjectReference Include="..\..\MachineStudio\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj"> <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project> <Name>Tango.MachineStudio.Common</Name> |
