private bool UnregisterMapperSync <T>() { var wrapper = JsonSerializatorCache <T> .Unregister(this); if (wrapper == null) { return(false); } _mapperWrappers.Remove(wrapper); return(true); }
public IJsonSerializator <T> GetSerializator <T>() { var wrapper = JsonSerializatorCache <T> .GetJsonSerializator(this); if (wrapper != null) { return(wrapper.JsonSerializator); } wrapper = BuildJsonSerializator <T>(); if (wrapper != null) { return(wrapper.JsonSerializator); } return(ExceptionHelper.ThrowMapperNotRegisteredException <T>()); }
private MapperWrapper <T> BuildJsonSerializator <T>() { lock (_lock) { var existingWrapper = JsonSerializatorCache <T> .GetJsonSerializator(this); if (existingWrapper != null) { return(existingWrapper); } MapperWrapper <T> createdWrapper = BuildMapperWrapperSync <T>(); JsonSerializatorCache <T> .Register(createdWrapper); _mapperWrappers.Add(createdWrapper); return(createdWrapper); } }
internal bool RegisterMapper <T>(IJsonMapper <T> mapper) { if (mapper == null) { return(false); } lock (_lock) { if (_frozen || _disposed) { return(false); } UnregisterMapperSync <T>(); MapperWrapper <T> wrapper = new MapperWrapper <T>(this, mapper); JsonSerializatorCache <T> .Register(wrapper); _mapperWrappers.Add(wrapper); return(true); } }