示例#1
0
 protected CodeGenerator(TemplateLoader templateLoader, DocumentContext context,
                         GeneratorConfig config, DirectoryInfo outputFolder)
 {
     _outputFolder     = outputFolder;
     _templateLoader   = templateLoader;
     _contextGenerator = context.TemplateContextGenerator;
     _config           = config;
 }
示例#2
0
 public CodeGenerator(TemplateLoader templateLoader, DocumentContext context,
                      GeneratorConfig config, DirectoryInfo outputFolder)
 {
     this.outputFolder     = outputFolder;
     this.templateLoader   = templateLoader;
     this.contextGenerator = context.TemplateContextGenerator;
     this.config           = config;
 }
示例#3
0
        public void Visit(Document document)
        {
            foreach (var definition in document.Definitions)
            {
                var javaType = new JavaType(documentContext.Namespace, TemplateContextGenerator.MangleJavaTypeName(definition.Name), javaNamespace);
                if (definition is Struct)
                {
                    javaType.IsLeanStruct = true;
                }
                else if (definition is IntegerEnum)
                {
                    javaType.IsLeanEnum = true;
                }

                LOG.Debug(string.Format("Registering type '{0}'", javaType));
                documentContext.TypeRegistry.Add(javaType);
            }
        }
示例#4
0
            private CSharpType FindCSharpTypeFromIdentifierType(IdentifierType id)
            {
                var name = id.Name;
                // the name is [<trip-namespace>.]<trip type>
                var names = new List <string>(name.Split('.'));

                if (names.Count == 0 || names.Count > 3)
                {
                    throw new ArgumentException("Only unqualified and trip-namespace qualified names are allowed!");
                }
                string tripName      = names[0];
                string tripNamespace = typeToCSharpConverter._namespace;

                if (names.Count == 2)
                {
                    tripName      = names[1];
                    tripNamespace = names[0];
                }

                var csharpTypeName = tripNamespace + "." + TemplateContextGenerator.MangleCSharpTypeName(tripName);
                var csharpType     = typeToCSharpConverter.typeRegistry.FindType(csharpTypeName);

                return(csharpType);
            }
示例#5
0
        public void Visit(Document document)
        {
            foreach (var definition in document.Definitions)
            {
                if (definition is Service)
                {
                    var serviceType = new CSharpType(documentContext.Namespace,
                                                     TemplateContextGenerator.MangleCSharpServiceName(definition.Name),
                                                     csharpNamespace);
                    LOG.Debug(string.Format("Registering service type '{0}'", serviceType));
                    documentContext.TypeRegistry.Add(serviceType);

                    var clientType = new CSharpType(documentContext.Namespace,
                                                    TemplateContextGenerator.MangleCSharpClientName(definition.Name),
                                                    csharpNamespace);
                    LOG.Debug(string.Format("Registering client type '{0}'", clientType));
                    documentContext.TypeRegistry.Add(clientType);
                    return;
                }

                var csharpType = new CSharpType(documentContext.Namespace,
                                                TemplateContextGenerator.MangleCSharpTypeName(definition.Name),
                                                csharpNamespace);
                if (definition is Struct)
                {
                    csharpType.IsTripStruct = true;
                }
                else if (definition is IntegerEnum)
                {
                    csharpType.IsTripEnum = true;
                }

                LOG.Debug(string.Format("Registering type '{0}'", csharpType));
                documentContext.TypeRegistry.Add(csharpType);
            }
        }