Example #1
0
        public virtual void Write(Proto proto, Dictionary<string, string> config)
        {
            string ext;
            if (Extension.StartsWith("."))
                ext = Extension.Substring(1);
            else
                ext = Extension;

            string directory = config["dir"];
            m_config = config;
            m_proto = proto;
            m_output = String.Format("{0}/{1}.{2}", directory, proto.Name, Extension);
            m_writer = new StreamWriter(File.Open(m_output, FileMode.Create));
            BeginWrite();
            // εΊεˆ—εŒ–
            for (int i = 0; i < m_proto.Imports.Count; ++i)
            {
                WriteImport(m_proto.Imports[i]);
            }
            m_writer.WriteLine();
            for (int i = 0; i < m_proto.Messages.Count; ++i)
            {
                Message msg = m_proto.Messages[i];
                if (msg.type == CmdType.ENUM)
                    WriteEnum(msg);
                else
                    WriteStruct(msg);
                m_writer.WriteLine();
            }
            EndWrite();
            m_writer.Close();
        }
Example #2
0
 public void Process()
 {
     if (m_input.Count == 0)
         m_input.Add("./proto/");
     foreach (var path in m_input)
     {
         DirectoryInfo di = new DirectoryInfo(path);
         FileInfo[] files = di.GetFiles("*.proto");
         for (int i = 0; i < files.Length; ++i)
         {
             Proto proto = new Proto(files[i].FullName);
             proto.Parse();
             m_protos.Add(proto);
         }
     }
     Check();
     Output();
 }