Exemplo n.º 1
0
        private void CreateConnectors(TNamespace tn, String AOutputPath, String ATemplateDir)
        {
            String OutputFile = AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                                Path.DirectorySeparatorChar + "Instantiator.Connectors-generated.cs";

            if (Directory.Exists(AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                                 Path.DirectorySeparatorChar + "connect"))
            {
                OutputFile = AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                             Path.DirectorySeparatorChar + "connect" +
                             Path.DirectorySeparatorChar + "Instantiator.Connectors-generated.cs";
            }

            Console.WriteLine("working on " + OutputFile);

            SortedList <string, TypeDeclaration> connectors = TCollectConnectorInterfaces.GetConnectors(tn.Name);

            ProcessTemplate Template = new ProcessTemplate(ATemplateDir + Path.DirectorySeparatorChar +
                                                           "ClientServerGlue" + Path.DirectorySeparatorChar +
                                                           "Connector.cs");

            // load default header with license and copyright
            Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(ATemplateDir));

            Template.SetCodelet("TOPLEVELMODULE", tn.Name);

            Template.AddToCodelet("USINGNAMESPACES", "using Ict.Petra.Shared.Interfaces.M" + tn.Name + ";" + Environment.NewLine);

            UsingConnectorNamespaces = new List <string>();

            string InterfacePath = Path.GetFullPath(AOutputPath).Replace(Path.DirectorySeparatorChar, '/');

            InterfacePath = InterfacePath.Substring(0, InterfacePath.IndexOf("csharp/ICT/Petra")) + "csharp/ICT/Petra/Shared/lib/Interfaces";
            Template.AddToCodelet("USINGNAMESPACES", (CreateInterfaces.AddNamespacesFromYmlFile(InterfacePath, tn.Name)));

            Template.SetCodelet("CONNECTORCLASSES", string.Empty);

            foreach (TNamespace sn in tn.Children.Values)
            {
                WriteConnectorClass(
                    Template,
                    "Ict.Petra.Shared.M" + tn.Name + "." + sn.Name,
                    sn.Name,
                    sn.Name,
                    sn.Children,
                    connectors);
            }

            foreach (string n in UsingConnectorNamespaces)
            {
                Template.AddToCodelet("USINGNAMESPACES", "using " + n + ";" + Environment.NewLine);
            }

            Template.FinishWriting(OutputFile, ".cs", true);
        }
Exemplo n.º 2
0
        private void CreateAutoHierarchy(TNamespace tn, String AOutputPath)
        {
            String OutputFile = AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                                Path.DirectorySeparatorChar + "Instantiator.AutoHierarchy-generated.cs";

            if (Directory.Exists(AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                                 Path.DirectorySeparatorChar + "connect"))
            {
                OutputFile = AOutputPath + Path.DirectorySeparatorChar + "M" + tn.Name +
                             Path.DirectorySeparatorChar + "connect" +
                             Path.DirectorySeparatorChar + "Instantiator.AutoHierarchy-generated.cs";
            }

            Console.WriteLine("working on " + OutputFile);

            SortedList <string, TypeDeclaration> connectors = TCollectConnectorInterfaces.GetConnectors(tn.Name);

            ProcessTemplate Template = new ProcessTemplate(FTemplateDir + Path.DirectorySeparatorChar +
                                                           "ClientServerGlue" + Path.DirectorySeparatorChar +
                                                           "Instantiator.cs");

            // load default header with license and copyright
            Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(FTemplateDir));

            Template.SetCodelet("TOPLEVELMODULE", tn.Name);

            Template.AddToCodelet("USINGNAMESPACES", "using Ict.Petra.Shared.Interfaces.M" + tn.Name + ";" + Environment.NewLine);

            string InterfacePath = Path.GetFullPath(AOutputPath).Replace(Path.DirectorySeparatorChar, '/');

            InterfacePath = InterfacePath.Substring(0, InterfacePath.IndexOf("csharp/ICT/Petra")) + "csharp/ICT/Petra/Shared/lib/Interfaces";
            Template.AddToCodelet("USINGNAMESPACES", CreateInterfaces.AddNamespacesFromYmlFile(InterfacePath, tn.Name));

            ProcessTemplate topLevelNamespaceSnippet = Template.GetSnippet("TOPLEVELNAMESPACE");

            topLevelNamespaceSnippet.SetCodelet("SUBNAMESPACEREMOTABLECLASSES", "");
            topLevelNamespaceSnippet.SetCodelet("TOPLEVELMODULE", tn.Name);
            topLevelNamespaceSnippet.InsertSnippet("LOADERCLASS", WriteLoaderClass(Template, tn.Name));
            topLevelNamespaceSnippet.InsertSnippet("MAINREMOTABLECLASS",
                                                   WriteRemotableClass(
                                                       topLevelNamespaceSnippet,
                                                       "Ict.Petra.Shared.M" + tn.Name,
                                                       "TM" + tn.Name,
                                                       "M" + tn.Name,
                                                       true,
                                                       tn.Children,
                                                       connectors));

            foreach (TNamespace sn in tn.Children.Values)
            {
                topLevelNamespaceSnippet.InsertSnippet("SUBNAMESPACEREMOTABLECLASSES",
                                                       WriteRemotableClass(
                                                           topLevelNamespaceSnippet,
                                                           "Ict.Petra.Shared.M" + tn.Name + "." + sn.Name,
                                                           sn.Name,
                                                           sn.Name,
                                                           false,
                                                           sn.Children,
                                                           connectors));
            }

            Template.InsertSnippet("CONTENT", topLevelNamespaceSnippet);

            Template.FinishWriting(OutputFile, ".cs", true);
        }
Exemplo n.º 3
0
        private static void GenerateGlueForOpenPetraCore(TCmdOpts ACmd, string AOutputDir)
        {
            TNamespace namespaceRoot;

            try
            {
                Console.WriteLine("parsing all cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(AOutputDir + "/Server/lib/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("problems with parsing namespaces from " + AOutputDir + "/Server/lib/");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                /*
                 * CreateInstantiators instantiators = new CreateInstantiators();
                 * instantiators.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                 * TCreateConnectors connectors = new TCreateConnectors();
                 * connectors.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                 */

                CreateInterfaces interfaces = new CreateInterfaces();
                interfaces.CreateFiles(namespaceRoot, AOutputDir + "/Shared/lib/Interfaces", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/Client/app/Core/Remoteobjects", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateConnectorCode(AOutputDir + "/../Common/Remoting/Client", ACmd.GetOptValue("TemplateDir"));
                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server/app/WebService", ACmd.GetOptValue("TemplateDir"));

                namespaceRoot = new TNamespace();
                TNamespace ServerAdminNamespace = new TNamespace("ServerAdmin");
                namespaceRoot.Children.Add("ServerAdmin", ServerAdminNamespace);
                TNamespace ServerAdminWebConnectorNamespace = new TNamespace("WebConnectors");
                ServerAdminNamespace.Children.Add("WebConnectors", ServerAdminWebConnectorNamespace);

                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server/app/WebService", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/ServerAdmin/app/Core", ACmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Exemplo n.º 4
0
        private static void GenerateGlueForPlugin(TCmdOpts ACmd, string AOutputDir)
        {
            TNamespace namespaceRoot;

            AOutputDir = AOutputDir.Replace("\\", "/");

            try
            {
                Console.WriteLine("parsing plugin cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(AOutputDir + "/Server/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("There are no connectors in " + AOutputDir + "/Server/");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                CreateInterfaces interfaces = new CreateInterfaces();
#if disabled
                // at the moment, we do not support UIConnectors for plugins. Better to focus on Webconnectors!
                if (!Directory.Exists(AOutputDir + "/Shared"))
                {
                    Directory.CreateDirectory(AOutputDir + "/Shared");
                }
                interfaces.CreateFiles(namespaceRoot, AOutputDir + "/Shared", ACmd.GetOptValue("TemplateDir"));
#endif
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/Client", ACmd.GetOptValue("TemplateDir"));
                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server", ACmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            TCmdOpts cmd = new TCmdOpts();

            new TAppSettingsManager(false);

            TLogging.DebugLevel = TAppSettingsManager.GetInt32("debuglevel", 0);

            String OutputDir;

            if (!cmd.IsFlagSet("TemplateDir"))
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }

            if (cmd.IsFlagSet("outputdir"))
            {
                OutputDir = cmd.GetOptValue("outputdir");

                // calculate ICTPath from outputdir
                string fullOutputPath = Path.GetFullPath(OutputDir).Replace("\\", "/");

                if (!fullOutputPath.Contains("csharp/ICT"))
                {
                    Console.WriteLine("Output path must be below the csharp/ICT directory");
                }

                CSParser.ICTPath = fullOutputPath.Substring(0, fullOutputPath.IndexOf("csharp/ICT") + "csharp/ICT".Length);
            }
            else
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }

            TNamespace namespaceRoot;

            try
            {
                Console.WriteLine("parsing all cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(OutputDir + "/Server/lib/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("problems with parsing namespaces from " + OutputDir + "/Server/lib/");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                CreateInterfaces interfaces = new CreateInterfaces();
                interfaces.CreateFiles(namespaceRoot, OutputDir + "/Shared/lib/Interfaces", cmd.GetOptValue("TemplateDir"));
                CreateInstantiators instantiators = new CreateInstantiators();
                instantiators.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                TCreateConnectors connectors = new TCreateConnectors();
                connectors.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }