File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Orm/Xtensive.Orm/Sql/Model Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,23 @@ public class NodeCollection<TNode>: CollectionBaseSlim<TNode>
30
30
/// <returns><see langword="True"/> if this instance is read-only; otherwise, <see langword="false"/>.</returns>
31
31
public override bool IsReadOnly { get { return IsLocked || base . IsReadOnly ; } }
32
32
33
- /// <inheritdoc/>
33
+ /// <summary>
34
+ /// Adds item to collection.
35
+ /// </summary>
36
+ /// <param name="item">Item to add</param>
37
+ /// <exception cref="ArgumentException">The item with same name already exists in the collection</exception>
34
38
public override void Add ( TNode item )
35
39
{
36
40
base . Add ( item ) ;
37
- if ( ! string . IsNullOrEmpty ( item . GetNameInternal ( ) ) )
38
- nameIndex . Add ( item . GetNameInternal ( ) , item ) ;
41
+ var name = item . GetNameInternal ( ) ;
42
+ if ( ! string . IsNullOrEmpty ( name ) ) {
43
+ try {
44
+ nameIndex . Add ( name , item ) ;
45
+ }
46
+ catch ( ArgumentException ) {
47
+ throw new ArgumentException ( string . Format ( Strings . ExItemWithNameXAlreadyExists , name ) ) ;
48
+ }
49
+ }
39
50
}
40
51
41
52
public override bool Remove ( TNode item )
You can’t perform that action at this time.
0 commit comments