private async Task <JsonConverter> GetBlockDataTypeConverterAsync(int pageBlockTypeId) { var dataBlockType = await _pageBlockTypeDataModelTypeFactory.CreateByPageBlockTypeIdAsync(pageBlockTypeId); var converterType = typeof(PageBlockDataModelJsonConverter <>).MakeGenericType(dataBlockType); return((JsonConverter)Activator.CreateInstance(converterType)); }
private async Task <JsonConverter> GetBlockDataTypeConverterAsync(int?pageBlockTypeId) { // If there's no id then the model probably wasn't supplied and should be // considered null which will cause a validation error if (!pageBlockTypeId.HasValue || pageBlockTypeId < 1) { return(null); } var dataBlockType = await _pageBlockTypeDataModelTypeFactory.CreateByPageBlockTypeIdAsync(pageBlockTypeId.Value); EntityNotFoundException.ThrowIfNull(dataBlockType, pageBlockTypeId); var converter = _entityDataModelJsonConverterFactory.Create(dataBlockType); return(converter); }