我有以下代码。
private void LoopThroughDependsIssues(JIRAOperations jiraOps, string jiraURL, string token, string username, string password, string projectKey, string exportTargetPath, string branch, SVNOperations svnOps, string svnExePath, string changesetDBFile, DependencyManager mgr)
{
var tempVar = mgr.Dependencies;
foreach (var item in tempVar)
{
if (item.depends.Length > 0)
{
var templist = item.depends;
var listissues1 = templist.Split(',');
for (var i = 0; i < listissues1.Length-1; i++)
{
var newissue1 = new string[] { listissues1[i].ToString() };
newissue1.getChangeSet(jiraOps, jiraURL, token, username, password, projectKey, exportTargetPath, branch, svnOps, svnExePath, changesetDBFile, mgr);
}
//throw new Exception("Dependencies found");
}
}
}
在此,我正在遍历该mgr.Dependencis
集合。这个值在变化newissue1.getChangeSet(jiraOps, jiraURL, token, username, password, projectKey, exportTargetPath, branch, svnOps, svnExePath, changesetDBFile, mgr);
所以每次调用这个方法,我的收藏价值都在增加。但是第一次它工作正常。但是在第二次迭代时,它给出了异常
收藏已修改;枚举操作可能无法执行。
我认为这个例外是为了改变收藏。如何处理这种情况。?
我的类定义如下。
public class Dependency
{
public string issueID { get; set; }
public string jirastatus { get; set; }
public int dependencyFound { get; set; }
public string depends { get; set; }
public string linked_issues { get; set; }
}
public class DependencyManager
{
public List<Dependency> Dependencies { get; private set; }
public DependencyManager()
{
this.Dependencies = new List<Dependency>();
}
}