Composite.Data.DataMetaDataFacade.UpdateFilenames C# (CSharp) Метод

UpdateFilenames() приватный статический Метод

private static UpdateFilenames ( ) : void
Результат void
        private static void UpdateFilenames()
        {
            List<string> filepaths = C1Directory.GetFiles(_metaDataPath, "*.xml").ToList();

            var ids = new Dictionary<Guid, string>();
            foreach (string filepath in filepaths)
            {
                Guid id = GetGuidFromFilename(filepath);
                if (!ids.ContainsKey(id))
                {
                    ids.Add(id, filepath);
                }
                else // This should never happen, but is here to be robust
                {
                    if (!IsMetaDataFileName(Path.GetFileNameWithoutExtension(filepath))) // Old version of the file, delete it
                    {
                        FileUtils.Delete(filepath);
                    }
                    else // Old version is stored in ids, delete it and change the value to new version
                    {
                        FileUtils.Delete(ids[id]);
                        ids[id] = filepath;
                    }
                }
            }

            foreach (var kvp in ids)
            {
                string filepath = kvp.Value;
                if (!IsMetaDataFileName(Path.GetFileNameWithoutExtension(filepath)))
                {
                    continue;
                }

                var dataTypeDescriptor = LoadFromFile(filepath);
                string newFilepath = CreateFilename(dataTypeDescriptor);

                FileUtils.RemoveReadOnly(filepath);

                Func<string, string> normalizeFileName = f => f.Replace('_', ' ').ToLowerInvariant();
                if (normalizeFileName(filepath) != normalizeFileName(newFilepath))
                {
                    C1File.Move(filepath, newFilepath);
                }
            }
        }