コード例 #1
0
		protected override LookupItemCollection InitializeLookups (string collectionName)
		{
			var root = CurrentXmlLookup.DocumentElement;
			var targetCollection = root.SelectSingleNode(String.Format("lookupCollection[@name='{0}']",collectionName));
	
			if (targetCollection == null) {
				return null;
			}
	
			LookupItemCollection result = new LookupItemCollection(collectionName);
			
			foreach (XmlNode item in targetCollection.ChildNodes) {
				LookupItem currentLookup = InitializeLookupItem(item);
				currentLookup.CollectionName = collectionName;
				result.Add(currentLookup);
			}
			return result;
		}
コード例 #2
0
		public override void SaveLookups (LookupItemCollection lookups)
		{
			var root = CurrentXmlLookup.DocumentElement;
			var targetCollection = root.SelectSingleNode (String.Format ("lookupCollection[@name='{0}']", lookups.CollectionName));
	
			if (targetCollection == null) {
				targetCollection = CurrentXmlLookup.CreateNode (XmlNodeType.Element, "lookup", null);
				
				var nameAttr = CurrentXmlLookup.CreateAttribute (nameAttributeName);
				nameAttr.Value = lookups.CollectionName;
				
				targetCollection.Attributes.Append (nameAttr);
				
				CurrentXmlLookup.AppendChild (targetCollection);
			}
			else
			{
				targetCollection.RemoveAll ();
				var nameAttr = CurrentXmlLookup.CreateAttribute (nameAttributeName);
				nameAttr.Value = lookups.CollectionName;
				targetCollection.Attributes.Append (nameAttr);
			}
			
			foreach (var lookup in lookups) {
				XmlNode newNode = CurrentXmlLookup.CreateNode(XmlNodeType.Element,"lookup", null);
				
				newNode.InnerText = lookup.LookupDesc;
				
				var idAttr = CurrentXmlLookup.CreateAttribute(idAttributeName);
				idAttr.Value = lookup.LookupID;
				
				var codeAttr = CurrentXmlLookup.CreateAttribute(codeAttributeName);
				codeAttr.Value = lookup.LookupCode;
				
				var viewOrderAttr = CurrentXmlLookup.CreateAttribute(viewOrderAttributeName);
				viewOrderAttr.Value = lookup.ViewOrder.ToString();
				
				newNode.Attributes.Append(idAttr);
				newNode.Attributes.Append(codeAttr);
				newNode.Attributes.Append(viewOrderAttr);
				
				targetCollection.AppendChild(newNode);
			}
			
			CurrentXmlLookup.Save(XmlFileName);
		}
コード例 #3
0
		public abstract void SaveLookups(LookupItemCollection lookups);