private static IObjectSerializer CreateObjectSerializer(Type targetType) { IObjectSerializer objectSerializer = ObjectSerializerFactory.Create(targetType); if (objectSerializer is CollectionSerializer collectionSerializer) { return(new CollectionObjectSerializer(collectionSerializer)); } return(objectSerializer); }
public CollectionSerializer(Type targetType) { if (targetType == null) { throw new ArgumentNullException(nameof(targetType)); } this.TargetType = targetType; this.ElementType = this.TargetType.GetCollectionElemenType(); this.ElementObjectSerializer = ObjectSerializerFactory.Create(this.ElementType); }
public ComplexPropertySerializer(PropertyInfo propertyInfo) : base(propertyInfo) { this.MemberAccessor = MemberAccessorFactory.Create(this.PropertyInfo); this.ObjectSerializer = ObjectSerializerFactory.Create(this.PropertyInfo.PropertyType); }