Beispiel #1
0
        protected override void ParseRecord(string record, int appVersion, TryConvertOldRecord converter)
        {
            float parsedRecord;

            if ((converter == null) || (converter(record, appVersion, out parsedRecord) == false))
            {
                if (float.TryParse(record, out parsedRecord) == true)
                {
                    Record = parsedRecord;
                }
                else
                {
                    throw new ArgumentException("Could not parse the record from: " + record);
                }
            }
        }
        public IRecord(string pastRecord, int appVersion, TryConvertOldRecord converter)
        {
            if (string.IsNullOrEmpty(pastRecord) == true)
            {
                throw new ArgumentNullException("pastRecord must be provided");
            }

            // Split the information
            string[] info = pastRecord.Split(Divider);
            if ((info == null) || (info.Length <= 0))
            {
                throw new ArgumentException("Could not parse pastRecord: " + pastRecord);
            }

            // Go through each split item
            byte index = 0;

            if (appVersion < AddLanguageSettings.AppVersion)
            {
                // Disregard the app version from the older records
                ++index;
            }

            // Grab score
            ParseRecord(info[index], appVersion, converter);

            // Grab name
            ++index;
            Name = info[index];

            // Grab time
            long ticks;

            ++index;
            if (long.TryParse(info[index], out ticks) == true)
            {
                dateAchievedUtc = new DateTime(ticks);
            }
            else
            {
                throw new ArgumentException("Could not parse the date from pastRecord: " + pastRecord);
            }
        }
 protected abstract void ParseRecord(string record, int appVersion, TryConvertOldRecord converter);
Beispiel #4
0
 public FloatRecord(string pastRecord, int appVersion, TryConvertOldRecord converter = null) : base(pastRecord, appVersion, converter)
 {
 }