Пример #1
0
        public object?ReadValue(JsonObject source)
        {
            var value = (JsonValue)source[nameof(IEntity.Id)];

            if (value.Type == JsonDataType.Number)
            {
                return(_intConverter.Read(value));
            }

            var alias = _stringConverter.Read(value);

            return(_descriptions.GetOrAddAlias(alias));
        }
Пример #2
0
        protected TEntity?ReadEntity(JsonData idData)
        {
            var idValue = (JsonValue)idData;

            if (idValue.Type == JsonDataType.Null)
            {
                return(null);
            }

            var id = idValue.Type == JsonDataType.String
                ? _descriptions.GetOrAddAlias(idValue.Value)
                : int.Parse(idValue.Value);

            return(_resolver(id));
        }
Пример #3
0
 public void AddAliasIfNotExists(string alias)
 {
     _sourceDescriptions
     .GetOrAddAlias(alias)
     .Should().BeGreaterThan(0);
 }