diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 11:39:04 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 11:39:04 +0200 |
| commit | 57a828b4d11ab8274053ee035c8de8014ddd4ca1 (patch) | |
| tree | c88e63b5e9019fe67cc3be451e46fbe57efc4a35 /Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs | |
| parent | 2d55102532afaccc447c8a28ded8ccb93437683b (diff) | |
| parent | d6e2772dd98e6880de14ea12be0ef53bae24f763 (diff) | |
| download | Tango-57a828b4d11ab8274053ee035c8de8014ddd4ca1.tar.gz Tango-57a828b4d11ab8274053ee035c8de8014ddd4ca1.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.WebClientGenerator/Program.cs | 26 |
1 files changed, 26 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); + } } } |
