public static SurfaceCommand Parse(BinaryReader fp) { UInt16 cmdType; SurfaceCommand cmd = null; cmdType = fp.ReadUInt16(); switch (cmdType) { case CMDTYPE_SET_SURFACE_BITS: cmd = new SetSurfaceBitsCommand(); cmd.Read(fp); break; case CMDTYPE_STREAM_SURFACE_BITS: cmd = new StreamSurfaceBitsCommand(); cmd.Read(fp); break; case CMDTYPE_FRAME_MARKER: cmd = new FrameMarkerCommand(); cmd.Read(fp); break; default: Console.WriteLine("Unknown Surface Command: {0}", cmdType); break; } return(cmd); }