示例#1
0
        public static Symbol Load(BinaryReader br)
        {
            SymbolType type = (SymbolType)br.ReadByte();
            Symbol     sym;

            switch (type)
            {
            case PunctuationSymbol.SymType:
                sym = new PunctuationSymbol((PunctuationType)br.ReadByte());
                break;

            case WordSymbol.SymType:
                sym = new WordSymbol(br.ReadString());
                break;

            case TerminateSymbol.SymType:
                sym = new TerminateSymbol();
                break;

            case UrlSymbol.SymType:
                sym = new UrlSymbol(br.ReadString());
                break;

            default:
                throw new InvalidOperationException();
            }
            return(sym);
        }
示例#2
0
 public static Symbol Load(BinaryReader br)
 {
     SymbolType type = (SymbolType)br.ReadByte();
     Symbol sym;
     switch (type)
     {
         case PunctuationSymbol.SymType:
             sym = new PunctuationSymbol((PunctuationType)br.ReadByte());
             break;
         case WordSymbol.SymType:
             sym = new WordSymbol(br.ReadString());
             break;
         case TerminateSymbol.SymType:
             sym = new TerminateSymbol();
             break;
         case UrlSymbol.SymType:
             sym = new UrlSymbol(br.ReadString());
             break;
         default:
             throw new InvalidOperationException();
     }
     return sym;
 }