public static ZIPFile WriteToArchive(this SolutionBuilder that) { var zip = new ZIPFile(); that.WriteTo( f => zip.Add(f.Name, f.Content) ); return(zip); }
public Application(IAbout a) { var s = new InternalSaveActionSprite(); s.AttachSpriteTo(a.Content); s.WebService = new ApplicationWebService(); var pp = new ProjectNameInput(); pp.AttachControlTo(a.Content); var Files = new IHTMLDiv().AttachTo(a.Content); s.WhenReady( i => { Action Update = delegate { var sln = new SolutionBuilder { Name = pp.ProjectName.Text }; i.FileName = sln.Name + ".zip"; i.Clear(); Files.Clear(); sln.WriteTo( (SolutionFile f) => { new IHTMLPre { innerText = f.Name }.AttachTo(Files); i.Add(f.Name, f.Content); } ); }; pp.UpdateButton.TextChanged += delegate { }; pp.UpdateButton.Click += delegate { Update(); }; Update(); } ); }
// to be used only on .net public static void WriteToConsole(this SolutionBuilder that) { var Lookup = new Dictionary <SolutionFileTextFragment, ConsoleColor> { { SolutionFileTextFragment.Comment, ConsoleColor.Green }, { SolutionFileTextFragment.Keyword, ConsoleColor.Cyan }, { SolutionFileTextFragment.None, ConsoleColor.Gray }, { SolutionFileTextFragment.String, ConsoleColor.Red }, { SolutionFileTextFragment.XMLAttributeName, ConsoleColor.Red }, { SolutionFileTextFragment.XMLAttributeValue, ConsoleColor.Blue }, { SolutionFileTextFragment.XMLComment, ConsoleColor.Green }, { SolutionFileTextFragment.XMLKeyword, ConsoleColor.Blue }, { SolutionFileTextFragment.Type, ConsoleColor.Yellow }, }; var zip = new ZIPFile(); that.WriteTo( SolutionFile => { Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" " + SolutionFile.Name + " "); //if (SolutionFile.WriteHistory.Count > 1) foreach (var item in SolutionFile.WriteHistory) { if (item.Fragment == SolutionFileTextFragment.Indent) { Console.BackgroundColor = ConsoleColor.DarkGray; } else if (item.Fragment == SolutionFileTextFragment.XMLText) { Console.BackgroundColor = ConsoleColor.DarkCyan; } else { Console.BackgroundColor = ConsoleColor.Black; } if (Lookup.ContainsKey(item.Fragment)) { Console.ForegroundColor = Lookup[item.Fragment]; } else { Console.ForegroundColor = ConsoleColor.Gray; } Console.Write(item.Text); } Console.WriteLine(); zip.Add(SolutionFile.Name, SolutionFile.Content); } ); var Output = new FileInfo(that.Name).FullName + ".zip"; Console.WriteLine(Output); File.WriteAllBytes(Output, zip.ToBytes()); }