-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathCecilArraySerializerFactory.cs
More file actions
29 lines (23 loc) · 971 Bytes
/
CecilArraySerializerFactory.cs
File metadata and controls
29 lines (23 loc) · 971 Bytes
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
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using Mono.Cecil;
namespace Stride.Core.AssemblyProcessor;
/// <summary>
/// Generates array serializer type from a given array type.
/// </summary>
public class CecilArraySerializerFactory : ICecilSerializerFactory
{
private readonly TypeReference genericArraySerializerType;
public CecilArraySerializerFactory(TypeReference genericArraySerializerType)
{
this.genericArraySerializerType = genericArraySerializerType;
}
public TypeReference? GetSerializer(TypeReference objectType)
{
if (objectType.IsArray)
{
return genericArraySerializerType.MakeGenericType(((ArrayType)objectType).ElementType);
}
return null;
}
}