Example #1
0
 private void buildParametersNode(Method method, TreeNode parentNode)
 {
     foreach (Parameter p in method.Parameters)
     {
         TreeNode parameterNode = new TreeNode(p.Name + " [" + p.Type + "]", 4, 4);
         parameterNode.Tag = p;
         parentNode.Nodes.Add(parameterNode);
     }
 }
Example #2
0
 public string GenerateMethod(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     writer.Write(generateMethodHeader(intr, method));
     writer.WriteLine(" {");
     writer.PushIdent();
     writer.WriteLine(generateMethodBody(intr, method));
     writer.PopIdent();
     writer.Write("}");
     return writer.Code;
 }
Example #3
0
        private string generateMethodHeader(Interface intr, Method method)
        {
            StringBuilder sb = new StringBuilder();
            List<string> paramDefs = new List<string>();
            string methodName = method.Name;
            foreach (Parameter p in method.Parameters)
            {
                string def = p.Name;
                paramDefs.Add(def);
            }
            paramDefs.Add("successFunction");
            paramDefs.Add("failFunction");

            string paramDefString = StringUtils.GenerateCommaSeparatedString(paramDefs, "", "");
            string header = string.Format("{0}: function({1})", methodName, paramDefString.Trim());
            return header;
        }
 private string generateMethodBody(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     List<string> paramDefs = new List<string>();
     string methodName = method.Name;
     foreach (Parameter p in method.Parameters)
     {
         string def = string.Format("'{0}': {0}", p.Name);
         paramDefs.Add(def);
     }
     string paramDefString = "{" + StringUtils.GenerateCommaSeparatedString(paramDefs, "", "") + "}";
     string dataObjectDef = string.Format("var data = {{ 'interface': '{0}', 'method': '{1}', 'parameters': {2} }}", intr.Name, method.Name, paramDefString);
     writer.WriteLine(dataObjectDef);
     writer.WriteLine("var jsonData = JSON.stringify(data);");
     writer.WriteLine("request.post(this.urlString, { data: jsonData, handleAs: 'json' }).then(successFunction, failFunction);");
     return writer.Code;
 }
Example #5
0
 private static void createMethods(Interface intr, Type interfaceType)
 {
     intr.Methods = new List<Method>();
     foreach (MethodInfo mi in interfaceType.GetMethods())
     {
         Method m = new Method();
         m.Name = mi.Name;
         m.Parameters = new List<Parameter>();
         foreach (ParameterInfo pi in mi.GetParameters())
         {
             Parameter p = new Parameter();
             p.Name = pi.Name;
             p.Type = GetTypeName(pi.ParameterType);
             m.Parameters.Add(p);
         }
         m.ReturnType = GetTypeName(mi.ReturnType);
         intr.Methods.Add(m);
     }
 }
Example #6
0
 public string GenerateMethodHeader(Interface intr, Method method)
 {
     List<string> paramDefs = new List<string>();
     string methodName = method.Name;
     foreach (Parameter p in method.Parameters)
     {
         string type = TypeMap == null ? p.Type : TypeMap.MapDataType(p.Type);
         string def = string.Format("{0}: {1}", p.Name, type);
         paramDefs.Add(def);
     }
     paramDefs.Add("completeFunction: Function");
     string paramDefString = StringUtils.GenerateCommaSeparatedString(paramDefs, "", "");
     string methodHeader = string.Format("public function {0} ({1}) : {2}", methodName, paramDefString, "void");
     return methodHeader;
 }
Example #7
0
 public string GenerateMethodBody(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLine("var o: Object = new Object();");
     writer.WriteLine("var p: Object = new Object();");
     writer.WriteLineFormat("o[\"interface\"] = \"{0}\"", intr.Name);
     writer.WriteLineFormat("o[\"method\"] = \"{0}\"", method.Name);
     foreach (Parameter p in method.Parameters)
     {
         writer.WriteLineFormat("p[\"{0}\"]={0};", p.Name);
     }
     writer.WriteLine("o[\"parameters\"] = p;");
     writer.WriteLine("var data: String = JSON.stringify(o);");
     writer.WriteLine("load(data, completeFunction);");
     return writer.Code;
 }
Example #8
0
 private string generateMethodBody(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLine("JSONObject result = null;");
     writer.WriteLine("JSONObject o = new JSONObject();");
     writer.WriteLine("JSONObject p = new JSONObject();");
     writer.WriteLineFormat("o.put(\"interface\", \"{0}\");", intr.Name);
     writer.WriteLineFormat("o.put(\"method\", \"{0}\");", method.Name);
     foreach (Parameter p in method.Parameters)
     {
         writer.WriteLineFormat("p.put(\"{0}\",mapObject({0}));", p.Name);
     }
     writer.WriteLineFormat("o.put(\"parameters\", p);");
     writer.WriteLine(@"String s = o.toString();");
     writer.WriteLine(@"String r = load(s);");
     writer.WriteLine(@"result = new JSONObject(r);");
     writer.WriteLine(@"return result;");
     return writer.Code;
 }
Example #9
0
 private string generateMethodHeader(Interface intr, Method method)
 {
     StringBuilder sb = new StringBuilder();
     List<string> paramDefs = new List<string>();
     string methodName = method.Name;
     foreach (Parameter p in method.Parameters)
     {
         string type = TypeMap == null ? p.Type : TypeMap.MapDataType(p.Type);
         string def = string.Format("{0} {1}", type, p.Name);
         paramDefs.Add(def);
     }
     string paramDefString = StringUtils.GenerateCommaSeparatedString(paramDefs, "", "");
     string returnType = "JSONObject";
     string header = string.Format("public {0} {1}({2}) throws Exception", returnType, methodName, paramDefString.Trim());
     return header;
 }
Example #10
0
 private string generateMethodBody(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     List<string> paramDefs = new List<string>();
     string methodName = method.Name;
     foreach (Parameter p in method.Parameters)
     {
         string def = string.Format("'{0}': {0}", p.Name);
         paramDefs.Add(def);
     }
     string paramDefString = "{" + StringUtils.GenerateCommaSeparatedString(paramDefs, "", "") + "}";
     string dataObjectDef = string.Format("var data = {{ 'interface': '{0}', 'method': '{1}', 'parameters': {2} }};", intr.Name, method.Name, paramDefString);
     writer.WriteLine(dataObjectDef);
     writer.WriteLine(CALL_DEF);
     return writer.Code;
 }