public static DecodedDto GetDtoInfoThrowExceptionIfNotThere(this Type dtoType) { if (!DecodedDtoCache.TryGetValue(dtoType, out var result)) { throw new NullReferenceException( $"The class {dtoType} is not registered as a valid CrudServices DTO/ViewModel." + $" Have you left off the {DecodedDtoExtensions.HumanReadableILinkToEntity} interface?"); } return(result); }
public static IStatusGeneric <DecodedDto> GetOrCreateDtoInfo(this Type classType, DecodedEntityClass entityInfo, IGenericServicesConfig publicConfig, PerDtoConfig perDtoConfig) { var status = new StatusGenericHandler <DecodedDto>(); if (classType.IsPublic || classType.IsNestedPublic) { return(status.SetResult(DecodedDtoCache.GetOrAdd(classType, type => new DecodedDto(classType, entityInfo, publicConfig, perDtoConfig)))); } status.AddError($"Sorry, but the DTO/ViewModel class '{classType.Name}' must be public for GenericServices to work."); return(status); }