Exemple #1
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);
        }
 protected override string GuessCountry()
 {
     return(base.GuessCountry() ?? (Target.Brand != null ? AcStringValues.CountryFromBrand(Target.Brand) : null));
 }