Init
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class DictionaryEntrySerializer : BasicQcSerializer<DictionaryEntry>
|
||||
{
|
||||
public override string SerializeFormatted(DictionaryEntry value, QuantumTheme theme)
|
||||
{
|
||||
string innerKey = SerializeRecursive(value.Key, theme);
|
||||
string innerValue = SerializeRecursive(value.Value, theme);
|
||||
|
||||
return $"{innerKey}: {innerValue}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f5ea7a0667903a4a81ff2b0253cf886
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class IDictionarySerializer : IEnumerableSerializer<IDictionary>
|
||||
{
|
||||
protected override IEnumerable GetObjectStream(IDictionary value)
|
||||
{
|
||||
foreach (DictionaryEntry item in value)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecd3d9e7bdfeaa1478f9a208e8251397
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using QFSW.QC.Pooling;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class IEnumerableSerializer : IEnumerableSerializer<IEnumerable>
|
||||
{
|
||||
public override int Priority => base.Priority - 1000;
|
||||
|
||||
protected override IEnumerable GetObjectStream(IEnumerable value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class IEnumerableSerializer<T> : PolymorphicQcSerializer<T> where T : class, IEnumerable
|
||||
{
|
||||
private readonly StringBuilderPool _builderPool = new StringBuilderPool();
|
||||
|
||||
public override string SerializeFormatted(T value, QuantumTheme theme)
|
||||
{
|
||||
Type type = value.GetType();
|
||||
StringBuilder builder = _builderPool.GetStringBuilder();
|
||||
|
||||
string left = "[";
|
||||
string seperator = ",";
|
||||
string right = "]";
|
||||
if (theme)
|
||||
{
|
||||
theme.GetCollectionFormatting(type, out left, out seperator, out right);
|
||||
}
|
||||
|
||||
builder.Append(left);
|
||||
|
||||
bool firstIteration = true;
|
||||
foreach (object item in GetObjectStream(value))
|
||||
{
|
||||
if (firstIteration)
|
||||
{
|
||||
firstIteration = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append(seperator);
|
||||
}
|
||||
|
||||
builder.Append(SerializeRecursive(item, theme));
|
||||
}
|
||||
|
||||
builder.Append(right);
|
||||
|
||||
return _builderPool.ReleaseAndToString(builder);
|
||||
}
|
||||
|
||||
protected abstract IEnumerable GetObjectStream(T value);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85d1c77e99db74c4786c67db88eed3ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#if !NET_STANDARD_2_0
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class ITupleSerializer : PolymorphicQcSerializer<ITuple>
|
||||
{
|
||||
public override string SerializeFormatted(ITuple value, QuantumTheme theme)
|
||||
{
|
||||
string[] serializedItems = new string[value.Length];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
{
|
||||
serializedItems[i] = SerializeRecursive(value[i], theme);
|
||||
}
|
||||
|
||||
return $"({string.Join(", ", serializedItems)})";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a98f9dc2d30e50a4ea3e6b10d5af4d1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class KeyValuePairSerializer : GenericQcSerializer
|
||||
{
|
||||
protected override Type GenericType { get; } = typeof(KeyValuePair<,>);
|
||||
|
||||
private readonly Dictionary<Type, PropertyInfo> _keyPropertyLookup = new Dictionary<Type, PropertyInfo>();
|
||||
private readonly Dictionary<Type, PropertyInfo> _valuePropertyLookup = new Dictionary<Type, PropertyInfo>();
|
||||
|
||||
public override string SerializeFormatted(object value, QuantumTheme theme)
|
||||
{
|
||||
Type type = value.GetType();
|
||||
PropertyInfo keyProperty;
|
||||
PropertyInfo valueProperty;
|
||||
|
||||
if (_keyPropertyLookup.ContainsKey(type))
|
||||
{
|
||||
keyProperty = _keyPropertyLookup[type];
|
||||
}
|
||||
else
|
||||
{
|
||||
keyProperty = type.GetProperty("Key");
|
||||
_keyPropertyLookup[type] = keyProperty;
|
||||
}
|
||||
|
||||
if (_valuePropertyLookup.ContainsKey(type))
|
||||
{
|
||||
valueProperty = _valuePropertyLookup[type];
|
||||
}
|
||||
else
|
||||
{
|
||||
valueProperty = type.GetProperty("Value");
|
||||
_valuePropertyLookup[type] = valueProperty;
|
||||
}
|
||||
|
||||
string innerKey = SerializeRecursive(keyProperty.GetValue(value, null), theme);
|
||||
string innerValue = SerializeRecursive(valueProperty.GetValue(value, null), theme);
|
||||
|
||||
return $"{innerKey}: {innerValue}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90dd2bea123ca7a43b2aee4e0985bd0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "QFSW.QC.Serializers",
|
||||
"references": [
|
||||
"QFSW.QC"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2b4ba6eb36b7bb49beadaf8e4db329a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class StringSerializer : BasicQcSerializer<string>
|
||||
{
|
||||
public override int Priority => int.MaxValue;
|
||||
|
||||
public override string SerializeFormatted(string value, QuantumTheme theme)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7a677dc32186804cb64e985537c4e21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using QFSW.QC.Utilities;
|
||||
using System;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class TypeSerialiazer : PolymorphicQcSerializer<Type>
|
||||
{
|
||||
public override string SerializeFormatted(Type value, QuantumTheme theme)
|
||||
{
|
||||
return value.GetDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0081da50a0ad3743b7adaa7f49a327d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class UnityObjectSerializer : PolymorphicQcSerializer<Object>
|
||||
{
|
||||
public override string SerializeFormatted(Object value, QuantumTheme theme)
|
||||
{
|
||||
return value.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85179674c3db5514082e498f38a169d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class Vector2IntSerializer : BasicQcSerializer<Vector2Int>
|
||||
{
|
||||
public override string SerializeFormatted(Vector2Int value, QuantumTheme theme)
|
||||
{
|
||||
return $"({value.x}, {value.y})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c966e27c828cfa84b80e8bf5c057176b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class Vector2Serializer : BasicQcSerializer<Vector2>
|
||||
{
|
||||
public override string SerializeFormatted(Vector2 value, QuantumTheme theme)
|
||||
{
|
||||
return $"({value.x}, {value.y})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84fbe7c52769e5049af7ac1c1ccf0c1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class Vector3IntSerializer : BasicQcSerializer<Vector3Int>
|
||||
{
|
||||
public override string SerializeFormatted(Vector3Int value, QuantumTheme theme)
|
||||
{
|
||||
return $"({value.x}, {value.y}, {value.z})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e04a3eb24be1a7f4f80c1c53290fed34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class Vector3Serializer : BasicQcSerializer<Vector3>
|
||||
{
|
||||
public override string SerializeFormatted(Vector3 value, QuantumTheme theme)
|
||||
{
|
||||
return $"({value.x}, {value.y}, {value.z})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d55001e28a383304ab174d2aed504aa6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFSW.QC.Serializers
|
||||
{
|
||||
public class Vector4Serializer : BasicQcSerializer<Vector4>
|
||||
{
|
||||
public override string SerializeFormatted(Vector4 value, QuantumTheme theme)
|
||||
{
|
||||
return $"({value.x}, {value.y}, {value.z}, {value.w})";
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af0a28dfe0d28b844b9ca788f93145c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user