Browse Source

fixed generator

master
jkpete 3 months ago
parent
commit
213546c490
  1. 2
      addons/EGFramework/Module/GenerateTools/DataGenerate/EGSvgGenerator.cs
  2. 43
      addons/EGFramework/Module/GenerateTools/DataGenerate/EGVariantGenerator.cs

2
addons/EGFramework/Module/GenerateTools/DataGenerate/EGSvgGenerator.cs

@ -1,4 +1,4 @@
namespace EGFramework{ namespace EGFramework.Generate{
public class EGSvgGenerator : IGenerateToolsInterface public class EGSvgGenerator : IGenerateToolsInterface
{ {
public string SvgHeader { get ; private set;} public string SvgHeader { get ; private set;}

43
addons/EGFramework/Module/GenerateTools/DataGenerate/EGVariantGenerator.cs

@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace EGFramework.Generate{
public static class EGenerateVariant{
public static Dictionary<string,object> EGenerateDictiontaryByObject<T>(this T self){
PropertyInfo[] propertyNames = typeof(T).GetProperties();
FieldInfo[] fieldNames = typeof(T).GetFields();
// object[] s = propertyNames.Select(p => p.GetValue(self)).ToArray();
// object[] a = fieldNames.Select(p => p.GetValue(self)).ToArray();
Dictionary<string,object> result = new Dictionary<string, object>();
foreach(PropertyInfo pName in propertyNames){
object p = pName.GetValue(self);
result.Add(pName.Name,p);
}
foreach(FieldInfo fName in fieldNames){
object p = fName.GetValue(self);
result.Add(fName.Name,p);
}
return result;
}
public static List<Dictionary<string,object>> EGenerateDictionaryByGroup<T>(this IEnumerable<T> self){
List<Dictionary<string,object>> result = new List<Dictionary<string, object>>();
PropertyInfo[] propertyNames = typeof(T).GetProperties();
FieldInfo[] fieldNames = typeof(T).GetFields();
foreach(T member in self){
Dictionary<string,object> mResult = new Dictionary<string, object>();
foreach(PropertyInfo pName in propertyNames){
object p = pName.GetValue(self);
mResult.Add(pName.Name,p);
}
foreach(FieldInfo fName in fieldNames){
object p = fName.GetValue(self);
mResult.Add(fName.Name,p);
}
result.Add(mResult);
}
return result;
}
}
}
Loading…
Cancel
Save