示例#1
0
        public static void WriteContentMappingListFile(List <ContentMapping> contentMappings)
        {
            string ContentMappingFilePath = Properties.Settings.Default["DefaultDir"].ToString() + "\\Library\\ContentMapping.xml";

            contentMappings = contentMappings.OrderBy(a => a.GameDataItemID).ThenBy(a => a.InternalModType).ThenBy(a => a.Slot).ToList();

            ContentMappingList cml = new ContentMappingList(contentMappings);

            XmlSerializer LibrarySerializer = new XmlSerializer(typeof(ContentMappingList));

            using (StreamWriter Writer = new StreamWriter(ContentMappingFilePath))
            {
                LibrarySerializer.Serialize(Writer, cml);
            }
        }
示例#2
0
        public static List <ContentMapping> GetContentMappings()
        {
            List <ContentMapping> ContentMappings   = new List <ContentMapping>();
            string        ContentMappingLibraryPath = Properties.Settings.Default.DefaultDir + @"\Library\ContentMapping.xml";
            XmlSerializer serializer = new XmlSerializer(typeof(ContentMappingList));

            if (File.Exists(ContentMappingLibraryPath))
            {
                using (FileStream fileStream = new FileStream(ContentMappingLibraryPath, FileMode.Open))
                {
                    ContentMappingList result = (ContentMappingList)serializer.Deserialize(fileStream);
                    foreach (ContentMapping cm in result)
                    {
                        ContentMappings.Add(cm);
                    }
                }
            }


            return(ContentMappings);
        }