using System; using Tesses.YouTubeDownloader.ExtensionLoader; using Tesses.WebServer; using Newtonsoft.Json; using System.Threading.Tasks; namespace Tesses.YouTubeDownloader.ExampleExtension { public class ExampleExtensionClass : Extension { string efn; public bool Enabled {get {return Storage.FileExists(efn);} set{ if(value) { if(!Storage.FileExists(efn)) { Storage.WriteAllTextAsync(efn,"enabled").Wait(); } }else{ if(Storage.FileExists(efn)) { Storage.DeleteFile(efn); } } }} public bool FirstLoad() { string init=this.ExtensionStorage("init"); bool first = !this.Storage.FileExists(init); if(first) { this.Storage.WriteAllTextAsync(init,"loaded").Wait(); } return first; } public override void OnStart() { if(FirstLoad()) { Enabled=true; } this.Storage.BeforeSaveInfo += BeforeSaveInfo; efn=this.ExtensionStorage("enabled"); RouteServer svr=new RouteServer(); svr.Add("/",Index); svr.Add("/setting.cgi",Setting); } public async Task Index(ServerContext ctx) { string enabledStr = Enabled ? " checked" : ""; string index=$"