public int Modify(SubscriptionCacheEntry entry, SendAsState sendAsState, AggregationStatus status) { int index = -1; this.ForFirstEntryByIdThenAddress(entry, delegate(int i) { if (!SubscriptionManager.IsValidForSendAs(sendAsState, status)) { this.cacheEntries.RemoveAt(i); index = i; return; } if (this.cacheEntries[i].Id.Equals(entry.Id)) { int num = this.cacheEntries[i].CompareTo(entry); if (num == 0 && entry.DisplayNameMatch(this.cacheEntries[i])) { index = -2; return; } if (0 < num) { while (0 < i) { if (0 >= this.cacheEntries[i - 1].CompareTo(entry)) { break; } this.cacheEntries[i] = this.cacheEntries[--i]; } } else if (0 > num) { while (this.cacheEntries.Count - 1 > i && 0 > this.cacheEntries[i + 1].CompareTo(entry)) { this.cacheEntries[i] = this.cacheEntries[++i]; } } } this.cacheEntries[i] = entry; index = i; }); if (-1 == index && SubscriptionManager.IsValidForSendAs(sendAsState, status)) { index = this.Add(entry); } return(index); }