Esempio n. 1
0
        private void populateLists() {
            IProxyGenerator gen1 = new CSharpGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen1.GetName(), gen1));

            IProxyGenerator gen2 = new JavaScriptGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen2.GetName(), gen2));

            IProxyGenerator gen3 = new JavaScriptDojoAMDGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen3.GetName(), gen3));

            IProxyGenerator gen4 = new JavaGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen4.GetName(), gen4));

            IProxyGenerator gen5 = new ObjectiveCGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen5.GetName(), gen5));

            IProxyGenerator gen6 = new FlexGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen6.GetName(), gen6));

            IProxyGenerator gen7 = new AngularGenerator();
            cmbGenerator.Items.Add(new GeneratorItem(gen7.GetName(), gen7));
            
            cmbTypeMap.Items.Add(new TypeMapItem("No Type Map", null));
            ResourceManager resMan = new ResourceManager();
            foreach (TypeMap tm in resMan.GetTypeMaps())
            {
                TypeMapItem item = new TypeMapItem(tm.Name, tm);
                cmbTypeMap.Items.Add(item);
            }
            cmbTypeMap.Items.Add(new TypeMapItem("Custom", null));
        }
Esempio n. 2
0
        private void processClientCode(NameValueCollection queryString, HttpContext context)
        {
            IProxyGenerator generator = null;
            ResourceManager resMan = new ResourceManager();
            string platform = queryString["platform"];
            if (string.IsNullOrEmpty(platform))
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("No Platform is Specified");
                return;
            }
            platform = platform.ToLower();
            if (platform == "csharp")
            {
                TypeMap tm = resMan.GetTypeMap("dotnet-csharp.typemap");
                generator = new CSharpGenerator(tm);
            }
            else if (platform == "java")
            {
                TypeMap tm = resMan.GetTypeMap("dotnet-java.typemap");
                generator = new JavaGenerator(tm);
            }
            else if (platform == "js-angularjs")
            {
                generator = new AngularGenerator();
            }
            else if (platform == "js-dojo")
            {
                generator = new JavaScriptGenerator();
            }
            else if (platform == "js-dojo-amd")
            {
                generator = new JavaScriptDojoAMDGenerator();
            }
            else if (platform == "flex")
            {
                generator = new FlexGenerator();
            }
            else if (platform == "objc")
            {
                TypeMap tm = resMan.GetTypeMap("dotnet-objc.typemap");
                generator = new ObjectiveCGenerator(tm);
            }

            if (generator == null)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Unknown Platform");
                return;
            }

            string format = queryString["format"];
            format = format == null ? "zip" : format.ToLower();


            Service svc = createService();
            IDictionary<string, string> files = generator.Generate(svc);

            if (format == "zip")
            {
                byte[] buffer = ZipExporter.Export(files);
                MemoryStream ms = new MemoryStream(buffer);
                //context.Response.ContentType = "application/zip";
                context.Response.ContentType = "application/octet-stream";
                string fileName = string.Format("{0}_{1}.zip", svc.Name, platform);
                context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
                ms.CopyTo(context.Response.OutputStream);
                context.Response.OutputStream.Close();
            }
            else if (format == "json")
            {
                string s = JsonConvert.SerializeObject(files);
                context.Response.ContentType = "text/json";
                context.Response.Write(s);
            }
            else if (format == "xml")
            {

            }
            
        }