Пример #1
0
        // 加载所有表
        static void LoadAllTable()
        {
            using (var stream = new FileStream("../../../../binary/table_gen.bin", FileMode.Open))
            {
                stream.Position = 0;

                var reader = new tabtoy.TableReader(stream);

                var tab = new main.Table();

                try
                {
                    tab.Deserialize(reader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                // 表遍历
                foreach (var kv in tab.ExampleData)
                {
                    Console.Write("{0} {1}\n", kv.ID, kv.Name);
                }

                // 直接取值
                Console.WriteLine(tab.ExtendData[1].Additive);

                // KV配置
                Console.WriteLine(tab.GetKeyValue_ExampleKV().ServerIP);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var curr = Directory.GetCurrentDirectory();

            using (var stream = new FileStream("../../../../binary/table_gen.bin", FileMode.Open))
            {
                stream.Position = 0;

                var reader = new tabtoy.TableReader(stream);


                var tab = new main.Table();

                try
                {
                    tab.Deserialize(reader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }


                Console.WriteLine(tab.ExampleData[3].Name);
            }
        }
Пример #3
0
        public static void LoadAllTable()
        {
            using (var stream = new FileStream(Application.dataPath + "/Resources/Excel/table_gen.bin", FileMode.Open))
            {
                stream.Position = 0;

                var reader = new tabtoy.TableReader(stream);

                var tab = new main.Table();

                try
                {
                    tab.Deserialize(reader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                // 表遍历
                foreach (var kv in tab.ExampleData)
                {
                    Debug.Log(kv.ID + "  " + kv.Name);
                }

                // 直接取值
                Debug.Log(tab.ExtendData[1].Additive);

                // KV配置
                Debug.Log(tab.GetKeyValue_ExampleKV().ServerIP);
            }
        }
Пример #4
0
        // 读取指定名字的表, 可根据实际需求调整该函数适应不同加载数据来源
        static void LoadTableByName(main.Table tab, string tableName)
        {
            using (var stream = new FileStream(string.Format("../../../../binary/{0}.bin", tableName), FileMode.Open))
            {
                stream.Position = 0;

                var reader = new tabtoy.TableReader(stream);
                try
                {
                    tab.Deserialize(reader);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }