20 public IReadOnlyList<FieldInfo>
Fields {
get; }
24 public IReadOnlyDictionary<string, FieldInfo>
FieldsByName {
get; }
26 internal bool ShouldEscapeObject {
get; }
28 internal Module? Collection {
get; }
30 internal MappingInfo(MappingContext ctx,
Type ty,
string? colName =
null)
34 Collection = colName !=
null ?
new Module(colName) : null;
36 var fields =
new List<FieldInfo>();
37 var byName =
new Dictionary<string, FieldInfo>();
39 foreach (var prop
in ty.GetProperties())
41 if (prop.GetCustomAttribute<IgnoreAttribute>() !=
null)
continue;
43 var attr = prop.GetCustomAttribute<BaseFieldAttribute>() ??
new FieldAttribute();
44 var info =
new FieldInfo(ctx, attr, prop);
46 if (byName.ContainsKey(info.Name))
50 byName[info.Name] = info;
53 ShouldEscapeObject = Serializer.Tags.Overlaps(byName.Values.Select(i => i.Name));
54 Fields = fields.ToImmutableList();
57 var serType = typeof(ClassSerializer<>).MakeGenericType(
new[] { ty });
58 ClassSerializer = (
ISerializer)Activator.CreateInstance(serType,
this)!;