public static async Task WriteDataAsync(ObjectWriter writer, SolutionAssetStorage assetStorage, ISerializerService serializer, int scopeId, Checksum[] checksums, CancellationToken cancellationToken)
        {
            writer.WriteInt32(scopeId);

            // special case
            if (checksums.Length == 0)
            {
                writer.WriteInt32(0);
                return;
            }

            if (checksums.Length == 1)
            {
                var checksum = checksums[0];

                var asset = (await assetStorage.GetAssetAsync(scopeId, checksum, cancellationToken).ConfigureAwait(false)) ?? SolutionAsset.Null;
                writer.WriteInt32(1);

                WriteAsset(writer, serializer, checksum, asset, cancellationToken);
                return;
            }

            var assets = await assetStorage.GetAssetsAsync(scopeId, checksums, cancellationToken).ConfigureAwait(false);

            writer.WriteInt32(assets.Count);

            foreach (var(checksum, asset) in assets)
            {
                WriteAsset(writer, serializer, checksum, asset, cancellationToken);
            }
Ejemplo n.º 2
0
            public async ValueTask <SolutionAsset?> GetAssetAsync(Checksum checksum, CancellationToken cancellationToken)
            {
                foreach (var(scopeId, _) in _solutionAssetStorage._solutionStates)
                {
                    var data = await _solutionAssetStorage.GetAssetAsync(scopeId, checksum, cancellationToken).ConfigureAwait(false);

                    if (data != null)
                    {
                        return(data);
                    }
                }

                return(null);
            }