Skip to content

Commit

Permalink
修复RemoveAll空引用异常
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Jan 9, 2024
1 parent ab8ee89 commit e734945
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Megumin.Explosion/Megumin/Class/Multiple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,24 @@ public virtual V RemoveAll(int raiseEvent = 0)

// //微软源码直接用泛型与null比较,这里不做判断了,增加两个构造函数保证DefaultKey 不为null。
//}
if (DefaultKey is not null)
{
ElementDic[DefaultKey] = DefaultValue;
}

ElementDic[DefaultKey] = DefaultValue;
ApplyValue(raiseEvent);
return Current;
}

public V RemoveAll(Func<KeyValuePair<K, V>, bool> predicate, int raiseEvent = 0)
{
ElementDic.RemoveAll(predicate);
ElementDic[DefaultKey] = DefaultValue;

if (DefaultKey is not null)
{
ElementDic[DefaultKey] = DefaultValue;
}

ApplyValue(raiseEvent);
return Current;
}
Expand Down
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e734945

Please sign in to comment.