public void Reload() { var loader = _loader; //如果加载器为空则退出 if (loader == null) { return; } //加载当前应用的所有元数据提供程序 var items = loader.Load(_name); _metadatas.Clear(); _metadatas.AddRange(items); //设置加载标记为完成 _isLoaded = true; }
public void AddRange_can_add_items_to_readonly_collection() { var metadataCollection = new MetadataCollection<EntityType>(); var item = new EntityType("E", "N", DataSpace.CSpace); metadataCollection.Add(item); Assert.Equal(1, metadataCollection.Count); metadataCollection.SetReadOnly(); Assert.True(metadataCollection.IsReadOnly); metadataCollection.AddRange( new List<EntityType> { new EntityType("F", "N", DataSpace.CSpace), new EntityType("G", "N", DataSpace.CSpace) }); Assert.Equal(3, metadataCollection.Count); Assert.True(metadataCollection.IsReadOnly); }
public void AddRange_throws_ArgumentNullException_for_null_collection_item() { var metadataCollection = new MetadataCollection<MetadataItem>(); Assert.Equal( Strings.ADP_CollectionParameterElementIsNull("items"), Assert.Throws<ArgumentException>( () => metadataCollection.AddRange( new List<MetadataItem> { null })).Message); }
public void AddRange_throws_ArgumentNullException_for_null_identity() { var metadataCollection = new MetadataCollection<EntityType>(); Assert.Equal( new ArgumentNullException("name").Message, Assert.Throws<ArgumentNullException>( () => metadataCollection.AddRange( new List<EntityType> { new EntityType(null, null, DataSpace.CSpace) })).Message); }
public void AddRange_throws_ArgumentException_for_duplicate_identity() { var metadataCollection = new MetadataCollection<EntityType>(); var item = new EntityType("E", "N", DataSpace.CSpace); metadataCollection.Add(item); Assert.Equal(1, metadataCollection.Count); Assert.Contains( Strings.ItemDuplicateIdentity(item.Identity), Assert.Throws<ArgumentException>( () => metadataCollection.AddRange( new List<EntityType> { item })).Message); Assert.Contains( Strings.ItemDuplicateIdentity(item.Identity), Assert.Throws<ArgumentException>( () => metadataCollection.AddRange( new List<EntityType> { new EntityType("E", "N", DataSpace.CSpace) })).Message); }