예제 #1
0
		private void AppendItemsToList(DictionaryItem parent, DictionaryItemCollection items, List<DictionaryItem> list)
		{
			if (items.Count > 0)
			{
				int childLevel = parent == null ? 1 : parent.level + 1;
				if(childLevel>this.levelsCount)
				{
					this.levelsCount = childLevel;
				}

				DictionaryItem child;
				for (int i = 0; i < items.Count; i++)
				{
					child = items[i];
					child.level = childLevel;
					list.Add(child);
					AppendItemsToList(child, child.Children, list);
				}
			}
		}
예제 #2
0
		//把从 Web 服务端获取的字典项集合转换为本地字典项集合
		private DictionaryItemCollection ConvertRemoteDictItemListToLocal(DictionaryItem parent, RemoteDictionaryItem[] remoteList, string dictionaryName, ItemValueDataType valueDataType, Int64 minValue, Int64 maxValue)
		{
			DictionaryItem localItem;
			List<DictionaryItem> localList = new List<DictionaryItem>(remoteList.Length);
			for (int i = 0; i < remoteList.Length; i++)
			{
				// 确保字典项的值在字典中限定的字典项的类型允许的范围之内
				if (remoteList[i].Value < minValue || remoteList[i].Value > maxValue)
				{
					throw new Exception(String.Format("字典 {0} 的 ItemDataValueType 为 {1},其字典项“{2}”的取值超出该类型允许的范围(太大或太小)。", dictionaryName, valueDataType.ToString(), remoteList[i].Caption));
				}
				localItem = new DictionaryItem(remoteList[i].Value, remoteList[i].Code, remoteList[i].Caption, remoteList[i].SortNo, remoteList[i].RequireDescription);
				localItem.SetRelation(parent, remoteList[i].Children.Length > 0 ? ConvertRemoteDictItemListToLocal(localItem, remoteList[i].Children, dictionaryName, valueDataType, minValue, maxValue) : DictionaryItemCollection.emptyItems);
				localList.Add(localItem);
			}
			return new DictionaryItemCollection(localList);
		}
예제 #3
0
		internal void SetRelation(DictionaryItem parent, DictionaryItemCollection children)
		{
			this.parent = parent;
			this.children = children;
		}