Example #1
0
        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("Ict.Petra.Shared.", "Ict.Petra.Server.");

            ATemplate.SetCodelet("CLIENTOBJECTFOREACHUICONNECTOR", string.Empty);

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

                    ProcessTemplate snippet = ATemplate.GetSnippet("WEBCONNECTORMETHOD");

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

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

                    snippet.InsertSnippet("CHECKUSERMODULEPERMISSIONS",
                                          CreateModuleAccessPermissionCheck(
                                              ATemplate,
                                              connectorClass.Name,
                                              m));

                    string returntype = AutoGenerationTools.TypeToString(m.TypeReference, "");

                    snippet.SetCodelet("RETURN", returntype != "void" ? "return " : string.Empty);

                    snippet.SetCodelet("METHODNAME", m.Name);
                    snippet.SetCodelet("ACTUALPARAMETERS", ActualParameters);
                    snippet.SetCodelet("PARAMETERDEFINITION", ParameterDefinition);
                    snippet.SetCodelet("RETURNTYPE", returntype);
                    snippet.SetCodelet("WEBCONNECTORCLASS", connectorClass.Name);

                    if (!UsingConnectorNamespaces.Contains(ConnectorNamespace))
                    {
                        UsingConnectorNamespaces.Add(ConnectorNamespace);
                    }

                    ATemplate.InsertSnippet("REMOTEDMETHODS", snippet);
                }
            }
        }
        private ProcessTemplate WriteRemotableClass(ProcessTemplate ATemplate,
                                                    String FullNamespace,
                                                    String Classname,
                                                    String Namespace,
                                                    Boolean HighestLevel,
                                                    SortedList <string, TNamespace> children,
                                                    SortedList <string, TypeDeclaration> connectors)
        {
            if ((children.Count == 0) && !HighestLevel)
            {
                return(new ProcessTemplate());
            }

            ProcessTemplate remotableClassSnippet = ATemplate.GetSnippet("REMOTABLECLASS");

            remotableClassSnippet.SetCodelet("SUBNAMESPACEREMOTABLECLASSES", string.Empty);

            remotableClassSnippet.SetCodelet("NAMESPACE", Namespace);

            remotableClassSnippet.SetCodelet("CLIENTOBJECTFOREACHPROPERTY", string.Empty);
            remotableClassSnippet.SetCodelet("SUBNAMESPACEPROPERTIES", string.Empty);

            foreach (TNamespace sn in children.Values)
            {
                ProcessTemplate subNamespaceSnippet = ATemplate.GetSnippet("SUBNAMESPACEPROPERTY");

                string NamespaceName = Namespace + sn.Name;

                if (HighestLevel)
                {
                    NamespaceName = sn.Name;
                }

                subNamespaceSnippet.SetCodelet("OBJECTNAME", sn.Name);
                subNamespaceSnippet.SetCodelet("NAMESPACENAME", NamespaceName);
                subNamespaceSnippet.SetCodelet("NAMESPACE", Namespace);

                remotableClassSnippet.InsertSnippet("SUBNAMESPACEPROPERTIES", subNamespaceSnippet);

                if (sn.Children.Count > 0)
                {
                    // properties for each sub namespace
                    foreach (TNamespace subnamespace in sn.Children.Values)
                    {
                        ATemplate.InsertSnippet("SUBNAMESPACEREMOTABLECLASSES",
                                                WriteRemotableClass(ATemplate,
                                                                    FullNamespace + "." + sn.Name + "." + subnamespace.Name,
                                                                    sn.Name + subnamespace.Name,
                                                                    NamespaceName + subnamespace.Name,
                                                                    false,
                                                                    subnamespace.Children,
                                                                    connectors));
                    }

                    remotableClassSnippet.InsertSnippet("CLIENTOBJECTFOREACHPROPERTY",
                                                        TCreateClientRemotingClass.AddClientRemotingClass(
                                                            FTemplateDir,
                                                            "T" + NamespaceName + "NamespaceRemote",
                                                            "I" + NamespaceName + "Namespace",
                                                            new List <TypeDeclaration>(),
                                                            FullNamespace + "." + sn.Name,
                                                            sn.Children
                                                            ));
                }
                else
                {
                    remotableClassSnippet.InsertSnippet("CLIENTOBJECTFOREACHPROPERTY",
                                                        TCreateClientRemotingClass.AddClientRemotingClass(
                                                            FTemplateDir,
                                                            "T" + NamespaceName + "NamespaceRemote",
                                                            "I" + NamespaceName + "Namespace",
                                                            TCollectConnectorInterfaces.FindTypesInNamespace(connectors, FullNamespace + "." + sn.Name)
                                                            ));
                }
            }

            return(remotableClassSnippet);
        }
Example #3
0
        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("Ict.Petra.Shared.", "Ict.Petra.Server.");

            ATemplate.SetCodelet("CLIENTOBJECTFOREACHUICONNECTOR", string.Empty);

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

                    ProcessTemplate snippet = ATemplate.GetSnippet("UICONNECTORMETHOD");

                    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"));
                    }

                    snippet.SetCodelet("METHODNAME", methodname);
                    snippet.SetCodelet("PARAMETERDEFINITION", ParameterDefinition);
                    snippet.SetCodelet("ACTUALPARAMETERS", ActualParameters);
                    snippet.SetCodelet("UICONNECTORINTERFACE", CSParser.GetImplementedInterface(connectorClass));
                    snippet.SetCodelet("UICONNECTORCLIENTREMOTINGCLASS", connectorClass.Name + "Remote");
                    snippet.SetCodelet("UICONNECTORCLASS", connectorClass.Name);

                    if (!UsingConnectorNamespaces.Contains(ConnectorNamespace))
                    {
                        UsingConnectorNamespaces.Add(ConnectorNamespace);
                    }

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

                List <TypeDeclaration> tempList = new List <TypeDeclaration>();
                tempList.Add(connectorClass);

                ATemplate.InsertSnippet("CLIENTOBJECTFOREACHUICONNECTOR",
                                        TCreateClientRemotingClass.AddClientRemotingClass(
                                            FTemplateDir,
                                            connectorClass.Name + "Remote",
                                            CSParser.GetImplementedInterface(connectorClass),
                                            tempList
                                            ));
            }
        }