/// </summary>\r
public static class CollectionExtensions\r
{\r
- public static IEnumerable<T> Replace<T>(this IEnumerable<T> list,Func<T,bool> match, Func<T,IEnumerable<T>> replace)\r
+ public static IEnumerable<T> Replace<T>(this IEnumerable<T> list,Func<T,bool> match, Func<T,IEnumerable<T>> generate)\r
{\r
foreach (var item in list)\r
{\r
if (match(item))\r
- foreach (var newItem in replace(item))\r
+ foreach (var newItem in generate(item))\r
{\r
yield return newItem;\r
}\r
*/\r
\r
var cleanRemotes = (from info in remoteObjects.Union(sharedObjects)\r
- let name = info.Name\r
+ let name = info.Name??""\r
where !name.EndsWith(".ignore", StringComparison.InvariantCultureIgnoreCase) &&\r
!name.StartsWith(FolderConstants.CacheFolder + "/",\r
StringComparison.InvariantCultureIgnoreCase)\r
return this;\r
}\r
\r
+\r
+ //The previous values that correspond to a NoModification object\r
+ //have the same account, container and possibly the same folder\r
+ Func<ObjectInfo, ObjectInfo, bool> correspondsTo = (info, noMod) => \r
+ info.Account == noMod.Account\r
+ && info.Container == noMod.Container\r
+ && (noMod.Name == null || info.Name.StartsWith(noMod.Name));\r
+\r
//Replace any NoModification entries with previous values that have\r
//the same account, container and possibly, folder\r
_current=list.Replace(\r
info => info is NoModificationInfo, \r
- noMod => from info in _previous\r
- where \r
- info.Account==noMod.Account \r
- && info.Container==noMod.Container \r
- //If the NoModification specifies a folder, use it to match items below this folder\r
- && (noMod.Name==null || info.Name.StartsWith(noMod.Name))\r
- select info);\r
+ noMod => _previous.Where(info => correspondsTo(info, noMod)))\r
+ .ToList();\r
\r
return this;\r
}\r