using OpenMetaverse.ImportExport.Collada14; using RestSharp.Extensions; using SecondBotEvents.Services; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Reflection; using System.Resources; using System.Security.Policy; using System.Text; using System.Threading.Tasks; using static log4net.Appender.RollingFileAppender; namespace SecondBotEvents { public class WikiMake { protected SimpleIO IO = new(); protected string version = ""; protected string htmltemplate = ""; public WikiMake() { IO.ChangeRoot("Static"); htmltemplate = IO.ReadFile("template.html"); version = AssemblyInfo.GetGitHash(); LogFormater.Info("Creating wiki files"); IO.ChangeRoot("wiki"); makehome(); } protected void makehome() { Dictionary commandmodules = http_commands_helper.getCommandModules(); string content = "
"; foreach (KeyValuePair entry in commandmodules) { Type endpointtype = entry.Value; string namespaceworker = entry.Key.ToLower(); string url = namespaceworker + ".html"; int commandcount = 0; foreach (MethodInfo M in endpointtype.GetMethods()) { foreach (CustomAttributeData At in M.CustomAttributes) { if (At.AttributeType.Name == "About") { commandcount++; break; } } } string about = entry.Value.GetAttribute().classinfo; string card = "
" + "
" + "
" + namespaceworker.FirstCharToUpper() + "
" + "

" + about.Split("" + "View " + commandcount.ToString() + " commands" + "

" + "
"; content = content + card; makecommandlist(endpointtype, namespaceworker, about); } makefile("index", content, "Index"); } protected void makecommandlist(Type endpoint, string namespaceworker, string aboutnamespace) { string content = "
<- Back to command sections
" + "

"+namespaceworker.FirstCharToUpper()+"

"+ aboutnamespace + "

" +"
"; content = content + ""; content = content + ""; foreach (MethodInfo M in endpoint.GetMethods()) { bool isCallable = false; string about = ""; foreach (CustomAttributeData At in M.CustomAttributes) { if (At.AttributeType.Name == "About") { about = M.GetAttribute().about; isCallable = true; break; } } if(isCallable == false) { continue; } string url = "command" + M.Name.ToLower() + ".html"; content = content + ""; content = content + ""; content = content + ""; makecommandfile(namespaceworker, M, about); } content = content + "
CommandAbout
" + M.Name + "" + about + "
"; makefile(namespaceworker, content, "Command list for "+ namespaceworker.FirstCharToUpper()); } protected void makecommandfile(string namespaceworker, MethodInfo method, string methodabout) { string content = "
<- Back to "+namespaceworker.FirstCharToUpper()+"
" + "

" + method.Name + "

" + methodabout + "

" + "
"; Dictionary hints = []; foreach (ArgHints At in method.GetCustomAttributes()) { hints.Add(At.name, At.about); } if (method.GetParameters().Length > 0) { content = content + "
Args
"; content = content + ""; content = content + ""; foreach (ParameterInfo pram in method.GetParameters()) { content = content + ""; content = content + ""; string hinttext = ""; if (hints.ContainsKey(pram.Name) == true) { hinttext = hints[pram.Name]; } content = content + ""; } content = content + "
NameHint
" + pram.Name + "" + hinttext + "
"; } content = content + "
Return hints
    "; foreach (ReturnHints At in method.GetCustomAttributes()) { content = content + "
  • ☑ "+At.hint+"
  • "; } foreach (ReturnHintsFailure At in method.GetCustomAttributes()) { content = content + "
  • ❌ "+ At.hint+"
  • "; } content = content + "
"; makefile("command"+method.Name.ToLower(), content, "Command info for " + method.Name); } protected void makefile(string file, string content, string title) { string pagecontent = htmltemplate; pagecontent = pagecontent.Replace("[[PAGETITLE]]", "Secondbot [Events] command wiki / "+title); pagecontent = pagecontent.Replace("[[BUILDVERSION]]", version); pagecontent = pagecontent.Replace("[[BUILDDATE]]", "Wiki created:"+DateTime.Now.ToString("dd/MM/yyyy")); pagecontent = pagecontent.Replace("[[CONTENT]]", content); IO.WriteFile(file+".html", pagecontent); } } }