private void AddTypeSerializer(IXleTypeSerializer serializer, bool allowInherit = false) { int count = 0; var dictionary = allowInherit ? mInherited : mDirect; foreach (var type in serializer.AllowedTypes) { count++; dictionary.Add(type, serializer); } if (count == 0) { throw new InvalidOperationException("The serializer doesn't serialize any types!"); } }
/// <summary> /// Adds a type serializer to the colleciton /// </summary> /// <param name="type">The type of object to be serialized</param> /// <param name="serializer">The object which will perform the serialization</param> /// <param name="allowInherit">Indicates whether this serializer will also be used to serialize types which inherit /// from <c>type</c>.</param> public void AddTypeSerializer(Type type, IXleTypeSerializer serializer, bool allowInherit = false) { var dictionary = allowInherit ? mInherited : mDirect; dictionary.Add(type, serializer); }