Skip to content

Commit 0fba0ec

Browse files
committed
switch to adding in types instead of namespaces for more flexibility
1 parent bab261c commit 0fba0ec

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/CIM.Cson/Converters/ShortNameBinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ class ShortNameBinder : DefaultSerializationBinder
1212
readonly Dictionary<Type, string> _typeToName = new Dictionary<Type, string>();
1313
readonly Dictionary<string, Type> _nameToType = new Dictionary<string, Type>();
1414

15-
public ShortNameBinder(List<string> includeShortNameNamespaces)
15+
public ShortNameBinder(List<Type> includeShortHandForTypes)
1616
{
1717
AddTypesFromNamespace(typeof(IdentifiedObject).Namespace);
1818
AddTypesFromNamespace(typeof(DataSetMember).Namespace);
1919

20-
foreach (var includeShortNameNamespace in includeShortNameNamespaces)
20+
foreach (var type in includeShortHandForTypes)
2121
{
22-
AddTypesFromNamespace(includeShortNameNamespace);
22+
AddType(type);
2323
}
2424
}
2525

src/CIM.Cson/CsonSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class CsonSerializer
1616
private readonly CustomizedJsonSerializer _serializer;
1717
private readonly int _lineBufferSize;
1818

19-
public CsonSerializer(int lineBufferSize = 1024, List<string>? includeShorthandNamespaces = null)
19+
public CsonSerializer(int lineBufferSize = 1024, List<Type>? includeShortHandForTypes = null)
2020
{
21-
_serializer = new CustomizedJsonSerializer(includeShorthandNamespaces ?? new List<string>());
21+
_serializer = new CustomizedJsonSerializer(includeShortHandForTypes ?? new List<Type>());
2222
_lineBufferSize = lineBufferSize;
2323
}
2424

src/CIM.Cson/Internal/CustomizedJsonSerializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class CustomizedJsonSerializer
1111
{
1212
private JsonSerializerSettings _serializerSettings;
1313

14-
public CustomizedJsonSerializer(List<string> includeShortNameNamespaces)
14+
public CustomizedJsonSerializer(List<Type> includeShortHandForTypes)
1515
{
1616
_serializerSettings = new JsonSerializerSettings
1717
{
1818
TypeNameHandling = TypeNameHandling.Objects,
1919
NullValueHandling = NullValueHandling.Ignore,
20-
SerializationBinder = new ShortNameBinder(includeShortNameNamespaces),
20+
SerializationBinder = new ShortNameBinder(includeShortHandForTypes),
2121
Converters =
2222
{
2323
new ObjectReferenceSerializer(),

0 commit comments

Comments
 (0)