Пример #1
0
        private ReleaseVersion ReadReleaseVersion()
        {
            this.XmlReader.AssertElementStart("release");

            ReleaseVersion version = new ReleaseVersion();
            version.Id = int.Parse(this.XmlReader.GetAttribute("id"));
            version.Status = DataReader.ParseReleaseStatus(this.XmlReader.GetAttribute("status"));

            while (true)
            {
                this.XmlReader.AssertRead();

                if (this.XmlReader.IsElementEnd("release"))
                {
                    break;
                }

                if (this.XmlReader.IsElementStart("title"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.Title = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("format"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.Format = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("label"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.Label = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("catno"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.CatalogNumber = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("country"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.Country = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("released"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.ReleaseDate = this.XmlReader.ReadContentAsString();
                }
                else if (this.XmlReader.IsElementStart("thumb"))
                {
                    this.XmlReader.AssertNonEmptyElement();
                    this.XmlReader.AssertRead();
                    version.Thumb = this.XmlReader.ReadContentAsString();
                }
                else
                {
                    this.ThrowInvalidFormatException();
                }
            }

            return version;
        }
Пример #2
0
        private ReleaseVersion ReadReleaseVersion(JObject source)
        {
            ReleaseVersion version = new ReleaseVersion();
            foreach (var item in source)
            {
                var v = item.Value;

                switch (item.Key)
                {
                    case "thumb":
                        version.Thumb = v.Value<string>();
                        break;
                    case "title":
                        version.Title = v.Value<string>();
                        break;
                    case "main_release":
                        version.MainRelease = v.Value<int>();
                        break;
                    case "role":
                        version.Role = v.Value<string>();
                        break;
                    case "year":
                        version.Year = v.Value<int>();
                        break;
                    case "type":
                        version.Type = ParseReleaseVersionType(v.Value<string>());
                        break;
                    case "id":
                        version.Id = v.Value<int>();
                        break;
                    case "label":
                        version.Label = v.Value<string>();
                        break;
                    case "format":
                        version.Format = v.Value<string>();
                        break;
                    case "status":
                        version.Status = DataReader.ParseReleaseStatus(v.Value<string>());
                        break;
                    case "trackinfo":
                        version.TrackInfo = v.Value<string>();
                        break;
                    case "resource_url":
                        break;
                    default:
                        this.ThrowIfStrict("Unknown key: " + item.Key);
                        break;
                }
            }
            return version;
        }