51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
using CommonSerializeDefine;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CommonSerializing
|
|
{
|
|
public class Serializer : SerializerBase, ISerializer
|
|
{
|
|
public IEnumerable<KeyValuePair<string, string>> Serialize(Type targetType, object obj)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public string SerializeData(Type targetType, object data)
|
|
{
|
|
ITypeSerializer serializer = EnsureSerializer(targetType);
|
|
return serializer.Serialize(data, targetType, this);
|
|
}
|
|
|
|
private IEnumerable<FieldInfo> GetFields(Type targetType)
|
|
{
|
|
foreach (var item in targetType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
|
|
{
|
|
yield return item;
|
|
}
|
|
}
|
|
|
|
//private IEnumerable<KeyValuePair<string, FieldInfo>> FlattenFields(object obj, List<string> stack)
|
|
//{
|
|
// Type type = obj.GetType();
|
|
// foreach (var item in GetFields(type))
|
|
// {
|
|
// Type fieldType = item.FieldType;
|
|
// ITypeSerializer typeSerializer = TryGetSerializer(fieldType);
|
|
// if (typeSerializer != null)
|
|
// {
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
}
|