コード例 #1
0
        public static List <InternalModType> GetInternalModTypes()
        {
            List <InternalModType> InteralModTypes = new List <InternalModType>();
            string        typesFolderPath          = Properties.Settings.Default.DefaultDir + @"\Resources\InternalModTypes\";
            XmlSerializer serializer = new XmlSerializer(typeof(InternalModType));

            try
            {
                foreach (string file in Directory.GetFiles(typesFolderPath, "*", SearchOption.AllDirectories))
                {
                    using (FileStream fileStream = new FileStream(file, FileMode.Open))
                    {
                        InternalModType result = (InternalModType)serializer.Deserialize(fileStream);
                        InteralModTypes.Add(result);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            return(InteralModTypes);
        }
コード例 #2
0
        public static void SaveInternalModType(InternalModType type)
        {
            string destination = Properties.Settings.Default.DefaultDir + @"\Resources\InternalModTypes\" + type.Filename + ".xml";

            type.Files.Sort(delegate(InternalModTypeFile x, InternalModTypeFile y)
            {
                return(x.ID.CompareTo(y.ID));
            });

            foreach (InternalModTypeFile imtf in type.Files)
            {
                imtf.Files.Sort(delegate(BuilderFile x, BuilderFile y)
                {
                    return(x.BuilderID.CompareTo(y.BuilderID));
                });
            }

            XmlSerializer xmlSerializer = new XmlSerializer(typeof(InternalModType));

            using (StreamWriter wr = new StreamWriter(destination))
            {
                xmlSerializer.Serialize(wr, type);
            }
        }
コード例 #3
0
        public static List <ContentMapping> RemoveUpdatedInternalModTypeMappings(List <ContentMapping> contentMappings, InternalModType imt)
        {
            List <ContentMapping> CorrespondingMappings = contentMappings.FindAll(cm => cm.InternalModType == imt.ID);

            foreach (ContentMapping foundContent in CorrespondingMappings)
            {
                contentMappings.Remove(foundContent);
            }

            return(contentMappings);
        }