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