public DefaultVariableSerializers(DefaultVariableSerializers serializers) { foreach (var typedValueSerializer in serializers.serializerMap) { serializerMap.Add(typedValueSerializer.Key, typedValueSerializer.Value); } }
public virtual IVariableSerializers Join(IVariableSerializers other) { var copy = new DefaultVariableSerializers(); // "other" serializers override existing ones if their names match foreach (var thisSerializer in serializerMap.Values) { ITypedValueSerializer serializer = other.GetSerializerByName(thisSerializer.Name); if (serializer == null) { serializer = thisSerializer; } copy.AddSerializer(serializer); } // add all "other" serializers that did not exist before to the end of the list foreach (ITypedValueSerializer otherSerializer in other.Serializers) { if (!copy.serializerMap.ContainsKey(otherSerializer.Name)) { copy.AddSerializer(otherSerializer); } } return(copy); }