public static ISmppSerializer GetForType(Type type, SmppSerializationSettings serializationSettings) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (Attribute.GetCustomAttribute(type, typeof(SerializableAttribute), false) is SmppSerializerAttribute attr) { return(GetFromAttribute(attr)); } var schema = serializationSettings.Schemata[type]; if (schema == null) { schema = SmppObjectSchema.CreateFrom(type); } if (schema == null) { throw new InvalidOperationException($"Could not find or generate a schema for the type {type}"); } return(new SchemaBasedSerializer(schema)); }
public SchemaBasedSerializer(SmppObjectSchema schema) { _schema = schema ?? throw new ArgumentNullException(nameof(schema)); }