Пример #1
0
        /// <summary>
        /// Determines if a given file URL exists.
        /// </summary>
        /// <param name="FileURL">The file URL to be located.</param>
        /// <param name="actualFileUrl">An output parameter containing the URL received from
        /// the server for the file.</param>
        /// <returns>True if the existence of the file has successfully been verified with the
        /// server.</returns>
        /// <remarks>Once the server has been contacted, the existence of the file and the URL
        /// from the server is cached.</remarks>
        public static bool IsValidURL(string FileURL, out string actualFileUrl)
        {
            actualFileUrl = FileURL;

            lock (remoteFilesDt)
            {
                if (remoteFilesDt.TryGetValue(FileURL, out actualFileUrl))
                {
                    return(true);
                }
                if (TryGetUrlMapping(FileURL, out actualFileUrl))
                {
                    return(true);
                }

                if (remoteFilesDt.Count > 5000)
                {
                    remoteFilesDt.Clear();
                }

                DateTime lastModified;

                RemoteFiles rf = new RemoteFiles();

                if (rf.CheckURLFileExists(FileURL, ref actualFileUrl, out lastModified))
                {
                    RemoteFiles.remoteFilesDt[FileURL] = actualFileUrl;

                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        public static void UpdateFileMappingInformation(Dictionary <string, string> newMappings)
        {
            LoadFileMappingInformation();

            foreach (KeyValuePair <string, string> kvp in newMappings)
            {
                FileMappingInformation[kvp.Key] = kvp.Value;
            }
            string fileName = RivetApplicationDataDragonTagPath + Path.DirectorySeparatorChar + MAPPING_FILE_NAME;


            List <string> serializableObject = new List <string>();

            foreach (KeyValuePair <string, string> kvp in FileMappingInformation)
            {
                serializableObject.Add(Path.GetFileName(kvp.Key).ToLower());
                serializableObject.Add(kvp.Value);
            }
            RemoteFiles.XmlSerializeObjectToFile(fileName, serializableObject.ToArray());
        }
Пример #3
0
        private static void LoadFileMappingInformation()
        {
            if (FileMappingInformation != null)
            {
                return;
            }
            string fileName = RivetApplicationDataDragonTagPath + Path.DirectorySeparatorChar + MAPPING_FILE_NAME;

            FileMappingInformation = new Dictionary <string, string>();

            if (File.Exists(fileName))
            {
                string[] vals = RemoteFiles.XmlDeserializeObjectFromFile(fileName, typeof(string[])) as string[];
                if (vals != null)
                {
                    for (int i = 1; i < vals.Length; i = i + 2)
                    {
                        FileMappingInformation[vals[i - 1]] = vals[i];
                    }
                }
            }
        }