public IActionResult GetSample01()
        {
            Core.DataTableMap tableMap = Core.DataTableMapFactory.CreateTestMap();
            DataTableMap      mapDto   = MapToApiDto(tableMap);

            return(Ok(mapDto));
        }
        private DataTableMap MapToApiDto(Core.DataTableMap dataTableMap)
        {
            DataTableMap dto = new DataTableMap();

            dto.Columns = dataTableMap.Columns.Select(c => MapToApiDto(c)).ToList();
            return(dto);
        }
Ejemplo n.º 3
0
    private void OnDestroy()
    {
        EditorSceneManager.OpenScene("Assets/Scenes/Game.unity");

        tableMap.Clear();
        tableMap    = null;
        tableMapDic = null;

        tableMonster.Clear();
        tableMonster    = null;
        tableMonsterDic = null;

        tableMonsterRefresh.Clear();
        tableMonsterRefresh    = null;
        tableMonsterRefreshDic = null;

        tableNpc.Clear();
        tableNpc    = null;
        tableNpcDic = null;

        tableTransfer.Clear();
        tableTransfer    = null;
        tableTransferDic = null;

        tableModel.Clear();
        tableModel = null;
    }
        private static string InnerGet(string json)
        {
            DataTableMap dataTableMap = DataTableMapFactory.CreateTestMap();

            Json.DataMapper dataMapper = new Json.DataMapper();
            DataTable       dataTable  = dataMapper.ToDataTable(json, dataTableMap);

            Json.DataTableConverter dataTableJsonConverter = new Json.DataTableConverter();
            string jsonOutput = dataTableJsonConverter.ToString(dataTable);

            return(jsonOutput);
        }
Ejemplo n.º 5
0
        public async Task <DataTableMap> GetSample01Async()
        {
            string requestUri = $"{_controllerName}/GetSample01";

            try
            {
                DataTableMap dataTableMap = await _httpClient.GetJsonAsync <DataTableMap>(requestUri);

                return(dataTableMap);
            }
            catch (SerializationException e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Ejemplo n.º 6
0
        public void ExtractData()
        {
            EventMgr.Instance.TriggerEvent(GlobalEvent.DATA_LOAD_PROGRESS, "数据资源初始化...开始...", 3, 0);

            tableMap = ResourcesMgr.Instance.LoadResource <DataTableMap>(DataPath + "DataTableMap.asset");
            tableMap.Init();
            m_DataDic.Add("DataTableMap", tableMap);

            tableModel = ResourcesMgr.Instance.LoadResource <DataTableModel>(DataPath + "DataTableModel.asset");
            tableModel.Init();
            m_DataDic.Add("DataTableModel", tableModel);

            tableMonster = ResourcesMgr.Instance.LoadResource <DataTableMonster>(DataPath + "DataTableMonster.asset");
            tableMonster.Init();
            m_DataDic.Add("DataTableMonster", tableMonster);

            tableMonsterRefresh = ResourcesMgr.Instance.LoadResource <DataTableMonsterRefresh>(DataPath + "DataTableMonsterRefresh.asset");
            tableMonsterRefresh.Init();
            m_DataDic.Add("DataTableMonsterRefresh", tableMonsterRefresh);

            tableNpc = ResourcesMgr.Instance.LoadResource <DataTableNpc>(DataPath + "DataTableNpc.asset");
            tableNpc.Init();
            m_DataDic.Add("DataTableNpc", tableNpc);

            tableTransfer = ResourcesMgr.Instance.LoadResource <DataTableTransfer>(DataPath + "DataTableTransfer.asset");
            tableTransfer.Init();
            m_DataDic.Add("DataTableTransfer", tableTransfer);

            EventMgr.Instance.TriggerEvent(GlobalEvent.DATA_LOAD_PROGRESS, "数据资源初始化中...", 3, 30);



            EventMgr.Instance.TriggerEvent(GlobalEvent.DATA_LOAD_PROGRESS, "数据资源初始化中...", 3, 60);



            tableUI = ResourcesMgr.Instance.LoadResource <DataTableUi>(DataPath + "DataTableUi.asset");
            tableUI.Init();
            m_DataDic.Add("DataTableUi", tableUI);

            EventMgr.Instance.TriggerEvent(GlobalEvent.DATA_LOAD_PROGRESS, "数据资源初始化中...", 3, 90);


            EventMgr.Instance.TriggerEvent(DataConst.DATA_LOAD_COMPLETE);
            EventMgr.Instance.TriggerEvent(GlobalEvent.DATA_LOAD_PROGRESS, "数据资源初始化完成!!!", 3, 100);
        }
Ejemplo n.º 7
0
    void OnEnable()
    {
        selectTypeDic.Add(0, "Null");
        selectTypeDic.Add(1, "PlayerBorn");
        selectTypeDic.Add(2, "Monster");
        selectTypeDic.Add(3, "MonsterRefresh");
        selectTypeDic.Add(4, "Npc");
        selectTypeDic.Add(5, "Transfer");

        _scriptEditPath   = EditorPrefs.GetString(SAVE_EDIT_PATH, _scriptEditPath);
        _scriptClientPath = EditorPrefs.GetString(SAVE_CLIENT_PATH, _scriptClientPath);

        tableMap = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableMap.asset") as DataTableMap;
        tableMap.Init();
        tableMapDic = tableMap.GetInfo();

        tableMonster = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableMonster.asset") as DataTableMonster;
        tableMonster.Init();
        tableMonsterDic = tableMonster.GetInfo();

        tableMonsterRefresh = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableMonsterRefresh.asset") as DataTableMonsterRefresh;
        tableMonsterRefresh.Init();
        tableMonsterRefreshDic = tableMonsterRefresh.GetInfo();

        tableNpc = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableNpc.asset") as DataTableNpc;
        tableNpc.Init();
        tableNpcDic = tableNpc.GetInfo();

        tableTransfer = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableTransfer.asset") as DataTableTransfer;
        tableTransfer.Init();
        tableTransferDic = tableTransfer.GetInfo();

        tableModel = UnityEditor.AssetDatabase.LoadAssetAtPath <ScriptableObject>("Assets/Resources/Data/DataTableModel.asset") as DataTableModel;
        tableModel.Init();

        //ScriptableObject tempObj = UnityEditor.AssetDatabase.LoadAssetAtPath<ScriptableObject>("Assets/Resources/Data/DataTableUi.asset");
        //DataTableUi testAsset = tempObj as DataTableUi;
        //foreach (UiExcel gd in testAsset.DataList)
        //{
        //    Debug.Log(gd.id);
        //    Debug.Log(gd.name);
        //}
        //testAsset.Init();
        //UiExcel tempData = testAsset.GetInfoById(1);
        //Debug.Log(tempData.id);
    }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            string currentDirectory = Directory.GetCurrentDirectory();
            string p            = Path.Combine(currentDirectory, @"..\..\..\..\DataSamples\Json\sample01.json");
            String jsonFilePath = Path.GetFullPath(p);

            string outputPath = @"F:\Temp\DataFlattener";

            string json = File.ReadAllText(jsonFilePath);

            DataTableMap dataTableMap          = DataTableMapFactory.CreateTestMap();
            string       jsonMapOutputFilePath = GetFilePath(outputPath, "map.json");
            string       jsonMapOutput         = Serializer.Serialize(dataTableMap.Columns);

            File.WriteAllText(jsonMapOutputFilePath, jsonMapOutput);

            Json.DataMapper dataMapper = new Json.DataMapper();
            DataTable       dataTable  = dataMapper.ToDataTable(json, dataTableMap);

            Json.DataTableConverter dataTableJsonConverter = new Json.DataTableConverter();
            string jsonOutput         = dataTableJsonConverter.ToString(dataTable);
            string jsonOutputFilePath = GetFilePath(outputPath, "json");

            File.WriteAllText(jsonOutputFilePath, jsonOutput);

            Xml.DataTableConverter dataTableXmlConverter = new Xml.DataTableConverter();
            string xmlOutput         = dataTableXmlConverter.ToString(dataTable);
            string xmlOutputFilePath = GetFilePath(outputPath, "xml");

            File.WriteAllText(xmlOutputFilePath, xmlOutput);

            Csv.DataTableConverter dataTableCsvConverter = new Csv.DataTableConverter();
            string csvOutput         = dataTableCsvConverter.ToString(dataTable);
            string csvOutputFilePath = GetFilePath(outputPath, "csv");

            File.WriteAllText(csvOutputFilePath, csvOutput);

            Console.WriteLine("End");
            Console.WriteLine("Press [Enter] to exit...");
            Console.ReadLine();
        }
Ejemplo n.º 9
0
        public static DataTable ToDataTable(String json, DataTableMap tableMap)
        {
            JArray jArray = JArray.Parse(json);

            IEnumerable <JToken> childTokens = jArray.Children();

            DataTable dataTable = new DataTable("Rows");

            foreach (DataColumnMap columnMap in tableMap.Columns)
            {
                Type systemType = DataTypeHelper.ToSystemType(columnMap.DataType);
                dataTable.Columns.Add(columnMap.Name, systemType);
            }

            DataColumnMap[] columnMaps = tableMap.Columns.ToArray();

            foreach (JToken childToken in childTokens)
            {
                object[] values = ToValues(childToken, columnMaps);
                dataTable.Rows.Add(values);
            }

            return(dataTable);
        }
Ejemplo n.º 10
0
        public DataTable ToDataTable(String json, DataTableMap tableMap)
        {
            DataTable dataTable = MappingHelper.ToDataTable(json, tableMap);

            return(dataTable);
        }