Esempio n. 1
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);
		}
Esempio n. 2
0
		internal Dictionary(string name, string caption, bool raiseBitwise, ItemValueDataType valueDataType, string description, DictionaryItemCollection items)
		{
			this.name = name;
			this.caption = caption;
			this.raiseBitwise = raiseBitwise;
			this.itemValueDataType = valueDataType;
			this.description = description;

			this.items = items;

			List<DictionaryItem> list = new List<DictionaryItem>(this.items.Count);

			this.AppendItemsToList(null, this.items, list);

			this.all = new DictionaryItemCollection(list);
		}