コード例 #1
0
ファイル: Xml.cs プロジェクト: Wolfury/nebenkosten
		public static void Write(LesseeManager lessees, string filepath, IdTable ids) {
			var f = new XmlWriter(filepath);
			f.Begin("Lessees");
			var list = new Lessee[lessees.Count];
			lock ( lessees ) lessees.CopyTo(list, 0);
			foreach ( var l in list ) {
				f.Begin(l, ids);
				f.Begin("Payments");
				var paymentlist = new AdvancePayment[l.Payments.Count];
				lock ( l.Payments ) l.Payments.CopyTo(paymentlist, 0);
				foreach ( var p in paymentlist ) f.Write(p, ids);
				f.End("Payments");
				f.End(l);
			}
			f.End("Lessees");
			f.Close();
		}
コード例 #2
0
ファイル: Xml.cs プロジェクト: Wolfury/nebenkosten
		public static void Read(string filepath, LesseeManager lessees, ReferenceTable references, IdTable ids) {
			var xml = new XPathDocument(filepath).CreateNavigator();
			var li = xml.Select("/Lessees/Lessee");
            var list = new List<Lessee>();
			while ( li.MoveNext() ) {
				var lnode = li.Current;
				var l = new Lessee();
				ids[l] = new Guid(lnode.GetAttribute("id", ""));
				AssignProperties(lnode, l, references);
				var pi = lnode.Select("Payments/AdvancePayment");
				while ( pi.MoveNext() ) {
					var pnode = pi.Current;
					var p = new AdvancePayment();
					ids[p] = new Guid(pnode.GetAttribute("id", ""));
					AssignProperties(pnode, p, references);
					l.Payments.Add(p);
				}
                list.Add(l);
			}
            foreach (var i in list.OrderBy(item => item.Name))
                lessees.Add(i);
		}