public LinkIndex Update(IList <LinkIndex> restrictions, IList <LinkIndex> substitution) { var sequence = restrictions.SkipFirst(); var newSequence = substitution.SkipFirst(); if (sequence.IsNullOrEmpty() && newSequence.IsNullOrEmpty()) { return(Constants.Null); } if (sequence.IsNullOrEmpty()) { return(Create(substitution)); } if (newSequence.IsNullOrEmpty()) { Delete(restrictions); return(Constants.Null); } return(_sync.ExecuteWriteOperation((Func <ulong>)(() => { ILinksExtensions.EnsureLinkIsAnyOrExists <ulong>(Links, (IList <ulong>)sequence); Links.EnsureLinkExists(newSequence); return UpdateCore(sequence, newSequence); }))); }