public async Task <Possible <int, Failure> > IncorporateRecordsAsync(IEnumerable <Task <StrongFingerprint> > strongFingerprints, Guid activityId) { Contract.Requires(!IsClosed); Contract.Requires(strongFingerprints != null); Contract.Assert(!IsReadOnly); using (var counter = m_counters.IncorporateRecordsCounter()) { using (var eventing = new IncorporateRecordsActivity(BasicFilesystemCache.EventSource, activityId, this)) { eventing.Start(); int count = 0; if (m_sessionId != null) { foreach (var strongTask in strongFingerprints) { StrongFingerprint strong = await strongTask; if (!Contains(strong)) { // Validate that we have the strong fingerprint if (!m_cache.StrongFingerprintExists(strong)) { // Strong fingerprint not found return(eventing.StopFailure(new NoMatchingFingerprintFailure(strong))); } // Add it to our session since we don't have it already AddSessionRecord(strong); counter.NewRecord(); count++; } else { counter.DupRecord(); } } } return(eventing.Returns(count)); } } }