483 {
484 Encoder encoder = (Encoder)baseEncoder;
485 int num = 0;
486 int num2 = -1;
488 if (encoder != null)
489 {
490 num = encoder.bits;
491 num2 = encoder.bitCount;
492 while (num2 >= 6)
493 {
494 num2 -= 6;
495 if (!encodingByteBuffer.AddByte(
_base64Bytes[(num >> num2) & 0x3F]))
496 {
498 }
499 }
500 }
501 while (encodingByteBuffer.MoreData)
502 {
503 char nextChar = encodingByteBuffer.GetNextChar();
505 {
506 if (num2 >= 0)
507 {
508 if (num2 > 0)
509 {
510 if (!encodingByteBuffer.AddByte(
_base64Bytes[(num << 6 - num2) & 0x3F]))
511 {
512 break;
513 }
514 num2 = 0;
515 }
516 if (!encodingByteBuffer.AddByte(45))
517 {
518 break;
519 }
520 num2 = -1;
521 }
522 if (!encodingByteBuffer.AddByte((byte)nextChar))
523 {
524 break;
525 }
526 continue;
527 }
528 if (num2 < 0 && nextChar == '+')
529 {
530 if (!encodingByteBuffer.AddByte((byte)43, (byte)45))
531 {
532 break;
533 }
534 continue;
535 }
536 if (num2 < 0)
537 {
538 if (!encodingByteBuffer.AddByte(43))
539 {
540 break;
541 }
542 num2 = 0;
543 }
544 num = (num << 16) | nextChar;
545 num2 += 16;
546 while (num2 >= 6)
547 {
548 num2 -= 6;
549 if (!encodingByteBuffer.AddByte(
_base64Bytes[(num >> num2) & 0x3F]))
550 {
551 num2 += 6;
552 encodingByteBuffer.GetNextChar();
553 break;
554 }
555 }
556 if (num2 >= 6)
557 {
558 break;
559 }
560 }
561 if (num2 >= 0 && (encoder == null || encoder.MustFlush))
562 {
563 if (num2 > 0 && encodingByteBuffer.AddByte(
_base64Bytes[(num << 6 - num2) & 0x3F]))
564 {
565 num2 = 0;
566 }
567 if (encodingByteBuffer.AddByte(45))
568 {
569 num = 0;
570 num2 = -1;
571 }
572 else
573 {
574 encodingByteBuffer.GetNextChar();
575 }
576 }
577 if (
bytes !=
null && encoder !=
null)
578 {
579 encoder.bits = num;
580 encoder.bitCount = num2;
581 encoder._charsUsed = encodingByteBuffer.CharsUsed;
582 }
583 return encodingByteBuffer.Count;
584 }
void ThrowBytesOverflow()