Add project files.

This commit is contained in:
2022-09-30 17:32:21 +08:00
parent df69e65c88
commit e8e36b83bd
561 changed files with 40626 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
namespace Cryville.Common.Plist {
public class PlistConvert {
public static T Deserialize<T>(string file) {
return (T)Deserialize(typeof(T), PlistCS.Plist.readPlist(file));
}
public static object Deserialize(Type type, object obj, Binder binder = null) {
if (binder == null)
binder = BinderAttribute.CreateBinderOfType(type);
if (obj is IList) {
var lobj = (List<object>)obj;
foreach (var i in lobj) {
throw new NotImplementedException(); // TODO
}
}
else if (obj is IDictionary) {
var dobj = (Dictionary<string, object>)obj;
if (typeof(IDictionary).IsAssignableFrom(type)) {
var result = (IDictionary)ReflectionHelper.InvokeEmptyConstructor(type);
var it = type.GetGenericArguments()[1];
foreach (var i in dobj) {
var value = Deserialize(it, i.Value, binder);
result.Add(i.Key, value);
}
return result;
}
else {
var result = ReflectionHelper.InvokeEmptyConstructor(type);
foreach (var i in dobj) {
var imis = type.GetMember(i.Key);
if (imis.Length == 0) continue;
var imi = imis[0];
var it = ReflectionHelper.GetMemberType(imi);
var value = Deserialize(it, i.Value, binder);
ReflectionHelper.SetValue(imi, result, value, binder);
}
return result;
}
}
else return obj;
throw new Exception(); // TODO
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3bc71e8b62d4022409aa5518bbf3a7d8
timeCreated: 1608801352
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: