forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsistentArraySerializerFactory.cs
More file actions
34 lines (30 loc) · 1.13 KB
/
ConsistentArraySerializerFactory.cs
File metadata and controls
34 lines (30 loc) · 1.13 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
// -----------------------------------------------------------------------
// <copyright file="ConsistentArraySerializerFactory.cs" company="Asynkron HB">
// Copyright (C) 2015-2017 Asynkron HB All rights reserved
// </copyright>
// -----------------------------------------------------------------------
using System;
using System.Collections.Concurrent;
using Wire.Extensions;
using Wire.ValueSerializers;
namespace Wire.SerializerFactories
{
public class ConsistentArraySerializerFactory : ValueSerializerFactory
{
public override bool CanSerialize(Serializer serializer, Type type)
{
return type.IsOneDimensionalPrimitiveArray();
}
public override bool CanDeserialize(Serializer serializer, Type type)
{
return CanSerialize(serializer, type);
}
public override ValueSerializer BuildSerializer(Serializer serializer, Type type,
ConcurrentDictionary<Type, ValueSerializer> typeMapping)
{
var res = ConsistentArraySerializer.Instance;
typeMapping.TryAdd(type, res);
return res;
}
}
}