public bool ForeachChannel (Channel channel) { /* These are handled by the "system_packages" section */ if (channel.IsSystem) return true; channel.ToXml (this.writer); return true; }
public bool ForeachChannelCb (Channel channel) { this.list.Add (channel); return true; }
public static void ToXml (Channel[] channels, string filename) { System.IO.Stream s = System.IO.File.Open (filename, System.IO.FileMode.OpenOrCreate); Channel.ToXml (channels, s); s.Close (); }
private static int FromXml (System.Xml.XmlTextReader reader, ChannelDelegate callback) { reader.MoveToContent (); reader.ReadStartElement ("channellist"); int counter = 0; while (reader.Read ()) { if (reader.LocalName != "channel") continue; if (!reader.HasAttributes) { Console.WriteLine ("channel doesn't have attributes, skipping"); continue; } Channel c = new Channel (reader["bid"], reader["name"], reader["alias"], reader["description"]); c.LegacyId = reader["id"]; string distros = reader["distro_target"]; if (distros != null) { foreach (string d in distros.Split (new Char[] {':'})) c.AddDistroTarget (d); } ChannelType type = ChannelType.Unknown; string type_str = reader["type"]; if (type_str != null) { switch (type_str) { case "helix": type = ChannelType.Helix; break; case "debian": type = ChannelType.Debian; break; case "aptrpm": type = ChannelType.Aptrpm; break; case "yum": type = ChannelType.Yum; break; default: break; } } c.SetType (type); int subd_priority = 0; int unsubd_priority = 0; string priority = reader["priority"]; if (priority != null) subd_priority = Channel.PriorityParse (priority); priority = reader["priority_when_unsubscribed"]; if (priority != null) unsubd_priority = Channel.PriorityParse (priority); c.SetPriorities (subd_priority, unsubd_priority); c.Path = reader["path"]; c.FilePath = reader["file_path"]; c.IconFile = reader["icon"]; c.PkginfoFile = reader["pkginfo_file"]; string compressed = reader["pkginfo_compressed"]; if (compressed != null && compressed == "1") c.PkginfoFileCompressed = true; counter++; if (!callback (c)) break; } return counter; }
public static void ToXml (Channel[] channels, System.IO.Stream stream) { System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter (stream, null); writer.WriteStartDocument (); writer.WriteStartElement ("channellist"); foreach (Channel c in channels) c.ToXml (writer); writer.WriteEndElement (); writer.WriteEndDocument (); writer.Close (); }