From 2b97da850276c959f4e94b8d7e6cae95dbd3b18f Mon Sep 17 00:00:00 2001 From: jkpete <1031139173@qq.com> Date: Tue, 8 Oct 2024 11:14:12 +0800 Subject: [PATCH] change get properties pre --- Example/UsingTest/Script/EGSaveTest.cs | 14 +++++++------- addons/EGFramework/Module/SaveTools/EGCsvSave.cs | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Example/UsingTest/Script/EGSaveTest.cs b/Example/UsingTest/Script/EGSaveTest.cs index f1135ad..25f85e3 100644 --- a/Example/UsingTest/Script/EGSaveTest.cs +++ b/Example/UsingTest/Script/EGSaveTest.cs @@ -32,17 +32,17 @@ namespace EGFramework.Examples.Test{ // }; // csvSave.SetData("",testData,2) - IEnumerable allResult = csvSave.GetAll(""); - GD.Print("Get result " + allResult.Count()); - foreach(Customer customer in allResult){ - GD.Print(customer.Id +"|" + customer.Name); - } + // IEnumerable allResult = csvSave.GetAll(""); + // GD.Print("Get result " + allResult.Count()); + // foreach(Customer customer in allResult){ + // GD.Print(customer.Id +"|" + customer.Name); + // } - // System.Linq.Expressions.Expression> expr = i => i.Id < 5; + // System.Linq.Expressions.Expression> expr = i => i.Name == "Creature"; // IEnumerable linqResult = csvSave.FindData("",expr); // GD.Print("Find result " + linqResult.Count()); // foreach(Customer customer in linqResult){ - // GD.Print(customer.Name); + // GD.Print(customer.Id); // } // GD.Print(typeof(Customer)); diff --git a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs index c7a7d6c..8607e92 100644 --- a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs @@ -164,9 +164,10 @@ namespace EGFramework { // throw new NotImplementedException(); List DataList = new List(); + PropertyInfo[] properties = typeof(TData).GetProperties(); for (int dataID = 0; dataID < CsvDataBlock.Count(); dataID++){ TData data = new TData(); - foreach(PropertyInfo property in typeof(TData).GetProperties()){ + foreach(PropertyInfo property in properties){ CsvParamAttribute csvParam = property.GetCustomAttribute(); if(csvParam != null && CsvDataHeader.ContainsKey(csvParam._name)){ string valueStr = CsvDataBlock[dataID][CsvDataHeader[csvParam._name]];