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); }
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); } }
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); }