Example #1
0
        public ServiceContext ServiceFromLean(Service service)
        {
            var name     = MangleJavaTypeName(service.Name);
            var javaType = typeRegistry.FindType(defaultNamespace, name);

            var javaParents = new HashSet <string>();

            string serviceName = null, serviceNamespace = null;

            if (service.Annotations != null && service.Annotations.Count != 0)
            {
                var serviceNameAnnotation = service.Annotations.FirstOrDefault(a => a.Name == "serviceName");
                serviceName = serviceNameAnnotation != null ? serviceNameAnnotation.Value : null;
                var serviceNamespaceAnnotation = service.Annotations.FirstOrDefault(a => a.Name == "serviceNamespace");
                serviceNamespace = serviceNamespaceAnnotation != null ? serviceNamespaceAnnotation.Value : null;
            }
            if (serviceName == null || serviceNamespace == null)
            {
                var message = string.Format("serviceName and serviceNamespace annotations are required for {0}.",
                                            service.Name);
                throw new ArgumentException(message);
            }
            var serviceContext = new ServiceContext(service.DocStringLines, name, javaType.Package, javaType.SimpleName,
                                                    javaParents, serviceName, serviceNamespace);

            //javaParents.Add("java.io.Serializable");

            return(serviceContext);
        }
        public virtual ServiceContext ServiceFromIdl(Service service)
        {
            var name = _typeMangler.MangleTypeName(service.Name);
            var type = _typeRegistry.FindType(_defaultNamespace, name);

            var parents = new HashSet <string>();

            string serviceName, serviceNamespace;

            GetServiceNameAndNamespace(service, out serviceName, out serviceNamespace);

            var serviceContext = new ServiceContext(service.DocStringLines, name, type.CodeNamespace, type.Name,
                                                    parents, serviceName, serviceNamespace);

            return(serviceContext);
        }
        public ServiceContext ServiceFromTrip(Service service)
        {
            var name       = MangleCSharpServiceName(service.Name);
            var csharpType = typeRegistry.FindType(defaultNamespace, name);

            var    csharpParents = new HashSet <string>();
            string serviceName, serviceNamespace;

            GetServiceNameAndNamespace(service, out serviceName, out serviceNamespace);

            var serviceContext = new ServiceContext(service.DocStringLines, name, csharpType.TypeNamespace,
                                                    csharpType.TypeName, csharpParents, serviceName, serviceNamespace);

            if (generatorConfig.ContainsTweak(GeneratorTweak.ADD_DISPOSABLE_INTERFACE))
            {
                csharpParents.Add("IDisposable");
                //serviceContext.AddMethod(DISPOSE_METHOD_CONTEXT);
            }

            return(serviceContext);
        }
Example #4
0
        public virtual ServiceContext ServiceFromIdl(Service service)
        {
            ValidateService(service);

            var name = _typeMangler.MangleTypeName(service.Name);
            var type = _typeRegistry.FindType(_defaultNamespace, name);

            var parents = new HashSet <string>();

            string serviceName, serviceNamespace;

            GetServiceNameAndNamespace(service, out serviceName, out serviceNamespace);

            var serviceContext = new ServiceContext(service.DocStringLines, name, type.CodeNamespace, type.Name,
                                                    parents, serviceName, serviceNamespace);

            foreach (var method in service.Methods)
            {
                var methodContext = MethodFromIdl(method);
                serviceContext.AddMethod(methodContext);
            }
            return(serviceContext);
        }