//
// System.IO.TextReader
//
// Authors:
//   Marcin Szczepanski (marcins@zipworld.com.au)
//   Miguel de Icaza (miguel@gnome.org)
//
import { IDisposable_$type, Base, typeCast, markType } from "./type";
import { ArgumentNullException } from "./ArgumentNullException";
import { stringEmpty } from "./string";
export class TextReader extends Base {
    constructor() {
        super();
    }
    static staticInit() {
        TextReader.e = new TextReader_NullTextReader();
    }
    i() {
        this.dispose1(true);
    }
    dispose() {
        this.dispose1(true);
    }
    dispose1(a) {
        if (a) {
        }
        return;
    }
    a() {
        return -1;
    }
    b() {
        return -1;
    }
    c(a, b, c) {
        let d, e;
        for (e = 0; e < c; e++) {
            if ((d = this.b()) == -1) {
                return e;
            }
            a[b + e] = String.fromCharCode(d);
        }
        return e;
    }
    d(a, b, c) {
        let d = 0;
        let e = 0;
        do {
            e = this.c(a, b, c);
            b += e;
            d += e;
            c -= e;
        } while (e != 0 && c > 0);
        return d;
    }
    g() {
        return stringEmpty();
    }
    h() {
        return stringEmpty();
    }
    static f(a) {
        if (a == null) {
            throw new ArgumentNullException(0, "reader is null");
        }
        if (typeCast(SynchronizedReader.$, a) !== null) {
            return a;
        }
        return new SynchronizedReader(a);
    }
}
TextReader.e = null;
TextReader.$t = markType(TextReader, 'TextReader', Base.$, [IDisposable_$type]);
export class TextReader_NullTextReader extends TextReader {
    g() {
        return null;
    }
}
TextReader_NullTextReader.$t = markType(TextReader_NullTextReader, 'TextReader_NullTextReader', TextReader.$);
export class SynchronizedReader extends TextReader {
    constructor(a) {
        super();
        this.k = null;
        this.k = a;
    }
    i() {
        this.k.i();
    }
    a() {
        return this.k.a();
    }
    d(a, b, c) {
        return this.k.d(a, b, c);
    }
    g() {
        return this.k.g();
    }
    h() {
        return this.k.h();
    }
    b() {
        return this.k.b();
    }
    c(a, b, c) {
        return this.k.c(a, b, c);
    }
}
SynchronizedReader.$t = markType(SynchronizedReader, 'SynchronizedReader', TextReader.$);
/*<BeginStatics Name="System.IO.TextReader" />*/
/*<EndStatics Name="System.IO.TextReader" />*/
//# sourceMappingURL=TextReader_combined.js.map