Achamenes.ID3.Frames.Parsers.FrameParser.Parse C# (CSharp) Метод

Parse() публичный статический Метод

This function parses the next frame from the stream and returns it.
/// Thrown if the FrameParserFactory object passed did not recognize the Frame ID for the given version. ///
public static Parse ( System stream, ID3v2MajorVersion version, FrameParserFactory parserFactory, string &frameID ) : Frame
stream System The stream to parse the Frame from.
version ID3v2MajorVersion The ID3 v2 Major version of the ID3 tag that the stream is reading.
parserFactory FrameParserFactory A FrameParserFactory to use to create FrameParsers based on Frame IDs.
frameID string Output: outputs the frameID of the frame just parsed.
Результат Frame
        public static Frame Parse(System.IO.Stream stream, ID3v2MajorVersion version, FrameParserFactory parserFactory, out string frameID)
        {
            FrameHeaderParser headerParser=FrameHeaderParser.CreateFrameHeaderParser(version);
            FrameHeader header=headerParser.Parse(stream);
            frameID="";
            if(header==null) // have reached the padding, no more frames.
            {
                return null;
            }
            frameID=header.FrameID;

            if(header.Length > 128*128*128*128)
            {
                throw new FatalException("Invalid frame length for frame with frame ID '"+frameID+"'.");
            }

            byte[] frameData=new byte[header.Length];
            stream.Read(frameData, 0, frameData.Length);
            FrameParser parser=parserFactory.CreateFrameParser(version,header.FrameID);
            if(parser==null)
            {
                throw new NoFrameParserProvidedException(frameID,version, "No frame parser object is provided to parse this type of frame in this implementation.");
            }
            return parser.ParseFrame(frameData);
        }