public void TextReaderUtility_OpenRead_1()
        {
            string   expected = "Hello, world!";
            Encoding encoding = Encoding.ASCII;
            string   fileName = Path.GetTempFileName();

            File.WriteAllText(fileName, expected, encoding);

            using (TextReader reader = TextReaderUtility.OpenRead(fileName, encoding))
            {
                string actual = reader.ReadToEnd();
                Assert.AreEqual(expected, actual);
            }
        }
Ejemplo n.º 2
0
        public static IrbisAlphabetTable ParseLocalFile
        (
            [NotNull] string fileName
        )
        {
            Sure.NotNullNorEmpty(fileName, "fileName");

            using (StreamReader reader = TextReaderUtility.OpenRead
                                         (
                       fileName,
                       IrbisEncoding.Ansi
                                         ))
            {
                return(ParseText(reader));
            }
        }
Ejemplo n.º 3
0
        public static StringDictionary Load
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Sure.NotNullNorEmpty(fileName, nameof(fileName));
            Sure.NotNull(encoding, nameof(encoding));

            using (TextReader reader = TextReaderUtility.OpenRead
                                       (
                       fileName,
                       encoding
                                       ))
            {
                return(Load(reader));
            }
        }
Ejemplo n.º 4
0
        public static StringDictionary Load
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Code.NotNullNorEmpty(fileName, "fileName");
            Code.NotNull(encoding, "encoding");

            using (TextReader reader = TextReaderUtility.OpenRead
                                       (
                       fileName,
                       encoding
                                       ))
            {
                return(Load(reader));
            }
        }
Ejemplo n.º 5
0
        public static GblFile ParseLocalFile
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Sure.NotNull(fileName, "fileName");
            Sure.NotNull(encoding, "encoding");

            using (StreamReader reader = TextReaderUtility.OpenRead
                                         (
                       fileName,
                       encoding
                                         ))
            {
                GblFile result = ParseStream(reader);

                return(result);
            }
        }
Ejemplo n.º 6
0
        public static IrbisTreeFile ReadLocalFile
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Sure.NotNullNorEmpty(fileName, "fileName");
            Sure.NotNull(encoding, "encoding");

            using (StreamReader reader = TextReaderUtility.OpenRead
                                         (
                       fileName,
                       encoding
                                         ))
            {
                IrbisTreeFile result = ParseStream(reader);
                result.FileName = Path.GetFileName(fileName);

                return(result);
            }
        }
Ejemplo n.º 7
0
        public static MenuFile ParseLocalFile
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Sure.NotNullNorEmpty(fileName, nameof(fileName));
            Sure.NotNull(encoding, nameof(encoding));

            using (StreamReader reader = TextReaderUtility.OpenRead
                                         (
                       fileName,
                       encoding
                                         ))
            {
                MenuFile result = ParseStream(reader);
                result.FileName = Path.GetFileName(fileName);

                return(result);
            }
        }
Ejemplo n.º 8
0
        public static IrbisUpperCaseTable ParseLocalFile
        (
            [NotNull] string fileName
        )
        {
            Sure.NotNullNorEmpty(fileName, "fileName");

            using (StreamReader reader = TextReaderUtility.OpenRead
                                         (
                       fileName,
                       IrbisEncoding.Ansi
                                         ))
            {
                string text = reader.ReadToEnd();

                return(ParseText
                       (
                           IrbisEncoding.Ansi,
                           text
                       ));
            }
        }
Ejemplo n.º 9
0
        public static StreamParser FromFile
        (
            [NotNull] string fileName,
            [NotNull] Encoding encoding
        )
        {
            Sure.NotNull(fileName, nameof(fileName));
            Sure.FileExists(fileName, nameof(fileName));
            Sure.NotNull(encoding, nameof(encoding));

            StreamReader reader = TextReaderUtility.OpenRead
                                  (
                fileName,
                encoding
                                  );
            StreamParser result = new StreamParser
                                  (
                reader,
                true
                                  );

            return(result);
        }