public bool TryGet(Type type, string name, out ISerializableViaName serializableViaName) { serializableViaName = null; if (!TryGetValueForType(type, out var dictForType)) { return(false); } return(dictForType.TryGetValue(name, out serializableViaName)); }
public void Set(ISerializableViaName instance) { if (!_typeNameAndInstances.TryGetValue(instance.GetType(), out var dictForType)) { dictForType = new Dictionary <string, ISerializableViaName>(); _typeNameAndInstances[instance.GetType()] = dictForType; } //if (dictForType.ContainsKey(instance.GetName())) // throw new ArgumentException( // $"Shared instance of {instance.GetType().Name} with name {instance.GetName()} has already been set."); dictForType[instance.GetName()] = instance; }