Ejemplo n.º 1
0
        protected override void LoadData(JObject json) {
            Name = json.GetStringValueOnly("skinname");
            LoadCountry(json);
            LoadSkinRelated(json);

            if (string.IsNullOrWhiteSpace(Name)) {
                // more than usual case
                // AddError(AcErrorType.Data_ObjectNameIsMissing);
            }

            // LoadTags(json);
            // LoadDescription(json);
            // LoadYear(json);
            // LoadVersionInfo(json);
        }
Ejemplo n.º 2
0
        protected override void LoadData(JObject json) {
            base.LoadData(json);

            Brand = json.GetStringValueOnly("brand");
            if (string.IsNullOrEmpty(Brand)) {
                AddError(AcErrorType.Data_CarBrandIsMissing);
            }

            if (Country == null && Brand != null) {
                Country = AcStringValues.CountryFromBrand(Brand);
            }

            CarClass = json.GetStringValueOnly("class");
            ParentId = json.GetStringValueOnly("parent");

            var specsObj = json["specs"] as JObject;
            SpecsBhp = specsObj?.GetStringValueOnly("bhp");
            SpecsTorque = specsObj?.GetStringValueOnly("torque");
            SpecsWeight = specsObj?.GetStringValueOnly("weight");
            SpecsTopSpeed = specsObj?.GetStringValueOnly("topspeed");
            SpecsAcceleration = specsObj?.GetStringValueOnly("acceleration");
            SpecsPwRatio = specsObj?.GetStringValueOnly("pwratio");

            SpecsTorqueCurve = new GraphData(json["torqueCurve"] as JArray);
            SpecsPowerCurve = new GraphData(json["powerCurve"] as JArray);
        }
Ejemplo n.º 3
0
 private void LoadSkinRelated(JObject json) {
     DriverName = json.GetStringValueOnly("drivername")?.Trim();
     Team = json.GetStringValueOnly("team")?.Trim();
     SkinNumber = json.GetStringValueOnly("number")?.Trim();
     Priority = json.GetIntValueOnly("priority");
 }
Ejemplo n.º 4
0
        protected void LoadVersionInfo(JObject json) {
            Author = json.GetStringValueOnly("author")?.Trim() ?? (TestIfKunos() ? AuthorKunos : null);
            Version = json.GetStringValueOnly("version")?.Trim();
            Url = json.GetStringValueOnly("url")?.Trim();

            if (Version == null && Name != null) {
                string name;
                Version = AcStringValues.GetVersionFromName(Name, out name);
                if (Version != null) {
                    Name = name;
                }
            }
        }
Ejemplo n.º 5
0
 protected void LoadDescription(JObject json) {
     Description = AcStringValues.DecodeDescription(json.GetStringValueOnly("description"));
 }
Ejemplo n.º 6
0
 protected void LoadCountry(JObject json) {
     var value = json.GetStringValueOnly("country")?.Trim();
     Country = value != null ? AcStringValues.CountryFromTag(value) ?? value :
         Tags.Select(AcStringValues.CountryFromTag).FirstOrDefault(x => x != null);
 }
Ejemplo n.º 7
0
        protected virtual void LoadData(JObject json) {
            Name = json.GetStringValueOnly("name")?.Trim();
            if (string.IsNullOrEmpty(Name)) {
                AddError(AcErrorType.Data_ObjectNameIsMissing);
            }

            LoadTags(json);
            LoadCountry(json);
            LoadDescription(json);
            LoadYear(json);
            LoadVersionInfo(json);
        }
Ejemplo n.º 8
0
        protected override void LoadData(JObject json) {
            base.LoadData(json);

            if (Version == null && Description != null) {
                string description;
                Version = AcStringValues.GetVersionFromName(Description, out description);
                if (Version != null) {
                    Description = description;
                }
            }

            City = json.GetStringValueOnly("city");
            GeoTags = json.GetGeoTagsValueOnly("geotags");

            if (Country == null) {
                foreach (var country in Tags.Select(AcStringValues.CountryFromTag).Where(x => x != null)) {
                    Country = country;
                    break;
                }
            }

            SpecsLength = json.GetStringValueOnly("length");
            SpecsWidth = json.GetStringValueOnly("width");
            SpecsPitboxes = json.GetStringValueOnly("pitboxes");
        }