Beispiel #1
0
        public string GenerateInterface(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteFormat(".factory(\"{0}Client\", function($http, serviceUrl)", intr.Name);
            writer.WriteLineNoIdent(" {");
            writer.PushIdent();
            writer.WriteLine("return {");

            int methodCount = intr.Methods.Count;
            for (int i = 0; i < methodCount; i++)
            {
                writer.PushIdent();
                Method method = intr.Methods[i];
                string comma = i < methodCount - 1 ? "," : "";
                writer.Write(GenerateMethod(intr, method).Trim());
                writer.WriteLineNoIdent(comma);
                writer.WriteLine();
                writer.PopIdent();
            }
 
            writer.WriteLine("}");
            writer.PopIdent();
            writer.WriteLine("})");
            return writer.Code;
        }
Beispiel #2
0
        public string GenerateClass(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine(HEADER);
            writer.WriteLineFormat("package {0}", service.Name);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine(IMPORT);
            writer.WriteLine();
            writer.WriteLineFormat("public class {0}Client", intr.Name);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine("public var url: String = \"\";");
            writer.WriteLine(LOAD);
            writer.WriteLine();

            foreach(Method method in intr.Methods)
            {
                writer.WriteLine(GenerateMethodHeader(intr, method));
                writer.WriteLine("{"); 
                writer.PushIdent();
                writer.WriteLine(GenerateMethodBody(intr, method));
                writer.PopIdent();
                writer.WriteLine("}");
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            writer.PopIdent();
            writer.WriteLine("}");
            return writer.Code;
        }
        public string GenerateInterface(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine("define([\"dojo/request\", \"dojo/json\"], function (request, JSON) {");
            writer.PushIdent();
            writer.WriteLine("var serviceClient = {");
            writer.PushIdent();
            writer.WriteLine("urlString: '',");
            writer.WriteLine();

            int methodCount = intr.Methods.Count;
            for (int i = 0; i < methodCount; i++)
            {
                Method method = intr.Methods[i];
                string comma = i < methodCount - 1 ? "," : "";
                writer.Write(GenerateMethod(intr, method).Trim());
                writer.WriteLineNoIdent(comma);
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            writer.WriteLine("return serviceClient;");
            writer.PopIdent();
            writer.Write("});");
            return writer.Code;
        }
Beispiel #4
0
 private IProxyGenerator selectGenerator(Service service)
 {
     IProxyGenerator gen = null;
     GenOptionsDialog dlg = new GenOptionsDialog(service);
     DialogResult r = dlg.ShowDialog();
     if (r == DialogResult.OK)
     {
         gen = dlg.SelectedGenerator;
     }
     return gen;
 }
Beispiel #5
0
        public IDictionary<string, string> Generate(Service service)
        {
            IDictionary<string, string> files = new Dictionary<string, string>();
            foreach (Interface intr in service.Interfaces)
            {
                string fileName = intr.Name + ".as";
                string code = GenerateClass(service, intr);
                files[fileName] = code;
            }

            return files;
        }
Beispiel #6
0
 public static Service BuildFromServiceConf(ServiceConfig serviceConf) {
     Service svc = new Service(serviceConf.Name);
     svc.Description = serviceConf.Description;
     svc.Interfaces = new List<Interface>();
     foreach (InterfaceConfiguration iconf in serviceConf.InterfaceConfigs)
     {
         Interface intr = InterfaceBuilder.BuildFromInterfaceType(iconf.RuntimeInfo.InterfaceType);
         intr.Name = iconf.Name;
         intr.Description = iconf.Description;
         svc.Interfaces.Add(intr);
     }
     return svc;
 }
Beispiel #7
0
 private Service createService()
 {
     Service svc = new Service(runtimeConfig.ServiceConfig.Name);
     svc.Description = runtimeConfig.ServiceConfig.Description;
     svc.Interfaces = new List<Interface>();
     foreach (InterfaceConfiguration iconf in runtimeConfig.ServiceConfig.InterfaceConfigs)
     {
         Interface intr = InterfaceBuilder.BuildFromInterfaceType(iconf.RuntimeInfo.InterfaceType);
         intr.Name = iconf.Name;
         intr.Description = iconf.Description;
         svc.Interfaces.Add(intr);
     }
     return svc;
 }
Beispiel #8
0
        public IDictionary<string, string> Generate(Service service)
        {
            IDictionary<string, string> files = new Dictionary<string, string>();

            CodeWriter writer = new CodeWriter();
            writer.WriteLineFormat("angular.module(\"{0}\", [])", service.Name);
            writer.PushIdent();
            writer.WriteLine(".constant('serviceUrl', 'http://localhost:8800/Server/handler.ashx')");
            writer.WriteLine();

            foreach (Interface intr in service.Interfaces)
            {
                string code = GenerateInterface(service, intr);
                writer.WriteLine(code);
            }
            string fileName = service.Name + ".js";
            files[fileName] = writer.Code;
            return files;
        }
Beispiel #9
0
        private void initTestService()
        {
            InterfaceConfiguration iconf1 = new InterfaceConfiguration("SimpleInterface", "Simple Interface",
                new RuntimeInfo(typeof(ISimpleInterface), typeof(SimpleInterfaceImpl)));

            InterfaceConfiguration iconf2 = new InterfaceConfiguration("TestInterface", "Test Interface",
                new RuntimeInfo(typeof(ITestInterface), typeof(TestInterfaceImpl)));

            ServiceConfig sconf = new ServiceConfig("hxf_service", "HXF Service");
            sconf.InterfaceConfigs.Add(iconf1);
            sconf.InterfaceConfigs.Add(iconf2);
            

            testService = ServiceBuilder.BuildFromServiceConf(sconf);
            TreeBuilder builder = new TreeBuilder(testService);
            TreeNode rootNode = builder.Build();
            treeView.Nodes.Add(rootNode);
            edtJson.Text = testService.ToJson();
            
        }
Beispiel #10
0
 public TreeBuilder(Service service)
 {
     this.service = service;
 }
Beispiel #11
0
 public IDictionary<string, string> Generate(Service service)
 {
     return generator.Generate(service);
 }
Beispiel #12
0
        public string GenerateClientClass(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine(HEADER);
            writer.WriteLineFormat("package {0};", service.Name);
            writer.WriteLine(IMPORT);
            writer.WriteLine();
            string className = intr.Name + "Client";
            writer.WriteLineFormat("public class {0}", className);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine("private static final String SERVICE_URL = \"\";");
            writer.WriteLine("private static final int BUFFER_SIZE = 4096;");
            writer.WriteLine();
            writer.WriteLine(LOAD_METHOD);
            writer.WriteLine();
            writer.WriteLine(MAP_OBJECT_METHOD);
            writer.WriteLine();
            writer.WriteLine(CONVERT_METHOD);
            writer.WriteLine();

            foreach (Method method in intr.Methods)
            {
                writer.WriteLine(GenerateMethod(intr, method));
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            return writer.Code;
        }
Beispiel #13
0
 public GenOptionsDialog(Service schema)
 {
     InitializeComponent();
     this.schema = schema;
     lblPlatform.Text = schema.Platform;
 }