GenerateDocumentKeyAsync() public method

Generates the document key.
public GenerateDocumentKeyAsync ( IAsyncDatabaseCommands databaseCommands, DocumentConvention convention, object entity ) : Task
databaseCommands IAsyncDatabaseCommands
convention DocumentConvention The convention.
entity object The entity.
return Task
        public Task <string> GenerateDocumentKeyAsync(IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
        {
            var typeTagName = conventions.GetDynamicTagName(entity);

            if (string.IsNullOrEmpty(typeTagName)) //ignore empty tags
            {
                return(CompletedTask.With <string>(null));
            }
            var tag = conventions.TransformTypeTagNameToDocumentKeyPrefix(typeTagName);
            AsyncHiLoKeyGenerator value;

            if (keyGeneratorsByTag.TryGetValue(tag, out value))
            {
                return(value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity));
            }

            lock (generatorLock)
            {
                if (keyGeneratorsByTag.TryGetValue(tag, out value))
                {
                    return(value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity));
                }

                value = new AsyncHiLoKeyGenerator(tag, capacity);
                keyGeneratorsByTag.TryAdd(tag, value);
            }

            return(value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity));
        }
		public Task<string> GenerateDocumentKeyAsync(IAsyncDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
		{
		    var typeTagName = conventions.GetTypeTagName(entity.GetType());
			if (string.IsNullOrEmpty(typeTagName)) //ignore empty tags
				return CompletedTask.With<string>(null);
			var tag = conventions.TransformTypeTagNameToDocumentKeyPrefix(typeTagName);
			AsyncHiLoKeyGenerator value;
			if (keyGeneratorsByTag.TryGetValue(tag, out value))
				return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);

			lock(generatorLock)
			{
				if (keyGeneratorsByTag.TryGetValue(tag, out value))
					return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);

				value = new AsyncHiLoKeyGenerator(tag, capacity);
				keyGeneratorsByTag.TryAdd(tag, value);
			}

			return value.GenerateDocumentKeyAsync(databaseCommands, conventions, entity);
		}