예제 #1
0
        /// <summary>
        /// Loads the cached responses and redirects from files.
        /// </summary>
        /// <param name="fileName">the filename. (will be suffixed with .Responses or .Redirects)</param>
        public void LoadCacheState(string fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if (Responses && Responses.Any())
            {
                Logger.LogWarning($"Loading cached {nameof(WebRequestFactory)} will override {Responses.Count} responses from the cache. If you want to keep them consider using {nameof(WebRequestFactory)}.{nameof(WebRequestFactory.AppendCacheState)}.");
            }

            if (Redirects && Redirects.Any())
            {
                Logger.LogWarning($"Loading cached {nameof(WebRequestFactory)} will override {Redirects.Count} redirects from the cache. If you want to keep them consider using {nameof(WebRequestFactory)}.{nameof(WebRequestFactory.AppendCacheState)}.");
            }

            Responses = Serializer.ReadJsonData <SynchronizedDictionary <string, string, AVLHashMap <string, string> > >(fileName + "." + nameof(Responses));
            Redirects = Serializer.ReadJsonData <SynchronizedDictionary <string, string, AVLHashMap <string, string> > >(fileName + "." + nameof(Redirects));
        }