Ejemplo n.º 1
0
        public BlobType GetContentType()
        {
            if (!IsInitialized)
            {
                return(BlobType.Empty);
            }
            // Check if blob starts with key name
            var step = FitsKey.EntrySizeInBytes;
            var size = FitsKey.NameSize * FitsKey.CharSizeInBytes;
            ReadOnlySpan <byte> span = Data;

            // If not a key, assume it is data
            if (!FitsKey.IsValidKeyName(span.Slice(0, size), true))
            {
                return(BlobType.Data);
            }

            // Now check all remaining keys
            var counter = 1;

            for (var i = 1; i < KeysPerBlob; i++)
            {
                counter += FitsKey.IsValidKeyName(span.Slice(i * step, size), true) ? 1 : 0;
            }

            return(counter == KeysPerBlob ? BlobType.FitsHeader : BlobType.Corrupted);
        }
Ejemplo n.º 2
0
        public ImmutableArray <IFitsValue> AsKeyCollection()
        {
            var builder = ImmutableArray.CreateBuilder <IFitsValue>(SizeInBytes / FitsKey.EntrySizeInBytes);
            ReadOnlySpan <byte> data = Data;

            for (var i = 0; i < KeysPerBlob; i++)
            {
                var newKey = FitsKey.ParseRawData(data.Slice(i * FitsKey.EntrySizeInBytes));

                if (newKey is { })