public void AssertValid() { if (Registry == null) { throw new InvalidOperationException(string.Format("The Registry must not be Null.")); } Registry.AssertValid(); if (Files == null) { throw new InvalidOperationException(string.Format("The Files collection must not be Null.")); } var hashFolderIds = new Dictionary <string, bool>(); foreach (FolderXml folderxml in Files) { folderxml.AssertValid(); if (hashFolderIds.ContainsKey(folderxml.Id)) { throw new InvalidOperationException(string.Format("Duplicate folder ID “{0}”.", folderxml.Id)); } hashFolderIds.Add(folderxml.Id, true); } }