Ejemplo n.º 1
0
        public void OnExecute()
        {
            using var server = OutProcGenProtocol.CreateServer(PipeName);
            server.WaitForConnection();
            server.BeginSession();

            //           server.StartProfile("all_profiles");

            //           var buff = new StringBuilder();
            //           buff.AppendLine(@"
            //namespace Conjure.Gen
            //{
            //    public partial class Profiles
            //    {
            //");
            //           foreach (var profile in GetProfiles())
            //           {
            //               buff.AppendLine($"        // {profile.Name}");
            //               buff.AppendLine($"        public const string ProfilePath_{profile.Name} = \"{profile.ProfilePath.Replace("\\", "\\\\")}\";");
            //               buff.AppendLine($"        public const string OptionsPath_{profile.Name} = \"{profile.OptionsPath.Replace("\\", "\\\\")}\";");
            //           }
            //           buff.AppendLine(@"
            //    }
            //}
            //");
            //           server.AddFile("AllProfiles.cs", buff.ToString());

            try
            {
                foreach (var profile in GetProfiles())
                {
                    var options = _serializer.Load(profile);
                    var model   = _cacheBuilder.LoadFromCache(options);

                    var tc = GenerateCommand.ResolveTemplates(options);

                    server.StartProfile(profile.Name);
                    _codeGenerator.Generate(options, model, tc, server.AddFile);
                }
            }
            catch (Exception ex)
            {
                server.Fail("???", ex.Message, ex.StackTrace);
            }

            server.EndSession();
        }
Ejemplo n.º 2
0
        static void DoOPGServer()
        {
            using var server = OutProcGenProtocol.CreateServer("foo");
            Console.WriteLine("Server created");

            server.WaitForConnection();
            Console.WriteLine("Server connected");

            server.BeginSession();

            server.StartProfile("p1");
            server.AddFile("p1_f1", "This is file 1 of profile 1");
            server.AddFile("p1_f2", "This is file 2 of profile 1");

            server.StartProfile("p2");
            server.AddFile("p2_f1", "This is file 1 of profile 2");
            server.AddFile("p2_f2", "This is file 2 of profile 2");

            server.EndSession();
        }