/// <summary> /// Attempts to get the type from the cachedTypes dictionary or builds it if not present. /// </summary> private T BuildOrGetType(string kind, JToken tokenToBuild, JsonSerializer serializer, bool passTwo, string cacheKey) { T result; if (!passTwo && cachedTypes.ContainsKey(cacheKey)) { // Pull the type from the cache if found on pass one. result = cachedTypes[cacheKey]; } else { // Always build the type if it is pass two or the type is not found in the cache result = resourceExplorer.BuildType <T>(kind, tokenToBuild, serializer); cachedTypes[cacheKey] = result; } return(result); }