예제 #1
0
        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);
        }
예제 #2
0
        public static void test9()
        {
            var t = Type.GetType("Bestan.Common.Config.excel_proto");

            foreach (var field in t.GetMethods())
            {
                Console.WriteLine(field.Name);
            }
            var obj = (excel_proto)Activator.CreateInstance(t);

            t.GetMethod("set_Md5").Invoke(obj, new string[] { "aaa" });
            Console.WriteLine(t.GetMethod("get_Md5").Invoke(obj, null));

            var dataType = Enum.Parse <DATA_TYPE>("INT");

            Console.WriteLine(dataType);
            test_python_all va = new test_python_all();

            foreach (var it in va.Configs)
            {
            }
        }
예제 #3
0
        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());
        }