Ejemplo n.º 1
0
 public ProtoBufferMessage(ProtoBufferFile file,List<Line> lines)
 {
     Dependents = new List<ProtoBufferFile>();
     Summarys = new List<string>();
     Fields = new List<ProtoBufferField>();
     File = file;
     Lines = lines;
 }
Ejemplo n.º 2
0
 public Line(ProtoBufferFile file, int lineNumber, string content)
 {
     File       = file;
     LineNumber = lineNumber;
     Content    = content.Trim();
 }
Ejemplo n.º 3
0
 public Line(ProtoBufferFile file,int lineNumber,string content)
 {
     File = file;
     LineNumber = lineNumber;
     Content = content.Trim();
 }
Ejemplo n.º 4
0
        private DataType FindDataTypeInFile(Line line, string name, ProtoBufferFile file)
        {
            DataType result = DataType.Null;
            foreach (ProtoBufferMessage msg in file.Messages)
            {
                if (msg.Name.Equals(name))
                {
                    result = msg.DataType;

            #if DEBUG

                    Console.WriteLine(string.Format("文件名:{0}中的第{1}行:{2}在文件{3}中找到对应类型:{4}",line.File.FileName,line.LineNumber,name,file.FileName,result == DataType.Class ?"message":"enum"));
            #endif
                    break;
                }
            }
            return result;
        }
Ejemplo n.º 5
0
        public ProtoBufferDic(string path):this()
        {
            Path = path;
            if (!Directory.Exists(path))
            {
                throw new ProtoBufferException(string.Format("找不到文件夹:{0}",path));
            }
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            FileInfo[] fileInfos = directoryInfo.GetFiles();
            foreach (FileInfo fileInfo in fileInfos)
            {
                if (fileInfo.Extension.Equals(".proto"))
                {
                    using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open))
                    {
                        try
                        {
                            using (StreamReader reader = new StreamReader(fs))
                            {
                                try
                                {
                                    List<string> list = new List<string>();
                                    while (!reader.EndOfStream)
                                    {
                                        list.Add(reader.ReadLine());
                                    }
                                    ProtoBufferFile file = new ProtoBufferFile(fileInfo.FullName,this,list);
                                    AddFile(file);
                                }
                                catch (Exception)
                                {

                                    throw;
                                }
                                finally
                                {
                                    reader.Close();
                                }
                            } 

                        }
                        catch (Exception)
                        {

                            throw;
                        }
                        finally
                        {
                            fs.Close();
                        }
                    }
                    

                }
            }


        }
Ejemplo n.º 6
0
 /// <summary>
 /// 测试使用
 /// </summary>
 /// <param name="file"></param>
 public void AddFile(ProtoBufferFile file)
 {
     Files.Add(file);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 测试使用
 /// </summary>
 /// <param name="file"></param>
 public void AddFile(ProtoBufferFile file)
 {
     Files.Add(file);
 }