Exemplo n.º 1
0
 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 + ";");
     }
 }
Exemplo n.º 2
0
        private void ProcessPage(JSDoc doc)
        {
            StreamWriter writer = new StreamWriter(FileName(doc.FilePath));

            //writer.WriteLine(GenerateStart(doc));
            //CreateProperty(doc, writer);
            CreateFunctions(doc, writer);
            writer.Close();
        }
Exemplo n.º 3
0
 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)));
         }
     }
 }
Exemplo n.º 4
0
        private string GetModuleName(JSDoc doc)
        {
            string mod = doc.ModuleName;

            if (mod == null)
            {
                return("TestClass");
            }

            if (mod.Length <= 0)
            {
                mod = "TestClass";
            }

            return(mod);
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        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);
        }