Esempio n. 1
0
        private static void ImplementWebConnector(
            SortedList <string, TypeDeclaration> connectors,
            ProcessTemplate ATemplate, string AFullNamespace)
        {
            string ConnectorNamespace = AFullNamespace.
                                        Replace("Instantiator.", string.Empty);

            List <TypeDeclaration> ConnectorClasses = TCollectConnectorInterfaces.FindTypesInNamespace(connectors, ConnectorNamespace);

            ConnectorNamespace = ConnectorNamespace.
                                 Replace(".Shared.", ".Server.");

            foreach (TypeDeclaration connectorClass in ConnectorClasses)
            {
                List <string> MethodNames = new List <string>();

                foreach (MethodDeclaration m in CSParser.GetMethods(connectorClass))
                {
                    if (TCollectConnectorInterfaces.IgnoreMethod(m.Attributes, m.Modifier))
                    {
                        continue;
                    }

                    ProcessTemplate snippet;

                    if (FCompileForStandalone)
                    {
                        if (!FUsingNamespaces.ContainsKey(ConnectorNamespace))
                        {
                            FUsingNamespaces.Add(ConnectorNamespace, ConnectorNamespace);
                        }

                        snippet = ATemplate.GetSnippet("WEBCONNECTORMETHODSTANDALONE");
                    }
                    else
                    {
                        snippet = ATemplate.GetSnippet("WEBCONNECTORMETHODREMOTE");
                    }

                    InsertMethodCall(snippet, connectorClass, m, ref MethodNames);

                    ATemplate.InsertSnippet("CONNECTORMETHODS", snippet);
                }
            }
        }
Esempio n. 2
0
        private static void ImplementUIConnector(
            SortedList <string, TypeDeclaration> connectors,
            ProcessTemplate ATemplate, string AFullNamespace)
        {
            string ConnectorNamespace = AFullNamespace.
                                        Replace("Instantiator.", string.Empty);

            List <TypeDeclaration> ConnectorClasses = TCollectConnectorInterfaces.FindTypesInNamespace(connectors, ConnectorNamespace);

            ConnectorNamespace = ConnectorNamespace.
                                 Replace(".Shared.", ".Server.");

            foreach (TypeDeclaration connectorClass in ConnectorClasses)
            {
                foreach (ConstructorDeclaration m in CSParser.GetConstructors(connectorClass))
                {
                    if (TCollectConnectorInterfaces.IgnoreMethod(m.Attributes, m.Modifier))
                    {
                        continue;
                    }

                    ProcessTemplate snippet;

                    FModuleHasUIConnector = true;

                    if (FCompileForStandalone)
                    {
                        if (!FUsingNamespaces.ContainsKey(ConnectorNamespace))
                        {
                            FUsingNamespaces.Add(ConnectorNamespace, ConnectorNamespace);
                        }

                        snippet = ATemplate.GetSnippet("UICONNECTORMETHODSTANDALONE");
                    }
                    else
                    {
                        snippet = ATemplate.GetSnippet("UICONNECTORMETHODREMOTE");
                    }

                    string ParameterDefinition = string.Empty;
                    string ActualParameters    = string.Empty;

                    AutoGenerationTools.FormatParameters(m.Parameters, out ActualParameters, out ParameterDefinition);

                    string methodname = m.Name.Substring(1);

                    if (methodname.EndsWith("UIConnector"))
                    {
                        methodname = methodname.Substring(0, methodname.LastIndexOf("UIConnector"));
                    }

                    string interfacename = CSParser.GetImplementedInterface(connectorClass);
                    snippet.SetCodelet("METHODNAME", methodname);
                    snippet.SetCodelet("PARAMETERDEFINITION", ParameterDefinition);
                    snippet.SetCodelet("ACTUALPARAMETERS", ActualParameters);
                    snippet.SetCodelet("UICONNECTORINTERFACE", interfacename);
                    snippet.SetCodelet("UICONNECTORCLASSNAME", connectorClass.Name);

                    snippet.SetCodelet("UICONNECTORCLASS", string.Empty);

                    if (!FCompileForStandalone)
                    {
                        if (!FUIConnectorsAdded.Contains(connectorClass.Name))
                        {
                            FUIConnectorsAdded.Add(connectorClass.Name);

                            snippet.InsertSnippet("UICONNECTORCLASS",
                                                  GenerateUIConnector(ATemplate, connectorClass, interfacename));
                        }
                    }

                    ATemplate.InsertSnippet("CONNECTORMETHODS", snippet);
                }
            }
        }