Read() public method

public Read ( Stream data ) : void
data Stream
return void
示例#1
0
文件: Tag.cs 项目: mblaine/NbtViewer
        public override void Read(Stream data)
        {
            TagId = new TAG_Byte();
            TagId.Read(data);

            Length = new TAG_Int();
            Length.Read(data);

            Payload = new TAG[Length.Payload];
            for (Int32 i = 0; i < Length.Payload; i++)
            {
                switch ((TYPE)TagId.Payload)
                {
                    case TYPE.TAG_Byte:
                        Payload[i] = (TAG)new TAG_Byte(data);
                        break;
                    case TYPE.TAG_Short:
                        Payload[i] = (TAG)new TAG_Short(data);
                        break;
                    case TYPE.TAG_Int:
                        Payload[i] = (TAG)new TAG_Int(data);
                        break;
                    case TYPE.TAG_Long:
                        Payload[i] = (TAG)new TAG_Long(data);
                        break;
                    case TYPE.TAG_Float:
                        Payload[i] = (TAG)new TAG_Float(data);
                        break;
                    case TYPE.TAG_Double:
                        Payload[i] = (TAG)new TAG_Double(data);
                        break;
                    case TYPE.TAG_Byte_Array:
                        Payload[i] = (TAG)new TAG_Byte_Array(data);
                        break;
                    case TYPE.TAG_String:
                        Payload[i] = (TAG)new TAG_String(data);
                        break;
                    case TYPE.TAG_List:
                        Payload[i] = (TAG)new TAG_List(data);
                        break;
                    case TYPE.TAG_Compound:
                        Payload[i] = (TAG)new TAG_Compound(data, this);
                        break;
                    case TYPE.TAG_Int_Array:
                        Payload[i] = (TAG)new TAG_Int_Array(data);
                        break;
                    default:
                        throw new Exception("Unrecognized tag type.");
                }
            }
        }
示例#2
0
        public override void Read(Stream data)
        {
            TagId = new TAG_Byte();
            TagId.Read(data);

            Length = new TAG_Int();
            Length.Read(data);

            Payload = new TAG[Length.Payload];
            for (Int32 i = 0; i < Length.Payload; i++)
            {
                switch ((TYPE)TagId.Payload)
                {
                case TYPE.TAG_Byte:
                    Payload[i] = (TAG) new TAG_Byte(data);
                    break;

                case TYPE.TAG_Short:
                    Payload[i] = (TAG) new TAG_Short(data);
                    break;

                case TYPE.TAG_Int:
                    Payload[i] = (TAG) new TAG_Int(data);
                    break;

                case TYPE.TAG_Long:
                    Payload[i] = (TAG) new TAG_Long(data);
                    break;

                case TYPE.TAG_Float:
                    Payload[i] = (TAG) new TAG_Float(data);
                    break;

                case TYPE.TAG_Double:
                    Payload[i] = (TAG) new TAG_Double(data);
                    break;

                case TYPE.TAG_Byte_Array:
                    Payload[i] = (TAG) new TAG_Byte_Array(data);
                    break;

                case TYPE.TAG_String:
                    Payload[i] = (TAG) new TAG_String(data);
                    break;

                case TYPE.TAG_List:
                    Payload[i] = (TAG) new TAG_List(data);
                    break;

                case TYPE.TAG_Compound:
                    Payload[i] = (TAG) new TAG_Compound(data, this);
                    break;

                case TYPE.TAG_Int_Array:
                    Payload[i] = (TAG) new TAG_Int_Array(data);
                    break;

                default:
                    throw new Exception("Unrecognized tag type.");
                }
            }
        }