ProtocolBuffers.ProtoParser.Parse C# (CSharp) Method

Parse() public static method

public static Parse ( string path ) : Proto
path string
return Proto
        public static Proto Parse(string path)
        {
            Proto p = new Proto ();

            string t = "";

            using (TextReader reader = new StreamReader(path, Encoding.UTF8)) {
                while (true) {
                    string line = reader.ReadLine ();
                    if (line == null)
                        break;

                    t += line + "\n";
                }
            }

            TokenReader tr = new TokenReader (t);
            ProtoFormatException e = null;
            try {
                ParseMessages (tr, p);
                return p;
            } catch (ProtoFormatException pfe) {
                e = pfe;
            }
            Console.Write (tr.Parsed);
            Console.WriteLine (" <---");
            Console.WriteLine (e.Message);
            return null;
        }