private IMapperRequest FetchMapperRequest(string resourceKey) { if (CanFindMapperRequestWithJustKey) { try { MapperRequestTemplate mr = _mapperRequestBuilder.GetMapperRequest(resourceKey); IMapperRequest mrCooked = new MapperRequest(mr.SourceType, mr.DestinationPropModelKey, mr.ConfigPackageName); return(mrCooked); } catch (System.Exception e) { throw new ApplicationException($"MapperRequest for ResourceKey = {resourceKey} was not found.", e); } } else if (HasMrLookupResources) { throw new InvalidOperationException($"A call providing only a ResourceKey can only be done, " + $"if this PropModelBuilder was supplied with a MapperRequestBuilder upon construction. " + $"No class implementing: {nameof(IMapperRequestBuilder)} was provided. " + $"Please supply a MapperRequest object."); } else { throw new InvalidOperationException($"A call providing only a ResourceKey can only be done, " + $"if this PropModelBuilder was supplied with the necessary resources upon construction. " + $"A {_mapperRequestBuilder.GetType()} was provided, but it does not have the necessary resources. " + $"Please supply a ResourceDictionary and ResourceKey or a MapperRequest object."); } }
public IMapperRequest GetMapperRequest(ResourceDictionary rd, string resourceKey) { if (HasMrLookupResources) { try { MapperRequestTemplate mr = _mapperRequestBuilder.GetMapperRequest(rd, resourceKey); IMapperRequest mapperRequest = new MapperRequest(mr.SourceType, mr.DestinationPropModelKey, mr.ConfigPackageName); return(mapperRequest); } catch (System.Exception e) { throw new ApplicationException("Resource was not found.", e); } } else { throw new InvalidOperationException($"A call providing a ResourceDictionary and a ResouceKey can only be done, " + $"if this PropModelBuilder was supplied with a resource upon construction. " + $"No class implementing: {nameof(IMapperRequestBuilder)} was provided."); } }