private AddCode ( string num, string name, ContentType type ) : void | ||
num | string | |
name | string | |
type | ContentType | |
return | void |
public static ContentCodeBag ParseCodes(byte[] buffer) { ContentCodeBag bag = new ContentCodeBag (); // add some codes to bootstrap us bag.AddCode ("mccr", "dmap.contentcodesresponse", ContentType.Container); bag.AddCode ("mdcl", "dmap.dictionary", ContentType.Container); bag.AddCode ("mcnm", "dmap.contentcodesnumber", ContentType.Long); bag.AddCode ("mcna", "dmap.contentcodesname", ContentType.String); bag.AddCode ("mcty", "dmap.contentcodestype", ContentType.Short); bag.AddCode ("mstt", "dmap.status", ContentType.Long); // some photo-specific codes bag.AddCode ("ppro", "dpap.protocolversion", ContentType.Long); bag.AddCode ("pret", "dpap.blah", ContentType.Container); ContentNode node = ContentParser.Parse (bag, buffer); foreach (ContentNode dictNode in (node.Value as ContentNode[])) { if (dictNode.Name != "dmap.dictionary") { continue; } ContentCode code = new ContentCode (); foreach (ContentNode item in (dictNode.Value as ContentNode[])) { switch (item.Name) { case "dmap.contentcodesnumber": code.Number = (int) item.Value; break; case "dmap.contentcodesname": code.Name = (string) item.Value; break; case "dmap.contentcodestype": code.Type = (ContentType) Enum.ToObject (typeof (ContentType), (short) item.Value); break; } } bag.codes[code.Number] = code; } return bag; }
public static ContentCodeBag ParseCodes(byte[] buffer) { ContentCodeBag bag = new ContentCodeBag(); // add some codes to bootstrap us bag.AddCode("mccr", "dmap.contentcodesresponse", ContentType.Container); bag.AddCode("mdcl", "dmap.dictionary", ContentType.Container); bag.AddCode("mcnm", "dmap.contentcodesnumber", ContentType.Long); bag.AddCode("mcna", "dmap.contentcodesname", ContentType.String); bag.AddCode("mcty", "dmap.contentcodestype", ContentType.Short); bag.AddCode("mstt", "dmap.status", ContentType.Long); // some photo-specific codes bag.AddCode("ppro", "dpap.protocolversion", ContentType.Long); bag.AddCode("pret", "dpap.blah", ContentType.Container); bag.AddCode("cmst", "tune.root", ContentType.Container); bag.AddCode("cmsr", "tune.rev", ContentType.Long); bag.AddCode("caps", "tune.status", ContentType.Char); bag.AddCode("cash", "tune.shuffle", ContentType.Char); bag.AddCode("carp", "tune.repeat", ContentType.Char); bag.AddCode("cavc", "tune.xxx", ContentType.Char); bag.AddCode("caas", "tune.xxx", ContentType.Long); bag.AddCode("caar", "tune.xxx", ContentType.Long); bag.AddCode("canp", "tune.xxx", ContentType.String); bag.AddCode("cann", "tune.track", ContentType.String); bag.AddCode("cana", "tune.artist", ContentType.String); bag.AddCode("canl", "tune.album", ContentType.String); bag.AddCode("cang", "tune.xxx", ContentType.Short); bag.AddCode("cmmk", "tune.xxx", ContentType.Long); bag.AddCode("cant", "tune.remaining", ContentType.Long); bag.AddCode("cast", "tune.total", ContentType.Long); bag.AddCode("cmgt", "vol.root", ContentType.Container); bag.AddCode("cmvo", "tune.volume", ContentType.Long); bag.AddCode("ceGS", "tune.xxx", ContentType.String); bag.AddCode("mdbk", "db.xxx", ContentType.Long); bag.AddCode("aeIM", "db.xxx", ContentType.LongLong); bag.AddCode("cacr", "cue.xxx", ContentType.Container); ContentNode node = ContentParser.Parse(bag, buffer); foreach (ContentNode dictNode in (node.Value as ContentNode[])) { if (dictNode.Name != "dmap.dictionary") { continue; } ContentCode code = new ContentCode(); foreach (ContentNode item in (dictNode.Value as ContentNode[])) { switch (item.Name) { case "dmap.contentcodesnumber": code.Number = (int)item.Value; break; case "dmap.contentcodesname": code.Name = (string)item.Value; break; case "dmap.contentcodestype": code.Type = (ContentType)Enum.ToObject(typeof(ContentType), (short)item.Value); break; } } bag.codes[code.Number] = code; } return bag; }
public static ContentCodeBag ParseCodes(byte[] buffer) { ContentCodeBag bag = new ContentCodeBag(); // add some codes to bootstrap us bag.AddCode("mccr", "dmap.contentcodesresponse", ContentType.Container); bag.AddCode("mdcl", "dmap.dictionary", ContentType.Container); bag.AddCode("mcnm", "dmap.contentcodesnumber", ContentType.Long); bag.AddCode("mcna", "dmap.contentcodesname", ContentType.String); bag.AddCode("mcty", "dmap.contentcodestype", ContentType.Short); bag.AddCode("mstt", "dmap.status", ContentType.Long); // some photo-specific codes bag.AddCode("ppro", "dpap.protocolversion", ContentType.Long); bag.AddCode("pret", "dpap.blah", ContentType.Container); // Artwork bag.AddCode("asac", "daap.songartworkcount", ContentType.Short); bag.AddCode("ased", "daap.songextradata", ContentType.Short); bag.AddCode("ated", "daap.supportsextradata", ContentType.Short); ContentNode node = ContentParser.Parse(bag, buffer); foreach (ContentNode dictNode in (node.Value as ContentNode[])) { if (dictNode.Name != "dmap.dictionary") { continue; } ContentCode code = new ContentCode(); foreach (ContentNode item in (dictNode.Value as ContentNode[])) { switch (item.Name) { case "dmap.contentcodesnumber": code.Number = (int)item.Value; break; case "dmap.contentcodesname": code.Name = (string)item.Value; break; case "dmap.contentcodestype": code.Type = (ContentType)Enum.ToObject(typeof(ContentType), (short)item.Value); break; } } bag.codes[code.Number] = code; } return(bag); }