public static void SaveGridRules(string fileName, GridRules.GridRuleCollection rules) { FileMode mode = System.IO.File.Exists(fileName) ? FileMode.Truncate : FileMode.Create; using (FileStream fs = new FileStream(fileName, mode)) { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer( typeof(GridRules.GridRuleCollection)); ser.Serialize(fs, rules); } }
public static GridRules.GridRuleCollection LoadGridRules(string fileName) { GridRules.GridRuleCollection ret = null; using (FileStream fs = new FileStream(fileName, FileMode.Open)) { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer( typeof(GridRules.GridRuleCollection)); object o = ser.Deserialize(fs); ret = (GridRules.GridRuleCollection)o; } return(ret); }
public GridRuleCollection GetRulesFor(string gridTypeName, string weekendName, string trackName) { GridRuleCollection ret = new GridRuleCollection(); foreach (var item in this) { if (IsAccepted(gridTypeName, item.GridTypeName) && IsAccepted(weekendName, item.WeekendNameContains) && IsAccepted(trackName, item.TrackNameContains) ) { ret.Add(item); } } return(ret); }