Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Removing a Field from a Mesg

Rank

Total Posts: 3

Joined 2015-12-17

PM

I'm in the process of upgrading my C# application from FIT SDK 1.x to 20.50.00.

The application allows Fields to be removed from Mesgs in order, for example, to remove GPS data from a FIT activity file.

The code written against the 1.x SDK did this by identifying a field to be removed from a Mesg and calling:

mesg.fields.Remove(field); 


This won't work with SDK 20.50.00 as the fields collection is now private. I also can't use the public Fields property as this is implemented as IEnumerable<Field> and does not have a Remove() method.

Ideally, in the same way that the Mesg class implements an InsertField() method there should be a RemoveField() method.

I have added this to my local copy of the Dynastream source code as a temporary fix:

/// <summary>
        /// Remove the specified field.
        /// </summary>
        /// <param name="field">The Field instance to be removed.</param>
        
public void RemoveField(Field field)
        
{
            this
.FieldsList.Remove(field);
        
     
RankRankRank

Total Posts: 68

Joined 0

PM

Thank you for your suggestion. We were able to get your suggested change into the SDK that was released yesterday.      
Rank

Total Posts: 3

Joined 2015-12-17

PM

Thanks for the update. I downloaded the latest build and tried it out. Works as expected. Thanks again.