예제 #1
0
        /// <inheritdoc/>
        public EventSequenceNumber NextForType(IApplicationResourceIdentifier identifier)
        {
            var hashCode = identifier.GetHashCode();

            lock ( _sequenceLocksPerType )
            {
                if (!_sequenceLocksPerType.ContainsKey(hashCode))
                {
                    _sequenceLocksPerType[hashCode] = new object();
                }
            }

            lock (_sequenceLocksPerType[hashCode])
            {
                var identifierAsString = _applicationResourceIdentifierConverter.AsString(identifier);
                var file     = $"{SequenceForPrefix}{identifierAsString}";
                var sequence = GetNextInSequenceFromFile(file);
                _files.WriteString(_configuration.Path, file, sequence.ToString());
                return(sequence);
            }
        }
 /// <inheritdoc/>
 public int CompareTo(IApplicationResourceIdentifier other)
 {
     return(GetHashCode().CompareTo(other.GetHashCode()));
 }