feat(*): update namespace to TapTap.ModuleName
commit
42991af608
|
@ -0,0 +1 @@
|
|||
# ChangeLog
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 89a2f2ba3f4d4cf0b55f2f992c6b6afb
|
||||
timeCreated: 1616744142
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4ba437884454210a12d7af49d0debbd
|
||||
timeCreated: 1616744125
|
|
@ -0,0 +1 @@
|
|||
# TapTap.Common
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d7008a3a22e45a4bfe9605e6d050a29
|
||||
timeCreated: 1616744132
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28e2e71fed1414ad3978a4e5575065f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,954 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public static class Plist
|
||||
{
|
||||
private static List<int> offsetTable = new List<int>();
|
||||
private static List<byte> objectTable = new List<byte>();
|
||||
private static int refCount;
|
||||
private static int objRefSize;
|
||||
private static int offsetByteSize;
|
||||
private static long offsetTableOffset;
|
||||
|
||||
#region Public Functions
|
||||
|
||||
public static object readPlist(string path)
|
||||
{
|
||||
using (FileStream f = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
return readPlist(f, plistType.Auto);
|
||||
}
|
||||
}
|
||||
|
||||
public static object readPlistSource(string source)
|
||||
{
|
||||
return readPlist(System.Text.Encoding.UTF8.GetBytes(source));
|
||||
}
|
||||
|
||||
public static object readPlist(byte[] data)
|
||||
{
|
||||
return readPlist(new MemoryStream(data), plistType.Auto);
|
||||
}
|
||||
|
||||
public static plistType getPlistType(Stream stream)
|
||||
{
|
||||
byte[] magicHeader = new byte[8];
|
||||
stream.Read(magicHeader, 0, 8);
|
||||
|
||||
if (BitConverter.ToInt64(magicHeader, 0) == 3472403351741427810)
|
||||
{
|
||||
return plistType.Binary;
|
||||
}
|
||||
else
|
||||
{
|
||||
return plistType.Xml;
|
||||
}
|
||||
}
|
||||
|
||||
public static object readPlist(Stream stream, plistType type)
|
||||
{
|
||||
if (type == plistType.Auto)
|
||||
{
|
||||
type = getPlistType(stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
if (type == plistType.Binary)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(stream))
|
||||
{
|
||||
byte[] data = reader.ReadBytes((int) reader.BaseStream.Length);
|
||||
return readBinary(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.XmlResolver = null;
|
||||
xml.Load(stream);
|
||||
return readXml(xml);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeXml(object value, string path)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(path))
|
||||
{
|
||||
writer.Write(writeXml(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeXml(object value, Stream stream)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(stream))
|
||||
{
|
||||
writer.Write(writeXml(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static string writeXml(object value)
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
|
||||
xmlWriterSettings.Encoding = new System.Text.UTF8Encoding(false);
|
||||
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Document;
|
||||
xmlWriterSettings.Indent = true;
|
||||
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(ms, xmlWriterSettings))
|
||||
{
|
||||
xmlWriter.WriteStartDocument();
|
||||
//xmlWriter.WriteComment("DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"");
|
||||
xmlWriter.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN",
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
|
||||
xmlWriter.WriteStartElement("plist");
|
||||
xmlWriter.WriteAttributeString("version", "1.0");
|
||||
compose(value, xmlWriter);
|
||||
xmlWriter.WriteEndElement();
|
||||
xmlWriter.WriteEndDocument();
|
||||
xmlWriter.Flush();
|
||||
xmlWriter.Close();
|
||||
return System.Text.Encoding.UTF8.GetString(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBinary(object value, string path)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create)))
|
||||
{
|
||||
writer.Write(writeBinary(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBinary(object value, Stream stream)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(stream))
|
||||
{
|
||||
writer.Write(writeBinary(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] writeBinary(object value)
|
||||
{
|
||||
offsetTable.Clear();
|
||||
objectTable.Clear();
|
||||
refCount = 0;
|
||||
objRefSize = 0;
|
||||
offsetByteSize = 0;
|
||||
offsetTableOffset = 0;
|
||||
|
||||
//Do not count the root node, subtract by 1
|
||||
int totalRefs = countObject(value) - 1;
|
||||
|
||||
refCount = totalRefs;
|
||||
|
||||
objRefSize = RegulateNullBytes(BitConverter.GetBytes(refCount)).Length;
|
||||
|
||||
composeBinary(value);
|
||||
|
||||
writeBinaryString("bplist00", false);
|
||||
|
||||
offsetTableOffset = (long) objectTable.Count;
|
||||
|
||||
offsetTable.Add(objectTable.Count - 8);
|
||||
|
||||
offsetByteSize = RegulateNullBytes(BitConverter.GetBytes(offsetTable[offsetTable.Count - 1])).Length;
|
||||
|
||||
List<byte> offsetBytes = new List<byte>();
|
||||
|
||||
offsetTable.Reverse();
|
||||
|
||||
for (int i = 0; i < offsetTable.Count; i++)
|
||||
{
|
||||
offsetTable[i] = objectTable.Count - offsetTable[i];
|
||||
byte[] buffer = RegulateNullBytes(BitConverter.GetBytes(offsetTable[i]), offsetByteSize);
|
||||
Array.Reverse(buffer);
|
||||
offsetBytes.AddRange(buffer);
|
||||
}
|
||||
|
||||
objectTable.AddRange(offsetBytes);
|
||||
|
||||
objectTable.AddRange(new byte[6]);
|
||||
objectTable.Add(Convert.ToByte(offsetByteSize));
|
||||
objectTable.Add(Convert.ToByte(objRefSize));
|
||||
|
||||
var a = BitConverter.GetBytes((long) totalRefs + 1);
|
||||
Array.Reverse(a);
|
||||
objectTable.AddRange(a);
|
||||
|
||||
objectTable.AddRange(BitConverter.GetBytes((long) 0));
|
||||
a = BitConverter.GetBytes(offsetTableOffset);
|
||||
Array.Reverse(a);
|
||||
objectTable.AddRange(a);
|
||||
|
||||
return objectTable.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
|
||||
private static object readXml(XmlDocument xml)
|
||||
{
|
||||
XmlNode rootNode = xml.DocumentElement.ChildNodes[0];
|
||||
return parse(rootNode);
|
||||
}
|
||||
|
||||
private static object readBinary(byte[] data)
|
||||
{
|
||||
offsetTable.Clear();
|
||||
List<byte> offsetTableBytes = new List<byte>();
|
||||
objectTable.Clear();
|
||||
refCount = 0;
|
||||
objRefSize = 0;
|
||||
offsetByteSize = 0;
|
||||
offsetTableOffset = 0;
|
||||
|
||||
List<byte> bList = new List<byte>(data);
|
||||
|
||||
List<byte> trailer = bList.GetRange(bList.Count - 32, 32);
|
||||
|
||||
parseTrailer(trailer);
|
||||
|
||||
objectTable = bList.GetRange(0, (int) offsetTableOffset);
|
||||
|
||||
offsetTableBytes = bList.GetRange((int) offsetTableOffset, bList.Count - (int) offsetTableOffset - 32);
|
||||
|
||||
parseOffsetTable(offsetTableBytes);
|
||||
|
||||
return parseBinary(0);
|
||||
}
|
||||
|
||||
private static Dictionary<string, object> parseDictionary(XmlNode node)
|
||||
{
|
||||
XmlNodeList children = node.ChildNodes;
|
||||
if (children.Count % 2 != 0)
|
||||
{
|
||||
throw new DataMisalignedException("Dictionary elements must have an even number of child nodes");
|
||||
}
|
||||
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
|
||||
for (int i = 0; i < children.Count; i += 2)
|
||||
{
|
||||
XmlNode keynode = children[i];
|
||||
XmlNode valnode = children[i + 1];
|
||||
|
||||
if (keynode.Name != "key")
|
||||
{
|
||||
throw new ApplicationException("expected a key node");
|
||||
}
|
||||
|
||||
object result = parse(valnode);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
dict.Add(keynode.InnerText, result);
|
||||
}
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
private static List<object> parseArray(XmlNode node)
|
||||
{
|
||||
List<object> array = new List<object>();
|
||||
|
||||
foreach (XmlNode child in node.ChildNodes)
|
||||
{
|
||||
object result = parse(child);
|
||||
if (result != null)
|
||||
{
|
||||
array.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private static void composeArray(List<object> value, XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("array");
|
||||
foreach (object obj in value)
|
||||
{
|
||||
compose(obj, writer);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private static object parse(XmlNode node)
|
||||
{
|
||||
switch (node.Name)
|
||||
{
|
||||
case "dict":
|
||||
return parseDictionary(node);
|
||||
case "array":
|
||||
return parseArray(node);
|
||||
case "string":
|
||||
return node.InnerText;
|
||||
case "integer":
|
||||
// int result;
|
||||
//int.TryParse(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo, out result);
|
||||
return Convert.ToInt32(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
case "real":
|
||||
return Convert.ToDouble(node.InnerText, System.Globalization.NumberFormatInfo.InvariantInfo);
|
||||
case "false":
|
||||
return false;
|
||||
case "true":
|
||||
return true;
|
||||
case "null":
|
||||
return null;
|
||||
case "date":
|
||||
return XmlConvert.ToDateTime(node.InnerText, XmlDateTimeSerializationMode.Utc);
|
||||
case "data":
|
||||
return Convert.FromBase64String(node.InnerText);
|
||||
}
|
||||
|
||||
throw new ApplicationException(String.Format("Plist Node `{0}' is not supported", node.Name));
|
||||
}
|
||||
|
||||
private static void compose(object value, XmlWriter writer)
|
||||
{
|
||||
if (value == null || value is string)
|
||||
{
|
||||
writer.WriteElementString("string", value as string);
|
||||
}
|
||||
else if (value is int || value is long)
|
||||
{
|
||||
writer.WriteElementString("integer",
|
||||
((int) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
|
||||
}
|
||||
else if (value is System.Collections.Generic.Dictionary<string, object> ||
|
||||
value.GetType().ToString().StartsWith("System.Collections.Generic.Dictionary`2[System.String"))
|
||||
{
|
||||
//Convert to Dictionary<string, object>
|
||||
Dictionary<string, object> dic = value as Dictionary<string, object>;
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, object>();
|
||||
IDictionary idic = (IDictionary) value;
|
||||
foreach (var key in idic.Keys)
|
||||
{
|
||||
dic.Add(key.ToString(), idic[key]);
|
||||
}
|
||||
}
|
||||
|
||||
writeDictionaryValues(dic, writer);
|
||||
}
|
||||
else if (value is List<object>)
|
||||
{
|
||||
composeArray((List<object>) value, writer);
|
||||
}
|
||||
else if (value is byte[])
|
||||
{
|
||||
writer.WriteElementString("data", Convert.ToBase64String((Byte[]) value));
|
||||
}
|
||||
else if (value is float || value is double)
|
||||
{
|
||||
writer.WriteElementString("real",
|
||||
((double) value).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
|
||||
}
|
||||
else if (value is DateTime)
|
||||
{
|
||||
DateTime time = (DateTime) value;
|
||||
string theString = XmlConvert.ToString(time, XmlDateTimeSerializationMode.Utc);
|
||||
writer.WriteElementString("date", theString); //, "yyyy-MM-ddTHH:mm:ssZ"));
|
||||
}
|
||||
else if (value is bool)
|
||||
{
|
||||
writer.WriteElementString(value.ToString().ToLower(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(String.Format("Value type '{0}' is unhandled", value.GetType().ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeDictionaryValues(Dictionary<string, object> dictionary, XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("dict");
|
||||
foreach (string key in dictionary.Keys)
|
||||
{
|
||||
object value = dictionary[key];
|
||||
writer.WriteElementString("key", key);
|
||||
compose(value, writer);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private static int countObject(object value)
|
||||
{
|
||||
int count = 0;
|
||||
switch (value.GetType().ToString())
|
||||
{
|
||||
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
|
||||
Dictionary<string, object> dict = (Dictionary<string, object>) value;
|
||||
foreach (string key in dict.Keys)
|
||||
{
|
||||
count += countObject(dict[key]);
|
||||
}
|
||||
|
||||
count += dict.Keys.Count;
|
||||
count++;
|
||||
break;
|
||||
case "System.Collections.Generic.List`1[System.Object]":
|
||||
List<object> list = (List<object>) value;
|
||||
foreach (object obj in list)
|
||||
{
|
||||
count += countObject(obj);
|
||||
}
|
||||
|
||||
count++;
|
||||
break;
|
||||
default:
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryDictionary(Dictionary<string, object> dictionary)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
List<int> refs = new List<int>();
|
||||
for (int i = dictionary.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var o = new object[dictionary.Count];
|
||||
dictionary.Values.CopyTo(o, 0);
|
||||
composeBinary(o[i]);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
for (int i = dictionary.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var o = new string[dictionary.Count];
|
||||
dictionary.Keys.CopyTo(o, 0);
|
||||
composeBinary(o[i]); //);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
if (dictionary.Count < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0xD0 | Convert.ToByte(dictionary.Count)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0xD0 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(dictionary.Count, false));
|
||||
}
|
||||
|
||||
|
||||
foreach (int val in refs)
|
||||
{
|
||||
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
|
||||
Array.Reverse(refBuffer);
|
||||
buffer.InsertRange(0, refBuffer);
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] composeBinaryArray(List<object> objects)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
List<int> refs = new List<int>();
|
||||
|
||||
for (int i = objects.Count - 1; i >= 0; i--)
|
||||
{
|
||||
composeBinary(objects[i]);
|
||||
offsetTable.Add(objectTable.Count);
|
||||
refs.Add(refCount);
|
||||
refCount--;
|
||||
}
|
||||
|
||||
if (objects.Count < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0xA0 | Convert.ToByte(objects.Count)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0xA0 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(objects.Count, false));
|
||||
}
|
||||
|
||||
foreach (int val in refs)
|
||||
{
|
||||
byte[] refBuffer = RegulateNullBytes(BitConverter.GetBytes(val), objRefSize);
|
||||
Array.Reverse(refBuffer);
|
||||
buffer.InsertRange(0, refBuffer);
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] composeBinary(object obj)
|
||||
{
|
||||
byte[] value;
|
||||
switch (obj.GetType().ToString())
|
||||
{
|
||||
case "System.Collections.Generic.Dictionary`2[System.String,System.Object]":
|
||||
value = writeBinaryDictionary((Dictionary<string, object>) obj);
|
||||
return value;
|
||||
|
||||
case "System.Collections.Generic.List`1[System.Object]":
|
||||
value = composeBinaryArray((List<object>) obj);
|
||||
return value;
|
||||
|
||||
case "System.Byte[]":
|
||||
value = writeBinaryByteArray((byte[]) obj);
|
||||
return value;
|
||||
|
||||
case "System.Double":
|
||||
value = writeBinaryDouble((double) obj);
|
||||
return value;
|
||||
|
||||
case "System.Int32":
|
||||
value = writeBinaryInteger((int) obj, true);
|
||||
return value;
|
||||
|
||||
case "System.String":
|
||||
value = writeBinaryString((string) obj, true);
|
||||
return value;
|
||||
|
||||
case "System.DateTime":
|
||||
value = writeBinaryDate((DateTime) obj);
|
||||
return value;
|
||||
|
||||
case "System.Boolean":
|
||||
value = writeBinaryBool((bool) obj);
|
||||
return value;
|
||||
|
||||
default:
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] writeBinaryDate(DateTime obj)
|
||||
{
|
||||
List<byte> buffer =
|
||||
new List<byte>(RegulateNullBytes(BitConverter.GetBytes(PlistDateConverter.ConvertToAppleTimeStamp(obj)),
|
||||
8));
|
||||
buffer.Reverse();
|
||||
buffer.Insert(0, 0x33);
|
||||
objectTable.InsertRange(0, buffer);
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] writeBinaryBool(bool obj)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(new byte[1] {(bool) obj ? (byte) 9 : (byte) 8});
|
||||
objectTable.InsertRange(0, buffer);
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryInteger(int value, bool write)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(BitConverter.GetBytes((long) value));
|
||||
buffer = new List<byte>(RegulateNullBytes(buffer.ToArray()));
|
||||
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
|
||||
buffer.Add(0);
|
||||
int header = 0x10 | (int) (Math.Log(buffer.Count) / Math.Log(2));
|
||||
|
||||
buffer.Reverse();
|
||||
|
||||
buffer.Insert(0, Convert.ToByte(header));
|
||||
|
||||
if (write)
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryDouble(double value)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(RegulateNullBytes(BitConverter.GetBytes(value), 4));
|
||||
while (buffer.Count != Math.Pow(2, Math.Log(buffer.Count) / Math.Log(2)))
|
||||
buffer.Add(0);
|
||||
int header = 0x20 | (int) (Math.Log(buffer.Count) / Math.Log(2));
|
||||
|
||||
buffer.Reverse();
|
||||
|
||||
buffer.Insert(0, Convert.ToByte(header));
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryByteArray(byte[] value)
|
||||
{
|
||||
List<byte> buffer = new List<byte>(value);
|
||||
List<byte> header = new List<byte>();
|
||||
if (value.Length < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0x40 | Convert.ToByte(value.Length)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0x40 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(buffer.Count, false));
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] writeBinaryString(string value, bool head)
|
||||
{
|
||||
List<byte> buffer = new List<byte>();
|
||||
List<byte> header = new List<byte>();
|
||||
foreach (char chr in value.ToCharArray())
|
||||
buffer.Add(Convert.ToByte(chr));
|
||||
|
||||
if (head)
|
||||
{
|
||||
if (value.Length < 15)
|
||||
{
|
||||
header.Add(Convert.ToByte(0x50 | Convert.ToByte(value.Length)));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(0x50 | 0xf);
|
||||
header.AddRange(writeBinaryInteger(buffer.Count, false));
|
||||
}
|
||||
}
|
||||
|
||||
buffer.InsertRange(0, header);
|
||||
|
||||
objectTable.InsertRange(0, buffer);
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static byte[] RegulateNullBytes(byte[] value)
|
||||
{
|
||||
return RegulateNullBytes(value, 1);
|
||||
}
|
||||
|
||||
private static byte[] RegulateNullBytes(byte[] value, int minBytes)
|
||||
{
|
||||
Array.Reverse(value);
|
||||
List<byte> bytes = new List<byte>(value);
|
||||
for (int i = 0; i < bytes.Count; i++)
|
||||
{
|
||||
if (bytes[i] == 0 && bytes.Count > minBytes)
|
||||
{
|
||||
bytes.Remove(bytes[i]);
|
||||
i--;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytes.Count < minBytes)
|
||||
{
|
||||
int dist = minBytes - bytes.Count;
|
||||
for (int i = 0; i < dist; i++)
|
||||
bytes.Insert(0, 0);
|
||||
}
|
||||
|
||||
value = bytes.ToArray();
|
||||
Array.Reverse(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private static void parseTrailer(List<byte> trailer)
|
||||
{
|
||||
offsetByteSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(6, 1).ToArray(), 4), 0);
|
||||
objRefSize = BitConverter.ToInt32(RegulateNullBytes(trailer.GetRange(7, 1).ToArray(), 4), 0);
|
||||
byte[] refCountBytes = trailer.GetRange(12, 4).ToArray();
|
||||
Array.Reverse(refCountBytes);
|
||||
refCount = BitConverter.ToInt32(refCountBytes, 0);
|
||||
byte[] offsetTableOffsetBytes = trailer.GetRange(24, 8).ToArray();
|
||||
Array.Reverse(offsetTableOffsetBytes);
|
||||
offsetTableOffset = BitConverter.ToInt64(offsetTableOffsetBytes, 0);
|
||||
}
|
||||
|
||||
private static void parseOffsetTable(List<byte> offsetTableBytes)
|
||||
{
|
||||
for (int i = 0; i < offsetTableBytes.Count; i += offsetByteSize)
|
||||
{
|
||||
byte[] buffer = offsetTableBytes.GetRange(i, offsetByteSize).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
offsetTable.Add(BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0));
|
||||
}
|
||||
}
|
||||
|
||||
private static object parseBinaryDictionary(int objRef)
|
||||
{
|
||||
Dictionary<string, object> buffer = new Dictionary<string, object>();
|
||||
List<int> refs = new List<int>();
|
||||
int refCount = 0;
|
||||
|
||||
int refStartPosition;
|
||||
refCount = getCount(offsetTable[objRef], out refStartPosition);
|
||||
|
||||
|
||||
if (refCount < 15)
|
||||
refStartPosition = offsetTable[objRef] + 1;
|
||||
else
|
||||
refStartPosition = offsetTable[objRef] + 2 +
|
||||
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
|
||||
|
||||
for (int i = refStartPosition; i < refStartPosition + refCount * 2 * objRefSize; i += objRefSize)
|
||||
{
|
||||
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
|
||||
Array.Reverse(refBuffer);
|
||||
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
|
||||
}
|
||||
|
||||
for (int i = 0; i < refCount; i++)
|
||||
{
|
||||
buffer.Add((string) parseBinary(refs[i]), parseBinary(refs[i + refCount]));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static object parseBinaryArray(int objRef)
|
||||
{
|
||||
List<object> buffer = new List<object>();
|
||||
List<int> refs = new List<int>();
|
||||
int refCount = 0;
|
||||
|
||||
int refStartPosition;
|
||||
refCount = getCount(offsetTable[objRef], out refStartPosition);
|
||||
|
||||
|
||||
if (refCount < 15)
|
||||
refStartPosition = offsetTable[objRef] + 1;
|
||||
else
|
||||
//The following integer has a header aswell so we increase the refStartPosition by two to account for that.
|
||||
refStartPosition = offsetTable[objRef] + 2 +
|
||||
RegulateNullBytes(BitConverter.GetBytes(refCount), 1).Length;
|
||||
|
||||
for (int i = refStartPosition; i < refStartPosition + refCount * objRefSize; i += objRefSize)
|
||||
{
|
||||
byte[] refBuffer = objectTable.GetRange(i, objRefSize).ToArray();
|
||||
Array.Reverse(refBuffer);
|
||||
refs.Add(BitConverter.ToInt32(RegulateNullBytes(refBuffer, 4), 0));
|
||||
}
|
||||
|
||||
for (int i = 0; i < refCount; i++)
|
||||
{
|
||||
buffer.Add(parseBinary(refs[i]));
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static int getCount(int bytePosition, out int newBytePosition)
|
||||
{
|
||||
byte headerByte = objectTable[bytePosition];
|
||||
byte headerByteTrail = Convert.ToByte(headerByte & 0xf);
|
||||
int count;
|
||||
if (headerByteTrail < 15)
|
||||
{
|
||||
count = headerByteTrail;
|
||||
newBytePosition = bytePosition + 1;
|
||||
}
|
||||
else
|
||||
count = (int) parseBinaryInt(bytePosition + 1, out newBytePosition);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private static object parseBinary(int objRef)
|
||||
{
|
||||
byte header = objectTable[offsetTable[objRef]];
|
||||
switch (header & 0xF0)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
//If the byte is
|
||||
//0 return null
|
||||
//9 return true
|
||||
//8 return false
|
||||
return (objectTable[offsetTable[objRef]] == 0)
|
||||
? (object) null
|
||||
: ((objectTable[offsetTable[objRef]] == 9) ? true : false);
|
||||
}
|
||||
case 0x10:
|
||||
{
|
||||
return parseBinaryInt(offsetTable[objRef]);
|
||||
}
|
||||
case 0x20:
|
||||
{
|
||||
return parseBinaryReal(offsetTable[objRef]);
|
||||
}
|
||||
case 0x30:
|
||||
{
|
||||
return parseBinaryDate(offsetTable[objRef]);
|
||||
}
|
||||
case 0x40:
|
||||
{
|
||||
return parseBinaryByteArray(offsetTable[objRef]);
|
||||
}
|
||||
case 0x50: //String ASCII
|
||||
{
|
||||
return parseBinaryAsciiString(offsetTable[objRef]);
|
||||
}
|
||||
case 0x60: //String Unicode
|
||||
{
|
||||
return parseBinaryUnicodeString(offsetTable[objRef]);
|
||||
}
|
||||
case 0xD0:
|
||||
{
|
||||
return parseBinaryDictionary(objRef);
|
||||
}
|
||||
case 0xA0:
|
||||
{
|
||||
return parseBinaryArray(objRef);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("This type is not supported");
|
||||
}
|
||||
|
||||
public static object parseBinaryDate(int headerPosition)
|
||||
{
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, 8).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
double appleTime = BitConverter.ToDouble(buffer, 0);
|
||||
DateTime result = PlistDateConverter.ConvertFromAppleTimeStamp(appleTime);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object parseBinaryInt(int headerPosition)
|
||||
{
|
||||
int output;
|
||||
return parseBinaryInt(headerPosition, out output);
|
||||
}
|
||||
|
||||
private static object parseBinaryInt(int headerPosition, out int newHeaderPosition)
|
||||
{
|
||||
byte header = objectTable[headerPosition];
|
||||
int byteCount = (int) Math.Pow(2, header & 0xf);
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
//Add one to account for the header byte
|
||||
newHeaderPosition = headerPosition + byteCount + 1;
|
||||
return BitConverter.ToInt32(RegulateNullBytes(buffer, 4), 0);
|
||||
}
|
||||
|
||||
private static object parseBinaryReal(int headerPosition)
|
||||
{
|
||||
byte header = objectTable[headerPosition];
|
||||
int byteCount = (int) Math.Pow(2, header & 0xf);
|
||||
byte[] buffer = objectTable.GetRange(headerPosition + 1, byteCount).ToArray();
|
||||
Array.Reverse(buffer);
|
||||
|
||||
return BitConverter.ToDouble(RegulateNullBytes(buffer, 8), 0);
|
||||
}
|
||||
|
||||
private static object parseBinaryAsciiString(int headerPosition)
|
||||
{
|
||||
int charStartPosition;
|
||||
int charCount = getCount(headerPosition, out charStartPosition);
|
||||
|
||||
var buffer = objectTable.GetRange(charStartPosition, charCount);
|
||||
return buffer.Count > 0 ? Encoding.ASCII.GetString(buffer.ToArray()) : string.Empty;
|
||||
}
|
||||
|
||||
private static object parseBinaryUnicodeString(int headerPosition)
|
||||
{
|
||||
int charStartPosition;
|
||||
int charCount = getCount(headerPosition, out charStartPosition);
|
||||
charCount = charCount * 2;
|
||||
|
||||
byte[] buffer = new byte[charCount];
|
||||
byte one, two;
|
||||
|
||||
for (int i = 0; i < charCount; i += 2)
|
||||
{
|
||||
one = objectTable.GetRange(charStartPosition + i, 1)[0];
|
||||
two = objectTable.GetRange(charStartPosition + i + 1, 1)[0];
|
||||
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
buffer[i] = two;
|
||||
buffer[i + 1] = one;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[i] = one;
|
||||
buffer[i + 1] = two;
|
||||
}
|
||||
}
|
||||
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
}
|
||||
|
||||
private static object parseBinaryByteArray(int headerPosition)
|
||||
{
|
||||
int byteStartPosition;
|
||||
int byteCount = getCount(headerPosition, out byteStartPosition);
|
||||
return objectTable.GetRange(byteStartPosition, byteCount).ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum plistType
|
||||
{
|
||||
Auto,
|
||||
Binary,
|
||||
Xml
|
||||
}
|
||||
|
||||
public static class PlistDateConverter
|
||||
{
|
||||
public static long timeDifference = 978307200;
|
||||
|
||||
public static long GetAppleTime(long unixTime)
|
||||
{
|
||||
return unixTime - timeDifference;
|
||||
}
|
||||
|
||||
public static long GetUnixTime(long appleTime)
|
||||
{
|
||||
return appleTime + timeDifference;
|
||||
}
|
||||
|
||||
public static DateTime ConvertFromAppleTimeStamp(double timestamp)
|
||||
{
|
||||
DateTime origin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
|
||||
return origin.AddSeconds(timestamp);
|
||||
}
|
||||
|
||||
public static double ConvertToAppleTimeStamp(DateTime date)
|
||||
{
|
||||
DateTime begin = new DateTime(2001, 1, 1, 0, 0, 0, 0);
|
||||
TimeSpan diff = date - begin;
|
||||
return Math.Floor(diff.TotalSeconds);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 66eefeda055244c784769597b08e679e
|
||||
timeCreated: 1617120740
|
|
@ -0,0 +1,177 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public static class TapCommonCompile
|
||||
{
|
||||
public static string GetProjPath(string path)
|
||||
{
|
||||
return PBXProject.GetPBXProjectPath(path);
|
||||
}
|
||||
|
||||
public static PBXProject ParseProjPath(string path)
|
||||
{
|
||||
var proj = new PBXProject();
|
||||
proj.ReadFromString(File.ReadAllText(path));
|
||||
return proj;
|
||||
}
|
||||
|
||||
public static string GetUnityFrameworkTarget(PBXProject proj)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string target = proj.GetUnityFrameworkTargetGuid();
|
||||
return target;
|
||||
#endif
|
||||
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
|
||||
return unityPhoneTarget;
|
||||
}
|
||||
|
||||
public static string GetUnityTarget(PBXProject proj)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string target = proj.GetUnityMainTargetGuid();
|
||||
return target;
|
||||
#endif
|
||||
var unityPhoneTarget = proj.TargetGuidByName("Unity-iPhone");
|
||||
return unityPhoneTarget;
|
||||
}
|
||||
|
||||
public static bool CheckTarget(string target)
|
||||
{
|
||||
return string.IsNullOrEmpty(target);
|
||||
}
|
||||
|
||||
public static bool HandlerIOSSetting(string path, string appDataPath, string resourceName, string modulePackageName,
|
||||
string moduleName, string[] bundleNames, string target, string projPath, PBXProject proj)
|
||||
{
|
||||
var resourcePath = Path.Combine(path, resourceName);
|
||||
|
||||
var parentFolder = Directory.GetParent(appDataPath).FullName;
|
||||
|
||||
Debug.Log($"ProjectFolder path:{parentFolder}");
|
||||
|
||||
if (Directory.Exists(resourcePath))
|
||||
{
|
||||
Directory.Delete(resourcePath, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(resourcePath);
|
||||
|
||||
var remotePackagePath =
|
||||
TapFileHelper.FilterFile(parentFolder + "/Library/PackageCache/", $"{modulePackageName}@");
|
||||
|
||||
var assetLocalPackagePath = TapFileHelper.FilterFile(parentFolder + "/Assets/TapTap/", moduleName);
|
||||
|
||||
var localPackagePath = TapFileHelper.FilterFile(parentFolder, moduleName);
|
||||
|
||||
var tdsResourcePath = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(remotePackagePath))
|
||||
{
|
||||
tdsResourcePath = remotePackagePath;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(assetLocalPackagePath))
|
||||
{
|
||||
tdsResourcePath = assetLocalPackagePath;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(localPackagePath))
|
||||
{
|
||||
tdsResourcePath = localPackagePath;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tdsResourcePath))
|
||||
{
|
||||
Debug.LogError("tdsResourcePath is NUll");
|
||||
return false;
|
||||
}
|
||||
|
||||
tdsResourcePath = $"{tdsResourcePath}/Plugins/iOS/Resource";
|
||||
|
||||
Debug.Log($"Find {moduleName} path:{tdsResourcePath}");
|
||||
|
||||
if (!Directory.Exists(tdsResourcePath))
|
||||
{
|
||||
Debug.LogError($"Can't Find {bundleNames}");
|
||||
return false;
|
||||
}
|
||||
|
||||
TapFileHelper.CopyAndReplaceDirectory(tdsResourcePath, resourcePath);
|
||||
|
||||
foreach (var name in bundleNames)
|
||||
{
|
||||
proj.AddFileToBuild(target,
|
||||
proj.AddFile(Path.Combine(resourcePath, name), Path.Combine(resourcePath, name),
|
||||
PBXSourceTree.Source));
|
||||
}
|
||||
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool HandlerPlist(string pathToBuildProject, string infoPlistPath)
|
||||
{
|
||||
//添加info
|
||||
var plistPath = pathToBuildProject + "/Info.plist";
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromString(File.ReadAllText(plistPath));
|
||||
var rootDic = plist.root;
|
||||
|
||||
var items = new List<string>
|
||||
{
|
||||
"tapsdk",
|
||||
"tapiosdk",
|
||||
};
|
||||
var plistElementList = rootDic.CreateArray("LSApplicationQueriesSchemes");
|
||||
foreach (var t in items)
|
||||
{
|
||||
plistElementList.AddString(t);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(infoPlistPath)) return false;
|
||||
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
|
||||
var taptapId = "";
|
||||
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (item.Key.Equals("taptap"))
|
||||
{
|
||||
var taptapDic = (Dictionary<string, object>) item.Value;
|
||||
foreach (var taptapItem in taptapDic.Where(taptapItem => taptapItem.Key.Equals("client_id")))
|
||||
{
|
||||
taptapId = "tt" + (string) taptapItem.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rootDic.SetString(item.Key.ToString(), item.Value.ToString());
|
||||
}
|
||||
}
|
||||
//添加url
|
||||
var dict = plist.root.AsDict();
|
||||
var array = dict.CreateArray("CFBundleURLTypes");
|
||||
var dict2 = array.AddDict();
|
||||
dict2.SetString("CFBundleURLName", "TapTap");
|
||||
var array2 = dict2.CreateArray("CFBundleURLSchemes");
|
||||
array2.AddString(taptapId);
|
||||
|
||||
Debug.Log("TapSDK change plist Success");
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetValueFromPlist(string infoPlistPath, string key)
|
||||
{
|
||||
if (infoPlistPath == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var dic = (Dictionary<string, object>) Plist.readPlist(infoPlistPath);
|
||||
return (from item in dic where item.Key.Equals(key) select (string) item.Value).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5475af505e04119831448fe963f9c2c
|
||||
timeCreated: 1617120740
|
|
@ -0,0 +1,65 @@
|
|||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public static class TapCommonIOSProcessor
|
||||
{
|
||||
// 添加标签,unity导出工程后自动执行该函数
|
||||
[PostProcessBuild(99)]
|
||||
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS) return;
|
||||
|
||||
// 获得工程路径
|
||||
var projPath = TapCommonCompile.GetProjPath(path);
|
||||
var proj = TapCommonCompile.ParseProjPath(projPath);
|
||||
var target = TapCommonCompile.GetUnityTarget(proj);
|
||||
var unityFrameworkTarget = TapCommonCompile.GetUnityFrameworkTarget(proj);
|
||||
|
||||
if (TapCommonCompile.CheckTarget(target))
|
||||
{
|
||||
Debug.LogError("Unity-iPhone is NUll");
|
||||
return;
|
||||
}
|
||||
|
||||
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
|
||||
proj.AddBuildProperty(unityFrameworkTarget, "OTHER_LDFLAGS", "-ObjC");
|
||||
|
||||
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
|
||||
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
|
||||
proj.SetBuildProperty(target, "SWIFT_VERSION", "5.0");
|
||||
proj.SetBuildProperty(target, "CLANG_ENABLE_MODULES", "YES");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "ENABLE_BITCODE", "NO");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "SWIFT_VERSION", "5.0");
|
||||
proj.SetBuildProperty(unityFrameworkTarget, "CLANG_ENABLE_MODULES", "YES");
|
||||
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "MobileCoreServices.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "WebKit.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "Security.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "CoreTelephony.framework", false);
|
||||
proj.AddFrameworkToProject(unityFrameworkTarget, "SystemConfiguration.framework", false);
|
||||
|
||||
proj.AddFileToBuild(unityFrameworkTarget,
|
||||
proj.AddFile("usr/lib/libc++.tbd", "libc++.tbd", PBXSourceTree.Sdk));
|
||||
|
||||
if (TapCommonCompile.HandlerIOSSetting(path,
|
||||
Application.dataPath,
|
||||
"TapCommonResource",
|
||||
"com.tapsdk.common",
|
||||
"Common",
|
||||
new[] {"TapCommonResource.bundle"},
|
||||
target, projPath, proj))
|
||||
{
|
||||
Debug.Log("TapCommon add Bundle Success!");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogError("TapCommon add Bundle Failed!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28d4870389ed406eac7c8849da60c644
|
||||
timeCreated: 1617120740
|
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TapTap.Common.Editor
|
||||
{
|
||||
public class TapFileHelper : System.IDisposable
|
||||
{
|
||||
private string filePath;
|
||||
|
||||
public TapFileHelper(string fPath)
|
||||
{
|
||||
filePath = fPath;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
Debug.LogError(filePath + "路径下文件不存在");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteBelow(string below, string text)
|
||||
{
|
||||
StreamReader streamReader = new StreamReader(filePath);
|
||||
string all = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
|
||||
if (beginIndex == -1)
|
||||
{
|
||||
Debug.LogError(filePath + "中没有找到字符串" + below);
|
||||
return;
|
||||
}
|
||||
|
||||
int endIndex = all.LastIndexOf("\n", beginIndex + below.Length, StringComparison.Ordinal);
|
||||
all = all.Substring(0, endIndex) + "\n" + text + "\n" + all.Substring(endIndex);
|
||||
StreamWriter streamWriter = new StreamWriter(filePath);
|
||||
streamWriter.Write(all);
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
public void Replace(string below, string newText)
|
||||
{
|
||||
StreamReader streamReader = new StreamReader(filePath);
|
||||
string all = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
int beginIndex = all.IndexOf(below, StringComparison.Ordinal);
|
||||
if (beginIndex == -1)
|
||||
{
|
||||
Debug.LogError(filePath + "中没有找到字符串" + below);
|
||||
return;
|
||||
}
|
||||
|
||||
all = all.Replace(below, newText);
|
||||
StreamWriter streamWriter = new StreamWriter(filePath);
|
||||
streamWriter.Write(all);
|
||||
streamWriter.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public static void CopyAndReplaceDirectory(string srcPath, string dstPath)
|
||||
{
|
||||
if (Directory.Exists(dstPath))
|
||||
Directory.Delete(dstPath, true);
|
||||
if (File.Exists(dstPath))
|
||||
File.Delete(dstPath);
|
||||
|
||||
Directory.CreateDirectory(dstPath);
|
||||
|
||||
foreach (var file in Directory.GetFiles(srcPath))
|
||||
File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)));
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcPath))
|
||||
CopyAndReplaceDirectory(dir, Path.Combine(dstPath, Path.GetFileName(dir)));
|
||||
}
|
||||
|
||||
public static string FilterFile(string srcPath, string filterName)
|
||||
{
|
||||
if (!Directory.Exists(srcPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(srcPath))
|
||||
{
|
||||
string fileName = Path.GetFileName(dir);
|
||||
if (fileName.StartsWith(filterName))
|
||||
{
|
||||
return Path.Combine(srcPath, Path.GetFileName(dir));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FileInfo RecursionFilterFile(string dir, string fileName)
|
||||
{
|
||||
List<FileInfo> fileInfoList = new List<FileInfo>();
|
||||
Director(dir, fileInfoList);
|
||||
foreach (FileInfo item in fileInfoList)
|
||||
{
|
||||
if (fileName.Equals(item.Name))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Director(string dir, List<FileInfo> list)
|
||||
{
|
||||
DirectoryInfo d = new DirectoryInfo(dir);
|
||||
FileInfo[] files = d.GetFiles();
|
||||
DirectoryInfo[] directs = d.GetDirectories();
|
||||
foreach (FileInfo f in files)
|
||||
{
|
||||
list.Add(f);
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo dd in directs)
|
||||
{
|
||||
Director(dd.FullName, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d1556fcb81944af6a42170d3e1c99269
|
||||
timeCreated: 1617120740
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "TapTap.Common.Editor",
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 616cea76def2d4f059b94440fc8cc03d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb6d4461ef1d45078227fe283dc2c255
|
||||
timeCreated: 1616744081
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c40d795a083b457fa3d923415533822c
|
||||
timeCreated: 1616744098
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c15be9bece843a4b6998999a603f389
|
||||
timeCreated: 1616744107
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 01c51530a73b04493a43dcac8b5448b2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,110 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 75f4d9bf431824223b16a7cb0de56fd3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
'': Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 0
|
||||
Exclude Editor: 0
|
||||
Exclude Linux: 0
|
||||
Exclude Linux64: 0
|
||||
Exclude LinuxUniversal: 0
|
||||
Exclude OSXUniversal: 0
|
||||
Exclude Win: 0
|
||||
Exclude Win64: 0
|
||||
Exclude iOS: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Facebook: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Facebook: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Linux
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
- first:
|
||||
Standalone: LinuxUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0f443a727b2704d32966d84ec19ee8ee
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2bd18fc97a6547b8b75f6c343d4cc14f
|
||||
timeCreated: 1616744103
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2192f0da58ae410089b7aabfc9375ca4
|
||||
timeCreated: 1616744115
|
|
@ -0,0 +1,33 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 862aa0341df21484eb4a08a6ee21f9c3
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b90cb19a0ccd14069b203014806a6748
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 21fdeeca33c2d48258227cea39860103
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2f74478f5ddcc4628ad879e8c8f1cc22
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 406 B |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fbf577ace10714238ac825fb2069a5f5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 566 B |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 269ea3a1cfd224d50bbfc20e0b529eb0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4ef285809644943588a98cc1bad12d80
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 497164c4329b345dc9fcf9a603822bd4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2a236b3c23efa4a80b48d344322d8741
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5386a5f959aa641daaa74403aaf5d5eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// EngineBridgeError.h
|
||||
// EngineBridge
|
||||
//
|
||||
// Created by xe on 2020/9/28.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef NSString *KLTypeStr NS_STRING_ENUM;
|
||||
|
||||
FOUNDATION_EXPORT KLTypeStr const COMMAND_PARSE_ERROR;
|
||||
|
||||
FOUNDATION_EXPORT KLTypeStr const COMMAND_SERVICE_ERROR;
|
||||
|
||||
FOUNDATION_EXPORT KLTypeStr const COMMAND_METHOD_ERROR;
|
||||
|
||||
FOUNDATION_EXPORT KLTypeStr const COMMAND_ARGS_ERROR;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e5d1a4fbca2e4eed9c2b0742ee386f0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// NSArray+Safe.h
|
||||
// TapAchievement
|
||||
//
|
||||
// Created by TapTap-David on 2020/9/15.
|
||||
// Copyright © 2020 taptap. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSArray (Safe)
|
||||
|
||||
- (void)tds_each:(void (^)(id object, NSUInteger index))block;
|
||||
|
||||
- (void)tds_apply:(void (^)(id object, NSUInteger index))block;
|
||||
|
||||
- (NSArray *)tds_map:(id (^)(id object, NSUInteger index))block;
|
||||
|
||||
- (id)tds_reduce:(id (^)(id accumulated, id object))block;
|
||||
|
||||
- (NSArray *)tds_filter:(BOOL (^)(id object, NSUInteger index))block;
|
||||
|
||||
- (id)tds_safeObjectAtIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e91dab301ab7946cd8908ae8bc3a74dc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// NSBundle+Tools.h
|
||||
// TDSAchievement
|
||||
//
|
||||
// Created by TapTap-David on 2020/8/26.
|
||||
// Copyright © 2020 taptap. All rights reserved.
|
||||
//
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NSBundle (Tools)
|
||||
+ (instancetype)tds_bundleName:(NSString *)bundleName aClass:(Class)aClass;
|
||||
- (NSString *)tds_localizedStringForKey:(NSString *)key value:(NSString *)value;
|
||||
- (NSString *)tds_localizedStringForKey:(NSString *)key;
|
||||
|
||||
- (UIImage *)tds_imageName:(NSString *)imageName;
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 272cc39eb993047508c62438a989e128
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// NSData+JSON.h
|
||||
// NativeApp
|
||||
//
|
||||
// Created by JiangJiahao on 2018/3/9.
|
||||
// Copyright © 2018年 JiangJiahao. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSData (JSON)
|
||||
|
||||
- (NSArray *)tds_arrayFromJsonData;
|
||||
|
||||
- (NSDictionary *)tds_dictionaryFromJsonData;
|
||||
|
||||
- (NSString *)tds_stringFromData;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd0f6ee563bdb46a999a7dd983a219eb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// NSDictionary+JSON.h
|
||||
// NativeApp
|
||||
//
|
||||
// Created by JiangJiahao on 2018/10/11.
|
||||
// Copyright © 2018 JiangJiahao. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSDictionary (JSON)
|
||||
- (NSString *)tds_jsonString;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 209c5870a15de4f4f8b26b21895a5955
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// NSDictionary+TDSSafe.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Insomnia on 2020/10/20.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSDictionary (TDSSafe)
|
||||
|
||||
- (BOOL)tds_boolForKey:(NSString *)key;
|
||||
- (NSInteger)tds_integerForKey:(NSString *)key;
|
||||
- (NSDictionary *)tds_dicForKey:(NSString *)key;
|
||||
- (NSString *)tds_stringForKey:(NSString *)key;
|
||||
- (NSArray *)tds_arrayForKey:(NSString *)key;
|
||||
- (NSSet *)tds_setForKey:(NSString *)key;
|
||||
- (NSNumber *)tds_numberForKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e067dd4ba22944aa99e03f1b52fdd015
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// NSError+Ext.h
|
||||
// TapAchievement
|
||||
//
|
||||
// Created by TapTap-David on 2020/9/22.
|
||||
// Copyright © 2020 taptap. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSError (Ext)
|
||||
+ (instancetype)errorWithMessage:(NSString *)errorMsg code:(NSInteger)code;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4eeb4b3e721fc45779586f6d8a420470
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// NSMutableArray+Safe.h
|
||||
// TapAchievement
|
||||
//
|
||||
// Created by TapTap-David on 2020/9/24.
|
||||
// Copyright © 2020 taptap. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSMutableArray (Safe)
|
||||
- (void)tt_safeAddObject:(id)anObject;
|
||||
|
||||
- (void)tt_addNonNullObject:(id)anObject;
|
||||
|
||||
- (void)tt_safeInsertObject:(id)anObject atIndex:(NSUInteger)index;
|
||||
|
||||
- (void)tt_safeReplaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: beaa9e67229d64992a0f9d9fd60f299e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// NSObject+TDSCoding.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Insomnia on 2020/10/20.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSObject (TDSCoding)
|
||||
/**
|
||||
* 解码(从文件中解析对象)
|
||||
*/
|
||||
- (void)tds_decode:(NSCoder *)decoder;
|
||||
/**
|
||||
* 编码(将对象写入文件中)
|
||||
*/
|
||||
- (void)tds_encode:(NSCoder *)encoder;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0f48089c9f0fd43328ee4ee66e903260
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// NSObject+TDSModel.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Insomnia on 2020/10/20.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol TDSModel <NSObject>
|
||||
@optional
|
||||
|
||||
+ (NSDictionary *)replacedKeyFromPropertyName;
|
||||
+ (NSString *)replacedKeyFromPropertyName:(NSString *)propertyName;
|
||||
+ (NSDictionary *)objectClassInArray;
|
||||
+ (Class)objectClassInArray:(NSString *)propertyName;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (TDSModel) <TDSModel>
|
||||
|
||||
+ (instancetype)tds_modelWithKeyValues:(id)keyValues;
|
||||
|
||||
- (NSDictionary *)tds_keyValues;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0e1b8aa9e354141a3878d975fed9385d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// NSObject+TDSProperty.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Insomnia on 2020/10/20.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapCommonSDK/TDSModelHelper.h>
|
||||
#import <TapCommonSDK/TDSMacros.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (^TDSClassesEnumerator) (Class cls, BOOL *stop);
|
||||
|
||||
typedef void (^TDSPropertiesEnumerator) (TDSProperty *property, BOOL *stop);
|
||||
|
||||
@interface NSObject (TDSProperty)
|
||||
+ (void)tds_enumerateProperties:(TDSPropertiesEnumerator)enumerator;
|
||||
|
||||
+ (void)tds_enumerateClasses:(TDSClassesEnumerator)enumerator;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fba826192a8f847db9917e7438011840
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// NSString+Tools.h
|
||||
// TDS
|
||||
//
|
||||
// Created by JiangJiahao on 2018/4/24.
|
||||
// Copyright © 2018年 dyy. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (Tools)
|
||||
- (NSString *)tds_URLEncodedString;
|
||||
- (NSString *)tds_URLDecodedString;
|
||||
///反转字符串
|
||||
- (NSString *)tds_reverse;
|
||||
|
||||
// MD5 hash of the file on the filesystem specified by path
|
||||
+ (NSString *)tds_stringWithMD5OfFile:(NSString *) path;
|
||||
// The string's MD5 hash
|
||||
- (NSString *)tds_MD5Hash;
|
||||
|
||||
// base64
|
||||
- (NSString *)tds_base64Encode;
|
||||
- (NSString *)tds_base64Dencode;
|
||||
|
||||
/// 是否是空字符串
|
||||
+ (BOOL)tds_isEmpty:(NSString *)string;
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8bc01c7bcd32b4b878e4f2d3df1bcae9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// TDSAccount.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2020/9/29.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM (NSInteger, TDSAccountType) {
|
||||
TAP,
|
||||
XD,
|
||||
XDG,
|
||||
TYPE_TDS
|
||||
};
|
||||
|
||||
@interface TDSAccount : NSObject
|
||||
|
||||
/// xd token
|
||||
@property (nonatomic, copy, readonly) NSString *token;
|
||||
/// tap/tds
|
||||
@property (nonatomic, copy, readonly) NSString *kid;
|
||||
@property (nonatomic, copy, readonly) NSString *accessToken;
|
||||
@property (nonatomic, copy, readonly) NSString *tokenType;
|
||||
@property (nonatomic, copy, readonly) NSString *macKey;
|
||||
@property (nonatomic, copy, readonly) NSString *macAlgorithm;
|
||||
/// tds
|
||||
@property (nonatomic, assign, readonly) long expireIn;
|
||||
|
||||
- (instancetype)initWithToken:(NSString *)token type:(TDSAccountType)type;
|
||||
|
||||
- (TDSAccountType)getAccountType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d5363b6cf7c44196a7f8e3044357f6d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// TDSAccountProvider.h
|
||||
// TapCommonSDK
|
||||
//
|
||||
// Created by Bottle K on 2021/3/30.
|
||||
//
|
||||
|
||||
#import <TapCommonSDK/TDSAccount.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol TDSAccountProvider <NSObject>
|
||||
|
||||
- (nullable TDSAccount *)getAccount;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45422e8b3a4e449648435edab7d3dff4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,79 @@
|
|||
//
|
||||
// AsyncHttp.h
|
||||
//
|
||||
// Created by JiangJiahao on 2018/3/9.
|
||||
// Copyright © 2018年 JiangJiahao. All rights reserved.
|
||||
// 简单HTTP请求
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapCommonSDK/TDSHttpResult.h>
|
||||
|
||||
extern NSString *const TDS_TIMEOUTKEY;
|
||||
extern NSString *const TDS_HTTPMETHODKEY;
|
||||
extern NSString *const TDS_HTTPBODYKEY;
|
||||
extern NSString *const TDS_DATAFORMAT;
|
||||
extern NSString *const TDS_CACHE_POLICY_KEY;
|
||||
|
||||
/**
|
||||
header
|
||||
*/
|
||||
extern NSString *const TDS_AUTH_KEY;
|
||||
|
||||
|
||||
typedef void(^CallBackBlock)(TDSHttpResult *result);
|
||||
typedef void(^GetAllCallBack)(NSArray *resultArr,BOOL successAll);
|
||||
|
||||
|
||||
@interface TDSAsyncHttp : NSObject
|
||||
@property (nonatomic,copy) CallBackBlock callBackBlock;
|
||||
@property (nonatomic,copy) CallBackBlock failedCallback;
|
||||
|
||||
- (void)stopTask;
|
||||
- (void)retryTask;
|
||||
|
||||
- (void)handleSuccessResult:(TDSHttpResult *)result;
|
||||
- (void)handleFailResult:(TDSHttpResult *)result;
|
||||
|
||||
/// GET请求
|
||||
/// @param urlStr url
|
||||
/// @param requestParams 网络请求参数,如超时、格式等
|
||||
/// @param customHeaderParams 自定义请求头参数
|
||||
/// @param params 本次请求参数
|
||||
/// @param callBackBlock 成功回调
|
||||
/// @param failedCallback 失败回调
|
||||
- (TDSAsyncHttp *)httpGet:(NSString *)urlStr
|
||||
requestParams:(NSDictionary *)requestParams
|
||||
customHeader:(NSDictionary *)customHeaderParams
|
||||
params:(NSDictionary *)params
|
||||
callBack:(CallBackBlock)callBackBlock failedCallback:(CallBackBlock)failedCallback;
|
||||
|
||||
/**
|
||||
多个get请求并发,同时返回
|
||||
|
||||
@param urlStrArr URL数组
|
||||
@param requestParamsArr 请求参数数组
|
||||
@param customHeaderParamsArr 自定义请求头数组
|
||||
@param paramsDicArr 参数数组
|
||||
@param callback 回掉
|
||||
*/
|
||||
- (void)httpGetAll:(NSArray *)urlStrArr
|
||||
requestParamsArr:(NSArray *)requestParamsArr
|
||||
customHeadersArr:(NSArray *)customHeaderParamsArr
|
||||
params:(NSArray *)paramsDicArr
|
||||
callback:(GetAllCallBack)callback;
|
||||
|
||||
/// POST请求
|
||||
/// @param urlStr URL
|
||||
/// @param requestParams 网络请求参数,如超时、数据格式、请求头等
|
||||
/// @param customHeaderParams 自定义请求头参数
|
||||
/// @param params 本次请求参数
|
||||
/// @param callBackBlock 成功回调
|
||||
/// @param failedCallback 失败回调
|
||||
- (TDSAsyncHttp *)httpPost:(NSString *)urlStr
|
||||
requestParams:(NSDictionary *)requestParams
|
||||
customHeader:(NSDictionary *)customHeaderParams
|
||||
params:(NSDictionary *)params
|
||||
callBack:(CallBackBlock)callBackBlock
|
||||
failedCallback:(CallBackBlock)failedCallback;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0efdd281872c49e6847c5d161ffb59b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// XDGAutoLayout.h
|
||||
// XDG
|
||||
//
|
||||
// Created by JiangJiahao on 2020/8/20.
|
||||
// Copyright © 2020 JiangJiahao. All rights reserved.
|
||||
// 简单自动布局类
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSAutoLayout : NSObject
|
||||
|
||||
+ (void)openAutoLayout:(UIView *)targetView;
|
||||
+ (void)safeAreaLayout:(BOOL)safe;
|
||||
|
||||
+ (NSLayoutConstraint *)layoutHeight:(UIView *)targetView height:(CGFloat)height;
|
||||
+ (NSLayoutConstraint *)layoutWidth:(UIView *)targetView width:(CGFloat)width;
|
||||
|
||||
/// 相等约束相等布局
|
||||
/// @param view1 view1
|
||||
/// @param view2 view2
|
||||
+ (void)layoutViewEqual:(UIView *)view1 toView:(UIView *)view2;
|
||||
|
||||
+ (NSLayoutConstraint *)layoutViewEqual:(UIView *)view1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr;
|
||||
|
||||
+ (NSLayoutConstraint *)layoutViewEqual:(UIView *)view1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr
|
||||
offset:(CGFloat)offset;
|
||||
|
||||
+ (NSLayoutConstraint *)layoutViewEqual:(UIView *)view1
|
||||
attribute:(NSLayoutAttribute)attr1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr2;
|
||||
|
||||
/// 约束两个view相等
|
||||
/// @param view1 view1
|
||||
/// @param attr1 view1约束
|
||||
/// @param view2 view2
|
||||
/// @param attr2 view2约束
|
||||
/// @param constant 距离
|
||||
+ (NSLayoutConstraint *)layoutViewEqual:(UIView *)view1
|
||||
attribute:(NSLayoutAttribute)attr1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr2
|
||||
constant:(CGFloat)constant;
|
||||
|
||||
/// 约束两个view,更大
|
||||
/// @param view1 view1
|
||||
/// @param attr1 view1约束
|
||||
/// @param view2 view2
|
||||
/// @param attr2 view2约束
|
||||
/// @param constant 距离
|
||||
+ (NSLayoutConstraint *)layoutViewGreater:(UIView *)view1
|
||||
attribute:(NSLayoutAttribute)attr1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr2
|
||||
constant:(CGFloat)constant;
|
||||
|
||||
/// 约束两个view,更小
|
||||
/// @param view1 view1
|
||||
/// @param attr1 view1约束
|
||||
/// @param view2 view2
|
||||
/// @param attr2 view2约束
|
||||
/// @param constant 距离
|
||||
+ (NSLayoutConstraint *)layoutViewLesser:(UIView *)view1
|
||||
attribute:(NSLayoutAttribute)attr1
|
||||
toView:(UIView *)view2
|
||||
attribute:(NSLayoutAttribute)attr2
|
||||
constant:(CGFloat)constant;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59cc175e6b9c2407391cbb7149b0d0f1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// TDSSDK.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2020/10/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapCommonSDK/TDSAccount.h>
|
||||
|
||||
#define TDS_COMMON_VERSION @"1.1.11"
|
||||
#define TDS_COMMON_VERSION_NUMBER @"11"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
typedef NSString *TDSLanguage NS_STRING_ENUM;
|
||||
|
||||
FOUNDATION_EXPORT TDSLanguage const TDSLanguageCN;
|
||||
FOUNDATION_EXPORT TDSLanguage const TDSLanguageEN;
|
||||
|
||||
@interface TDSBaseManager : NSObject
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
+ (instancetype)shareInstance;
|
||||
|
||||
- (void)setLanguage:(NSString *)language;
|
||||
|
||||
- (NSString *)getLanguage;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e25d31c76f72a4b368ecb79799df13b5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// bridge.h
|
||||
// bridge
|
||||
//
|
||||
// Created by xe on 2020/10/15.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <TapCommonSDK/TDSBridgeTool.h>
|
||||
#import <TapCommonSDK/TDSBridgeProxy.h>
|
||||
#import <TapCommonSDK/TDSBridgeCallback.h>
|
||||
#import <TapCommonSDK/TDSCommandTask.h>
|
||||
#import <TapCommonSDK/TDSCommand.h>
|
||||
#import <TapCommonSDK/TDSResult.h>
|
||||
|
||||
//! Project version number for bridge.
|
||||
FOUNDATION_EXPORT double bridgeVersionNumber;
|
||||
|
||||
//! Project version string for bridge.
|
||||
FOUNDATION_EXPORT const unsigned char bridgeVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <bridge/PublicHeader.h>
|
||||
|
||||
@interface TDSBridge : NSObject
|
||||
|
||||
@property (nonatomic, weak) id<TDSBridgeCallback>delegte;
|
||||
|
||||
+ (instancetype)instance;
|
||||
|
||||
- (void)callHandler:(NSString*) command;
|
||||
|
||||
- (void)registerHandler:(NSString*) command
|
||||
bridgeCallback:(id<TDSBridgeCallback>) callback;
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b2b82319f812341b38a5d373fff4d321
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// BridgeCallback.h
|
||||
// Bridge
|
||||
//
|
||||
// Created by xe on 2020/10/16.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol TDSBridgeCallback <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
- (void)onResult:(NSString *)msg;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ecc7b9cd4be644544ba5bc37ee9f9dbd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// BridgeException.h
|
||||
// EngineBridge
|
||||
//
|
||||
// Created by xe on 2020/10/9.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TDSBridgeException : NSException
|
||||
@end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 37a855ea140a045c6997669d7d3a38bd
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// EngineBridgeProxy.h
|
||||
// Bridge
|
||||
//
|
||||
// Created by xe on 2020/10/15.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapCommonSDK/TDSBridgeCallback.h>
|
||||
#import <TapCommonSDK/TDSBridge.h>
|
||||
|
||||
@interface TDSBridgeProxy : NSObject<TDSBridgeCallback>
|
||||
|
||||
+ (TDSBridgeProxy *)shareInstance;
|
||||
|
||||
- (void)onResult:(NSString*) result;
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9c7f91a62e3e4037b57268a3772a53e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// BridgeTool.h
|
||||
// EngineBridge
|
||||
//
|
||||
// Created by xe on 2020/10/9.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TDSBridgeTool : NSObject
|
||||
|
||||
+ (BOOL)isEmpty:(NSString *)str;
|
||||
|
||||
+ (NSString *)jsonStringWithString:(NSString *)string;
|
||||
|
||||
+ (NSString *)jsonStringWithArray:(NSArray *)array;
|
||||
|
||||
+ (NSString *)jsonStringWithDictionary:(NSDictionary *)dictionary;
|
||||
|
||||
+ (NSString *)jsonStringWithObject:(id)model;
|
||||
|
||||
+ (NSString *)jsonStringWithMutaDic:(NSDictionary *)dic;
|
||||
|
||||
+ (NSDictionary *)dictionaryWithModel:(id)model;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 903612c4b6e7147899541da71615f173
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Command.h
|
||||
// EngineBridge
|
||||
//
|
||||
// Created by xe on 2020/9/28.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@interface TDSCommand : NSObject
|
||||
|
||||
@property (nonatomic,copy) NSString* service;
|
||||
@property (nonatomic,copy) NSString* method;
|
||||
@property (nonatomic,copy) NSString* args;
|
||||
@property (nonatomic,copy) NSString* callbackId;
|
||||
@property (nonatomic,assign) BOOL callback;
|
||||
@property (nonatomic,assign) BOOL onceTime;
|
||||
|
||||
+ (TDSCommand*)constructorCommand:(NSString*)commandJSON;
|
||||
|
||||
- (NSString*)toJSON;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2895f85f34f24793acdc4323f8fc1ce
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// CommandTask.h
|
||||
// EngineBridge
|
||||
//
|
||||
// Created by xe on 2020/9/29.
|
||||
// Copyright © 2020 xe. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TapCommonSDK/TDSCommand.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSCommandTask : NSObject
|
||||
|
||||
- (void)execute:(TDSCommand *)command brigeCallback:(void (^)(NSString * resultJSON))result;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d277d0841e9d241d49dc3f3379f0ce1d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// TDSCommonConfirmDialog.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2021/3/2.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (^TDSCommonConfirmDialogHandler) (BOOL confirm);
|
||||
|
||||
@interface TDSCommonConfirmDialog : UIView
|
||||
- (void)setupWithTitle:(NSString *)title
|
||||
content:(NSString *)content
|
||||
cancelText:(NSString *)cancelText
|
||||
confirmText:(NSString *)confirmText
|
||||
handler:(TDSCommonConfirmDialogHandler)handler;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 735a3c112bb4a4a3fa777e11be7068f9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// TDSCommonHeader.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2020/9/29.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSCommonHeader : NSObject
|
||||
|
||||
- (instancetype)init:(NSString *)sdkName
|
||||
sdkVersionCode:(NSString *)sdkVersionCode
|
||||
sdkVersionName:(NSString *)sdkVersionName;
|
||||
|
||||
- (NSString *)getXUAValue;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f939eb683e5f4bc0936548d7228a427
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// TDSCommonMacros.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2021/1/7.
|
||||
//
|
||||
|
||||
# define isRND false
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSCommonMacros : NSObject
|
||||
|
||||
+ (bool)isCurrentRND;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2a0578a01f9343d590ae7d8c2007ed8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// TDSCommonService.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by TapTap-David on 2020/11/10.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSCommonService : NSObject
|
||||
+ (void)language:(NSString *)language;
|
||||
|
||||
+ (void)getRegionCode:(void (^)(NSString *result))callback;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7f451ab716cc4a85a9a9c9bb8d1a345
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// TDSCommonUIHelper.h
|
||||
// TDSCommon
|
||||
//
|
||||
// Created by Bottle K on 2021/3/2.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDSCommonUIHelper : NSObject
|
||||
|
||||
/// 从common bundle获取image
|
||||
+ (UIImage *)getImageFromCommonWithImageName:(NSString *)name;
|
||||
|
||||
/// 从bundle获取image
|
||||
+ (UIImage *)getImageFromBundle:(NSString *)bundleName withImage:(NSString *)imageName;
|
||||
|
||||
/// rgb转color
|
||||
+ (UIColor *)rgbToColorWithRed:(CGFloat)red
|
||||
green:(CGFloat)green
|
||||
blue:(CGFloat)blue;
|
||||
|
||||
/// rgba转color
|
||||
+ (UIColor *)rgbToColorWithRed:(CGFloat)red
|
||||
green:(CGFloat)green
|
||||
blue:(CGFloat)blue
|
||||
aplha:(CGFloat)alpha;
|
||||
|
||||
/// hex转color
|
||||
+ (UIColor *)hexToColor:(int)hexValue;
|
||||
|
||||
/// hex转color
|
||||
+ (UIColor *)hexToColor:(int)hexValue alpha:(CGFloat)alpha;
|
||||
|
||||
/// 屏幕宽度,会根据横竖屏的变化而变化
|
||||
+ (CGFloat)screenWidth;
|
||||
|
||||
/// 屏幕高度,会根据横竖屏的变化而变化
|
||||
+ (CGFloat)screenHeight;
|
||||
|
||||
/// 屏幕宽度,跟横竖屏无关
|
||||
+ (CGFloat)deviceWidth;
|
||||
|
||||
/// 屏幕高度,跟横竖屏无关
|
||||
+ (CGFloat)deviceHeight;
|
||||
|
||||
/// 用户界面横屏了才会返回YES
|
||||
+ (BOOL)isUILandscape;
|
||||
|
||||
/// 无论支不支持横屏,只要设备横屏了,就会返回YES
|
||||
+ (BOOL)isDeviceLandscape;
|
||||
|
||||
/// 是否有刘海
|
||||
+ (BOOL)hasNotch;
|
||||
|
||||
/// 安全区域(上左下右)
|
||||
+ (UIEdgeInsets)safeAreaInsets;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue