Exemplo n.º 1
0
        public void Deserialize_V1(Stream stream, DataVersion version)
        {
            Byte[] intBuffer = new Byte[sizeof(UInt32)];
            BaseCadenceTarget.IConcreteCadenceTarget.CadenceTargetType type;

            stream.Read(intBuffer, 0, sizeof(UInt32));
            type = (BaseCadenceTarget.IConcreteCadenceTarget.CadenceTargetType)BitConverter.ToUInt32(intBuffer, 0);

            switch (type)
            {
                case BaseCadenceTarget.IConcreteCadenceTarget.CadenceTargetType.ZoneST:
                    {
                        m_ConcreteTarget = new CadenceZoneSTTarget(stream, version, this);
                        break;
                    }
                case BaseCadenceTarget.IConcreteCadenceTarget.CadenceTargetType.Range:
                    {
                        m_ConcreteTarget = new CadenceRangeTarget(stream, version, this);
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        break;
                    }
            }
        }
        public new void Deserialize_V0(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(IRepeatDuration), stream, version);

            m_RepetitionCount.Deserialize(stream, version);
        }
Exemplo n.º 3
0
        public void Deserialize_V1(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(BasePowerTarget.IConcretePowerTarget), stream, version);

            IZoneCategory zones = Options.Instance.PowerZoneCategory;

            // RefId
            GarminFitnessString categoryRefID = new GarminFitnessString();
            categoryRefID.Deserialize(stream, version);

            // Zone index
            GarminFitnessInt32Range zoneIndex = new GarminFitnessInt32Range(0);
            zoneIndex.Deserialize(stream, version);

            if (categoryRefID == zones.ReferenceId && zoneIndex < zones.Zones.Count)
            {
                Zone = zones.Zones[zoneIndex];
            }
            else
            {
                Debug.Assert(zones.Zones.Count > 0);
                Zone = zones.Zones[0];

                // We can't find saved zone, force dirty
                IsDirty = true;
            }
        }
Exemplo n.º 4
0
        public void Deserialize_V0(Stream stream, DataVersion version)
        {
            byte[] dateBuffer = new byte[sizeof(long)];

            stream.Read(dateBuffer, 0, sizeof(long));
            Value = new DateTime(BitConverter.ToInt64(dateBuffer, 0));
        }
Exemplo n.º 5
0
        public void Deserialize_V0(Stream stream, DataVersion version)
        {
            byte[] guidBuffer = new byte[16];

            stream.Read(guidBuffer, 0, 16);
            Value = new Guid(guidBuffer);
        }
        public new void Deserialize_V0(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(BaseHeartRateTarget.IConcreteHeartRateTarget), stream, version);

            m_Zone.Deserialize(stream, version);
        }
        protected void Deserialize(Type forcedType, Stream stream, DataVersion version)
        {
            MethodInfo deserializeMethod = GetLatestDeserializeMethod(forcedType, version);
            Debug.Assert(deserializeMethod != null);

            deserializeMethod.Invoke(this, new object[] { stream, version });
        }
        private MethodInfo GetLatestDeserializeMethod(Type forcedType, DataVersion version)
        {
            int bestVersionNumber = -1;
            MethodInfo deserializeMethod = null;
            MethodInfo[] methods = forcedType.GetMethods();

            for (int i = 0; i < methods.Length; ++i)
            {
                MethodInfo currentMethod = methods[i];

                if (currentMethod.Name.StartsWith(Constants.DeserializeMethodNamePrefix) &&
                    currentMethod.DeclaringType.FullName == forcedType.FullName)
                {
                    Byte currentMethodVersionNumber = 0;

                    try
                    {
                        currentMethodVersionNumber = Byte.Parse(currentMethod.Name.Substring(Constants.DeserializeMethodNamePrefix.Length));
                    }
                    catch
                    {
                        // Too big version for Byte?????
                        Debug.Assert(false);
                    }

                    if (currentMethodVersionNumber > bestVersionNumber && currentMethodVersionNumber <= version.VersionNumber)
                    {
                        deserializeMethod = currentMethod;
                        bestVersionNumber = currentMethodVersionNumber;
                    }
                }
            }

            return deserializeMethod;
        }
Exemplo n.º 9
0
        public new void Deserialize_V0(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(IDuration), stream, version);

            m_CaloriesToSpend.Deserialize(stream, version);
        }
Exemplo n.º 10
0
        public void Deserialize_V0(Stream stream, DataVersion version)
        {
            byte[] boolBuffer = new byte[sizeof(bool)];

            stream.Read(boolBuffer, 0, sizeof(bool));
            Value = BitConverter.ToBoolean(boolBuffer, 0);
        }
        public void Deserialize_V0(Stream stream, DataVersion version)
        {
            Byte[] buffer = new Byte[1];

            stream.Read(buffer, 0, 1);
            Value = (SByte)buffer[0];
        }
Exemplo n.º 12
0
        public void Deserialize(Stream stream, DataVersion version)
        {
            MethodInfo deserializeMethod = GetLatestDeserializeMethod(this.GetType(), version);

            if (deserializeMethod != null)
            {
                deserializeMethod.Invoke(this, new object[] { stream, version });
            }
        }
Exemplo n.º 13
0
        public Workout(Stream stream, DataVersion version)
        {
            CreateStepsList();

            Deserialize(stream, version);

            WorkoutChanged += new WorkoutChangedEventHandler(OnWorkoutChanged);

            UpdateSplitsCache();
        }
Exemplo n.º 14
0
        public WorkoutLinkStep(Stream stream, DataVersion version, Workout parent)
            : base(StepType.Link, parent)
        {
            Deserialize(stream, version);

            // Make sure we found the linked workout, it is possible we are copy-pasting
            //  an unavailable one, in which case this step is temporary and will be disposed
            if (LinkedWorkout != null)
            {
                Initialize();
            }
        }
Exemplo n.º 15
0
        public void Deserialize_V0(Stream stream, DataVersion version)
        {
            byte[] intBuffer = new byte[sizeof(Int32)];
            byte[] stringBuffer;
            Int32 stringLength;

            stream.Read(intBuffer, 0, sizeof(Int32));
            stringLength = BitConverter.ToInt32(intBuffer, 0);
            stringBuffer = new byte[stringLength];
            stream.Read(stringBuffer, 0, stringLength);
            Value = Encoding.UTF8.GetString(stringBuffer);
        }
Exemplo n.º 16
0
        public static ITarget Create(ITarget.TargetType type, Stream stream, DataVersion version, RegularStep parent)
        {
            ITarget newTarget;

            switch (type)
            {
                case ITarget.TargetType.Null:
                    {
                        newTarget = new NullTarget(stream, version, parent);
                        break;
                    }
                case ITarget.TargetType.Speed:
                    {
                        newTarget = new BaseSpeedTarget(stream, version, parent);
                        break;
                    }
                case ITarget.TargetType.HeartRate:
                    {
                        newTarget = new BaseHeartRateTarget(stream, version, parent);
                        break;
                    }
                case ITarget.TargetType.Cadence:
                    {
                        newTarget = new BaseCadenceTarget(stream, version, parent);
                        break;
                    }
                case ITarget.TargetType.Power:
                    {
                        newTarget = new BasePowerTarget(stream, version, parent);
                        break;
                    }
                default:
                    {
                        Debug.Assert(false);
                        newTarget = null;
                        break;
                    }
            }

            parent.Target = newTarget;

            return newTarget;
        }
Exemplo n.º 17
0
 public void Deserialize_V0(Stream stream, DataVersion version)
 {
     // This is the code that was in ITarget in data V0.  Since we changed our
     //  inheritance structure between V0 and V1, we must also change where the
     //  loading is done. It happens ITarget didn't deserialize anything in V0,
     //  so this is empty
 }
Exemplo n.º 18
0
 public PowerZoneSTTarget(Stream stream, DataVersion version, BasePowerTarget baseTarget)
     : this(baseTarget)
 {
     Deserialize(stream, version);
 }
Exemplo n.º 19
0
        public void Deserialize_V1(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(BasePowerTarget.IConcretePowerTarget), stream, version);

            m_MinPowerWatts.Deserialize(stream, version);
            m_MaxPowerWatts.Deserialize(stream, version);
        }
Exemplo n.º 20
0
 public void Deserialize_V0(Stream stream, DataVersion version)
 {
 }
Exemplo n.º 21
0
 protected ITarget(Stream stream, DataVersion version, IStep parent)
 {
     Deserialize(stream, version);
 }
Exemplo n.º 22
0
 public DistanceDuration(Stream stream, DataVersion version, IStep parent)
     : this(parent)
 {
     Deserialize(stream, version);
 }
Exemplo n.º 23
0
        public new void Deserialize_V0(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(IDuration), stream, version);

            byte[] doubleBuffer = new byte[sizeof(double)];
            byte[] intBuffer = new byte[sizeof(Int32)];

            stream.Read(doubleBuffer, 0, sizeof(double));
            stream.Read(intBuffer, 0, sizeof(Int32));

            SetDistanceInUnits(BitConverter.ToDouble(doubleBuffer, 0),
                               (Length.Units)BitConverter.ToInt32(intBuffer, 0));
        }
 public RepeatUntilHeartRateAboveDuration(Stream stream, DataVersion version, RepeatStep parent)
     : this(parent)
 {
     Deserialize(stream, version);
 }
Exemplo n.º 25
0
        public void Deserialize_V10(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(IDuration), stream, version);

            m_Distance.Deserialize(stream, version);
        }
        public new void Deserialize_V0(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(IRepeatDuration), stream, version);

            m_IsPercentageMaxHR.Deserialize(stream, version);
            InternalMaxHeartRate.Deserialize(stream, version);
        }
Exemplo n.º 27
0
        public void Deserialize_V18(Stream stream, DataVersion version)
        {
            // Call base deserialization
            Deserialize(typeof(BasePowerTarget.IConcretePowerTarget), stream, version);

            // Inverted the data order in V10 so we can use the Internal... functions
            m_IsPercentFTP.Deserialize(stream, version);
            InternalMinPower.Deserialize(stream, version);
            InternalMaxPower.Deserialize(stream, version);
        }
Exemplo n.º 28
0
 public new void Deserialize_V0(Stream stream, DataVersion version)
 {
     // In V0, we only have GTC zone type
     m_ConcreteTarget = new CadenceRangeTarget(stream, version, this);
 }
Exemplo n.º 29
0
 public BaseCadenceTarget(Stream stream, DataVersion version, IStep parent)
     : this(parent)
 {
     Deserialize(stream, version);
 }
 public RepeatUntilDistanceDuration(Stream stream, DataVersion version, RepeatStep parent)
     : this(parent)
 {
     Deserialize(stream, version);
 }