@@ -112,34 +112,33 @@ public static VersionAProtoBuf.ProtoBufPayload.KuraMetric ConvertVersionAMetric(
112
112
/// <returns>The <see cref="VersionAData.KuraMetric"/>.</returns>
113
113
public static VersionAData . KuraMetric ConvertVersionAMetric ( VersionAProtoBuf . ProtoBufPayload . KuraMetric metric )
114
114
{
115
- var newMetric = new VersionAData . KuraMetric
115
+ var newMetric = new VersionAData . KuraMetric ( )
116
116
{
117
- Name = metric . Name ,
118
- DataType = ConvertVersionADataType ( metric . DataType )
117
+ Name = metric . Name
119
118
} ;
120
119
121
120
switch ( newMetric . DataType )
122
121
{
123
- case VersionAData . DataType . Boolean :
124
- newMetric . BooleanValue = metric . BooleanValue ?? default ;
122
+ case VersionADataTypeEnum . Boolean :
123
+ newMetric . SetValue ( VersionADataTypeEnum . Boolean , metric . BooleanValue ) ;
125
124
break ;
126
- case VersionAData . DataType . Bytes :
127
- newMetric . BytesValue = metric . BytesValue ?? Array . Empty < byte > ( ) ;
125
+ case VersionADataTypeEnum . Bytes :
126
+ newMetric . SetValue ( VersionADataTypeEnum . Bytes , metric . BytesValue ) ;
128
127
break ;
129
- case VersionAData . DataType . Double :
130
- newMetric . DoubleValue = metric . DoubleValue ?? default ;
128
+ case VersionADataTypeEnum . Double :
129
+ newMetric . SetValue ( VersionADataTypeEnum . Double , metric . DoubleValue ) ;
131
130
break ;
132
- case VersionAData . DataType . Float :
133
- newMetric . FloatValue = metric . FloatValue ?? default ;
131
+ case VersionADataTypeEnum . Float :
132
+ newMetric . SetValue ( VersionADataTypeEnum . Float , metric . FloatValue ) ;
134
133
break ;
135
- case VersionAData . DataType . Int32 :
136
- newMetric . IntValue = metric . IntValue ?? default ;
134
+ case VersionADataTypeEnum . Int32 :
135
+ newMetric . SetValue ( VersionADataTypeEnum . Int32 , metric . IntValue ) ;
137
136
break ;
138
- case VersionAData . DataType . Int64 :
139
- newMetric . LongValue = metric . LongValue ?? default ;
137
+ case VersionADataTypeEnum . Int64 :
138
+ newMetric . SetValue ( VersionADataTypeEnum . Int64 , metric . LongValue ) ;
140
139
break ;
141
- case VersionAData . DataType . String :
142
- newMetric . StringValue = metric . StringValue ?? string . Empty ;
140
+ case VersionADataTypeEnum . String :
141
+ newMetric . SetValue ( VersionADataTypeEnum . String , metric . StringValue ) ;
143
142
break ;
144
143
}
145
144
@@ -151,34 +150,34 @@ public static VersionAData.KuraMetric ConvertVersionAMetric(VersionAProtoBuf.Pro
151
150
/// </summary>
152
151
/// <param name="type">The <see cref="VersionAProtoBuf.ProtoBufPayload.KuraMetric.ValueType"/>.</param>
153
152
/// <returns>The <see cref="VersionAData.DataType"/>.</returns>
154
- public static VersionAData . DataType ConvertVersionADataType ( VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType type )
153
+ public static VersionADataTypeEnum ConvertVersionADataType ( VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType type )
155
154
=> type switch
156
155
{
157
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bool => VersionAData . DataType . Boolean ,
158
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bytes => VersionAData . DataType . Bytes ,
159
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Double => VersionAData . DataType . Double ,
160
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Float => VersionAData . DataType . Float ,
161
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int32 => VersionAData . DataType . Int32 ,
162
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int64 => VersionAData . DataType . Int64 ,
163
- VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . String => VersionAData . DataType . String ,
164
- _ => VersionAData . DataType . String
156
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bool => VersionADataTypeEnum . Boolean ,
157
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bytes => VersionADataTypeEnum . Bytes ,
158
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Double => VersionADataTypeEnum . Double ,
159
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Float => VersionADataTypeEnum . Float ,
160
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int32 => VersionADataTypeEnum . Int32 ,
161
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int64 => VersionADataTypeEnum . Int64 ,
162
+ VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . String => VersionADataTypeEnum . String ,
163
+ _ => VersionADataTypeEnum . String
165
164
} ;
166
165
167
166
/// <summary>
168
167
/// Gets the version A ProtoBuf value type from the version A data type.
169
168
/// </summary>
170
169
/// <param name="type">The <see cref="VersionAData.DataType"/>.</param>
171
170
/// <returns>The <see cref="VersionAProtoBuf.ProtoBufPayload.KuraMetric.ValueType"/>.</returns>
172
- public static VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType ConvertVersionADataType ( VersionAData . DataType type )
171
+ public static VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType ConvertVersionADataType ( VersionADataTypeEnum type )
173
172
=> type switch
174
173
{
175
- VersionAData . DataType . Boolean => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bool ,
176
- VersionAData . DataType . Bytes => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bytes ,
177
- VersionAData . DataType . Double => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Double ,
178
- VersionAData . DataType . Float => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Float ,
179
- VersionAData . DataType . Int32 => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int32 ,
180
- VersionAData . DataType . Int64 => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int64 ,
181
- VersionAData . DataType . String => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . String ,
174
+ VersionADataTypeEnum . Boolean => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bool ,
175
+ VersionADataTypeEnum . Bytes => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Bytes ,
176
+ VersionADataTypeEnum . Double => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Double ,
177
+ VersionADataTypeEnum . Float => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Float ,
178
+ VersionADataTypeEnum . Int32 => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int32 ,
179
+ VersionADataTypeEnum . Int64 => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . Int64 ,
180
+ VersionADataTypeEnum . String => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . String ,
182
181
_ => VersionAProtoBuf . ProtoBufPayload . KuraMetric . ValueType . String
183
182
} ;
184
183
}
0 commit comments