public static void Test5() { string path = "test_python.dat"; FileStream file; try { file = new FileStream(path, FileMode.Open); } catch (Exception e) { Console.WriteLine("GenerateProto failed:打开文件" + path + "失败,error=" + e.Message); return; } if (file.Length <= 0) { Console.WriteLine("GenerateProto failed:文件" + path + "为空"); file.Close(); return; } test_python_all all = new test_python_all(); all.MergeFrom(file); Console.WriteLine("all=" + all); }
public static void Test2() { excel_path_full pathInfo = new excel_path_full(); excel_path_cell tempCellPath; excel_section tempSection; //id tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "id"; tempSection.DataType = excel_section.Types.DATA_TYPE.Int32; //count tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "count"; tempSection.DataType = excel_section.Types.DATA_TYPE.String; //value1 tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "value"; tempSection.Index = 1; tempSection.DataType = excel_section.Types.DATA_TYPE.Int32; //value2 tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "value"; tempSection.Index = 2; tempSection.DataType = excel_section.Types.DATA_TYPE.Int32; //skill-id tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "skill"; tempSection.Index = 1; tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "id"; tempSection.Index = 0; tempSection.DataType = excel_section.Types.DATA_TYPE.Double; //skill-rate tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "skill"; tempSection.Index = 1; tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "rate"; tempSection.Index = 0; tempSection.DataType = excel_section.Types.DATA_TYPE.Int32; //skill2-id tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "skill"; tempSection.Index = 2; tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "id"; tempSection.Index = 0; tempSection.DataType = excel_section.Types.DATA_TYPE.Double; //skill2-rate tempCellPath = new excel_path_cell(); pathInfo.Paths.Add(tempCellPath); tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "skill"; tempSection.Index = 2; tempSection = new excel_section(); tempCellPath.CellPath.Add(tempSection); tempSection.Section = "rate"; tempSection.Index = 0; tempSection.DataType = excel_section.Types.DATA_TYPE.Int32; string[] descList = { "7", "aa6", "5", "4", "3.111", "2", "10.22", "11" }; GetInstance().excelScript.ImportPath(pathInfo, "test_python_all"); GetInstance().excelScript.AddLineData(descList); test_python_all all = new test_python_all(); all.MergeFrom(GetInstance().excelScript.OutputData()); Console.WriteLine("all=" + all.ToString()); }