-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDeveloperDataLookup.cs
More file actions
100 lines (83 loc) · 3.55 KB
/
DeveloperDataLookup.cs
File metadata and controls
100 lines (83 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#region Copyright
/////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2026 Garmin International, Inc.
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
// may not use this file except in compliance with the Flexible and Interoperable Data
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.195.0Release
// Tag = production/release/21.195.0-0-g569e7e5
/////////////////////////////////////////////////////////////////////////////////////////////
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Dynastream.Fit
{
internal class DeveloperDataLookup
{
private readonly Dictionary<DeveloperDataKey, FieldDescriptionMesg> m_fieldDescriptionMesgs;
private readonly Dictionary<byte, DeveloperDataIdMesg> m_developerDataIdMesgs;
public DeveloperDataLookup()
{
m_fieldDescriptionMesgs = new Dictionary<DeveloperDataKey, FieldDescriptionMesg>();
m_developerDataIdMesgs = new Dictionary<byte, DeveloperDataIdMesg>();
}
public Tuple<DeveloperDataIdMesg, FieldDescriptionMesg> GetMesgs(DeveloperDataKey key)
{
DeveloperDataIdMesg devIdMesg;
FieldDescriptionMesg descriptionMesg;
m_developerDataIdMesgs.TryGetValue(key.DeveloperDataIndex, out devIdMesg);
m_fieldDescriptionMesgs.TryGetValue(key, out descriptionMesg);
if (devIdMesg != null && descriptionMesg != null)
{
return new Tuple<DeveloperDataIdMesg, FieldDescriptionMesg>(
devIdMesg,
descriptionMesg);
}
return null;
}
public void Add(DeveloperDataIdMesg mesg)
{
byte? index = mesg.GetDeveloperDataIndex();
if (index == null)
return;
m_developerDataIdMesgs[index.Value] = mesg;
// Remove all fields currently associated with this developer
var keysToRemove =
m_fieldDescriptionMesgs.Keys
.Where(
x =>
x.DeveloperDataIndex ==
index)
.ToList();
foreach (var key in keysToRemove)
{
m_fieldDescriptionMesgs.Remove(key);
}
}
public DeveloperFieldDescription Add(FieldDescriptionMesg mesg)
{
DeveloperFieldDescription desc = null;
byte? developerDataIndex = mesg.GetDeveloperDataIndex();
byte? fieldDefinitionNumber = mesg.GetFieldDefinitionNumber();
if ((developerDataIndex != null) &&
(fieldDefinitionNumber != null))
{
var key = new DeveloperDataKey(
(byte)developerDataIndex,
(byte)fieldDefinitionNumber);
m_fieldDescriptionMesgs[key] = mesg;
// Build a Description of the pairing we just created
var pair = GetMesgs(key);
if (pair != null)
{
desc = new DeveloperFieldDescription(pair.Item1, pair.Item2);
}
}
return desc;
}
}
} // namespace