private void GenerateCodeRecursive(ProtoFile proto)
        {
            foreach (var item in proto.ImportedFiles)
            {
                GenerateCodeRecursive(item);
            }

            var typeGenerator = new TypeGenerator(proto, _options.ModelOptions);

            typeGenerator.GenerateCode();

            if (_options.ServiceOptions != null)
            {
                var serviceGenerator = new ServiceGenerator(proto, _options.ServiceOptions, typeGenerator);
                serviceGenerator.GenerateCode();

                if (_options.ControllerOptions != null)
                {
                    var controlller = new WebApiControllerGenerator(proto, _options.ControllerOptions, serviceGenerator, typeGenerator);
                    controlller.GenerateCode();

                    if (_options.ClientOptions != null)
                    {
                        var client = new ClientGenerator(proto, _options.ClientOptions, serviceGenerator, typeGenerator);
                        client.GenerateCode();

                        if (_options.ApiGatewayOptions != null)
                        {
                            new ApiGatewayGenerator(proto, _options.ApiGatewayOptions, serviceGenerator, typeGenerator, client)
                            .GenerateCode();
                        }
                    }
                }
            }
        }
Example #2
0
        public ClientGenerator(ProtoFile proto, TypeGeneratorOption option, ServiceGenerator serviceGenerator, TypeGenerator typeGenerator)
            : base(proto, option)
        {
            _serviceGenerator = serviceGenerator;
            _typeGenerator    = typeGenerator;

            Namespace = option.Namespace ?? $"{proto.Option.Namespace}.Clients";
        }
Example #3
0
 public ApiGatewayGenerator(ProtoFile proto,
                            ApiGateWayGeneratorOption option,
                            ServiceGenerator serviceGenerator,
                            TypeGenerator typeGenerator,
                            ClientGenerator clientGenerator)
     : base(proto, option, serviceGenerator, typeGenerator)
 {
     _clientGenerator = clientGenerator;
 }
        public ServiceGenerator(ProtoFile proto, TypeGeneratorOption option, TypeGenerator typeGenerator) : base(proto, option)
        {
            this._typeGenerator = typeGenerator;
            Namespace           = option.Namespace ?? $"{proto.Option.Namespace}.Services";

            foreach (var item in Proto.Declarations)
            {
                if (item is ServiceDeclaration srv)
                {
                    var info = new ServiceGenInfo(srv, _option, Proto);

                    Services.Add(srv, info);
                }
            }
        }
 public WebApiControllerGenerator(ProtoFile proto, WebApiControllerGeneratorOption option,
                                  ServiceGenerator serviceGenerator, TypeGenerator typeGenerator) : base(proto, option)
 {
     _serviceGenerator = serviceGenerator;
     _typeGenerator    = typeGenerator;
 }