public bool TryGetValue(string key, out StringValues value)
        {
            if (_headers.TryGetValue(key, out value))
            {
                return(true);
            }

            ReadableBuffer buffer;

            if (_headerSlices.TryGetValue(key, out buffer))
            {
                value         = buffer.GetAsciiString();
                _headers[key] = value;
                return(true);
            }

            return(false);
        }
 public bool TryGetValue(string key, out StringValues value)
 {
     return(_headers.TryGetValue(key, out value));
 }
        public void UpdateValidity(IList <FileFragment> list, int index)
        {
            if (index < 0) //error
            {
                return;
            }
            else if (index == 0) //header
            {
                HeaderDictionary.TryGetValue(File.ReadAllBytes(list[index].Path), out HeaderType);
                list[index].Validity    = (HeaderType != NetworkGraphicTypes.Other) ? Validity.Valid : Validity.HardInvalid;
                list[index].Description = $"File type = {HeaderType} Network Graphics";
                return;
            }
            else //everything else
            {
                int chunkNumber = ((index - 1) / 4) + 1;
                switch (((index - 1) % 4) + 1) //Switch based on chunk type
                {
                case (1):                      //length
                    string lengthPath   = list[index].Path;
                    long   lengthLength = new FileInfo(lengthPath).Length;
                    if (lengthLength != 4)
                    {
                        list[index].Validity    = (lengthLength < 4) ? Validity.HardInvalid : Validity.Unknown;
                        list[index].Description = $"Chunk {chunkNumber} Length = <unkown>";
                    }
                    else if (lengthLength == 4)
                    {
                        int lengthData = BinaryFileInterpreter.ReadFileAs <int>(lengthPath, true);
                        list[index].Validity =
                            (lengthData == new FileInfo(list[index + 2].Path).Length)
                                ? Validity.Valid : Validity.HardInvalid;
                        list[index].Description = $"Chunk {chunkNumber} Length = {lengthData}";
                    }
                    break;

                case (2):     //type
                    byte[] typeData = File.ReadAllBytes(list[index].Path);
                    list[index].Validity =
                        IsValidChunkType(typeData)
                            ? Validity.Valid
                            : Validity.HardInvalid;
                    list[index].Description = $"Chunk {chunkNumber} Type = {Encoding.ASCII.GetString(typeData)}";     //HACK
                    goto case (4);

                case (3):     //data
                    string dataPath   = list[index].Path;
                    long   dataLength = new FileInfo(dataPath).Length;
                    if (dataLength > int.MaxValue)
                    {
                        list[index].Validity = Validity.HardInvalid;
                    }
                    else
                    {
                        int lengthData = BinaryFileInterpreter.ReadFileAs <int>(list[index - 2].Path, true);
                        if (FixLength && dataLength != lengthData)
                        {
                            File.WriteAllBytes(list[index - 2].Path, ((int)dataLength).GetBytes(true));
                            list[index - 2].Description = $"Chunk {chunkNumber} Length = {dataLength}";
                            list[index - 2].Validity    = Validity.Valid;
                        }
                        list[index].Validity = (FixLength || dataLength == lengthData) ? Validity.Valid : Validity.HardInvalid;
                    }
                    list[index].Description = $"Chunk {chunkNumber} Data length = {dataLength}";
                    goto case (4);

                case (4):                                            //crc
                    //int chunkStart = (((index - 1) / 4) * 4) + 1;
                    int    chunkStart = ((chunkNumber - 1) * 4) + 1; //Using this since this case is goto'd a few times
                    byte[] correctCRC = CalculateCRCOf(
                        File.ReadAllBytes(list[chunkStart + 1].Path)
                        .Concat(File.ReadAllBytes(list[chunkStart + 2].Path))
                        .ToArray());
                    byte[] currentCRC = File.ReadAllBytes(list[chunkStart + 3].Path);
                    if (!correctCRC.SequenceEqual(currentCRC))
                    {
                        if (FixCRC)
                        {
                            File.WriteAllBytes(list[chunkStart + 3].Path, correctCRC);
                        }
                        list[chunkStart + 3].Validity = (FixCRC)
                                ? Validity.Valid
                                : Validity.HardInvalid;
                    }
                    else
                    {
                        list[chunkStart + 3].Validity = Validity.Valid;
                    }
                    list[chunkStart + 3].Description = $"Chunk {chunkNumber} CRC (Big Endian) = {currentCRC.ConvertTo<uint>(true)}";
                    break;
                }
                return;
            }
        }