private void CreateProperty(JSDoc doc, StreamWriter writer) { foreach (var prop in doc.Properties) { writer.WriteLine("\t\t" + JSDocHelper.GetCSharpType(prop.DataTypes).PadRight(10) + " " + prop.Name + ";"); } }
private void ProcessPage(JSDoc doc) { StreamWriter writer = new StreamWriter(FileName(doc.FilePath)); //writer.WriteLine(GenerateStart(doc)); //CreateProperty(doc, writer); CreateFunctions(doc, writer); writer.Close(); }
private void CreateFunctions(JSDoc doc, StreamWriter writer) { foreach (var func in doc.Functions) { if (func.ReturnTypes.Count == 0) { writer.Write(voidFunction(func, GetModuleName(doc))); } else { writer.Write(nonVoidFunction(func, GetModuleName(doc))); } } }
private string GetModuleName(JSDoc doc) { string mod = doc.ModuleName; if (mod == null) { return("TestClass"); } if (mod.Length <= 0) { mod = "TestClass"; } return(mod); }
private string GenerateStart(JSDoc doc) { string mod = GetModuleName(doc); StringBuilder builder = new StringBuilder(""); builder.Append("using System;" + EOL); builder.Append("using Microsoft.JSInterop;" + EOL); builder.Append("using System.Collections.Generic;" + EOL); builder.Append("namespace Test" + EOL); builder.Append("{" + EOL); builder.Append(TAB + "public class " + mod + EOL); builder.Append(TAB + "{" + EOL); builder.Append(TAB + TAB + "public IJSRuntime Runtime { get; set; }" + EOL + EOL); builder.Append(TAB + TAB + "public " + mod + "(IJSRuntime runtime)" + EOL); builder.Append(TAB + TAB + "{" + EOL); builder.Append(TAB + TAB + TAB + "Runtime=runtime;" + EOL); builder.Append(TAB + TAB + "}"); return(builder.ToString()); }
private JSDoc ReadFile(string file) { JSDoc docFile = new JSDoc(); List <Function> funcList = new List <Function>(); List <Property> propList = new List <Property>(); //extract comments from file StreamReader reader = new StreamReader(file); string text = reader.ReadToEnd(); reader.Close(); string[] data = ParseContent(text); ///parse each comment to get functions info foreach (string d in data) { Function func = ParseFunctions(d); if (!string.IsNullOrWhiteSpace(func.FuncName)) { funcList.Add(func); } //add prop Property p = ParseProperty(d); if (!string.IsNullOrWhiteSpace(p.Name)) { propList.Add(p); } ///one file should only one moudule docFile.ModuleName = GetMoudule(d); } docFile.Functions = funcList; docFile.FilePath = file; docFile.Properties = propList; return(docFile); }