bingo 项目提交

This commit is contained in:
2026-04-20 13:49:36 +08:00
commit ad5920ac6a
5585 changed files with 1216243 additions and 0 deletions
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Editor
{
internal interface ISkAdNetworkParser
{
string GetExtension();
HashSet<string> ParseSource(ISkAdNetworkSource source);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97e0c61e3aa704af086868b25f08f85a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace Unity.Advertisement.IosSupport.Editor
{
public static class SkAdNetworkFileExtension
{
public const string XML = "xml";
public const string JSON = "json";
public const string NONE = "";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e496c38bf001040ecbe70e444a0542fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Editor
{
internal class SkAdNetworkJsonParser : ISkAdNetworkParser
{
[Serializable]
public class SkAdNetworkIdArray
{
public List<SkAdNetworkInfo> skadnetwork_ids;
}
[Serializable]
public class SkAdNetworkInfo
{
public string skadnetwork_id;
}
public string GetExtension()
{
return SkAdNetworkFileExtension.JSON;
}
public HashSet<string> ParseSource(ISkAdNetworkSource source)
{
var foundIds = new HashSet<string>();
try
{
string jsonData;
using (var stream = source.Open())
{
if (stream == null)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
return foundIds;
}
jsonData = new StreamReader(stream).ReadToEnd();
}
SkAdNetworkIdArray skAdNetworkCompanyInfo = null;
try
{
skAdNetworkCompanyInfo = JsonUtility.FromJson<SkAdNetworkIdArray>(jsonData);
}
catch (Exception) {}
//Fallback to try and see if this is a JSONObject which contains an array element called skadnetwork_ids instead of the expected JSONArray
if (skAdNetworkCompanyInfo?.skadnetwork_ids == null || skAdNetworkCompanyInfo.skadnetwork_ids.Count == 0)
{
var updatedJson = "{\"skadnetwork_ids\":" + jsonData + "}";
skAdNetworkCompanyInfo = JsonUtility.FromJson<SkAdNetworkIdArray>(updatedJson);
}
if (skAdNetworkCompanyInfo?.skadnetwork_ids == null)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
return foundIds;
}
foundIds.UnionWith(skAdNetworkCompanyInfo.skadnetwork_ids.Select(t => t.skadnetwork_id).Where(t => t != null));
}
catch (Exception)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
}
return foundIds;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9840479aaa6504c9ea96572abd23249c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
namespace Unity.Advertisement.IosSupport.Editor
{
internal static class SkAdNetworkParser
{
private static Dictionary<string, ISkAdNetworkParser> s_Parsers;
static SkAdNetworkParser()
{
s_Parsers = new Dictionary<string, ISkAdNetworkParser>
{
{ SkAdNetworkFileExtension.XML, new SkAdNetworkXmlParser() },
{ SkAdNetworkFileExtension.JSON, new SkAdNetworkJsonParser() },
{ SkAdNetworkFileExtension.NONE, new SkAdNetworkUrlParser() }
};
}
public static ISkAdNetworkParser GetParser(string parserType)
{
try
{
s_Parsers.TryGetValue(parserType, out var parser);
return parser;
}
catch (Exception) {}
return null;
}
public static IEnumerable<ISkAdNetworkParser> GetAllParsers()
{
return s_Parsers.Values;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f70ff3726241b4d2b8d0ea012c80e706
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Editor
{
internal class SkAdNetworkUrlParser : ISkAdNetworkParser
{
public string GetExtension()
{
return SkAdNetworkFileExtension.NONE;
}
public HashSet<string> ParseSource(ISkAdNetworkSource source)
{
var foundIds = new HashSet<string>();
try
{
string[] lines;
using (var reader = new StreamReader(source.Open()))
{
lines = reader.ReadToEnd().Split(Environment.NewLine.ToCharArray());
}
lines.Where(url => !string.IsNullOrEmpty(url))
.Where(url => Uri.IsWellFormedUriString(url, UriKind.Absolute))
.ToList().ForEach(url => {
ISkAdNetworkParser parser = null;
switch (GetExtensionFromPath(url))
{
case SkAdNetworkFileExtension.XML:
parser = SkAdNetworkParser.GetParser(SkAdNetworkFileExtension.XML);
break;
case SkAdNetworkFileExtension.JSON:
parser = SkAdNetworkParser.GetParser(SkAdNetworkFileExtension.JSON);
break;
}
if (parser == null)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unsupported file extension, No parser available to parse SKAdNetwork file: {source.Path} ");
return;
}
foundIds.UnionWith(parser.ParseSource(new SkAdNetworkRemoteSource(url)));
});
}
catch (Exception)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
}
return foundIds;
}
/// <summary>
/// Gets the extension for a filepath string
/// </summary>
private static string GetExtensionFromPath(string filepath)
{
var extension = Path.GetExtension(filepath);
return string.IsNullOrEmpty(extension) ? "" : extension.Substring(1).ToLower();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95e1f9f2b229246a08a2354f8c702ae9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Xml;
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Editor
{
internal class SkAdNetworkXmlParser : ISkAdNetworkParser
{
private const string k_SkAdNetworkIdentifier = "SKAdNetworkIdentifier";
public string GetExtension()
{
return SkAdNetworkFileExtension.XML;
}
public HashSet<string> ParseSource(ISkAdNetworkSource source)
{
var foundIds = new HashSet<string>();
try
{
var xmlDocument = new XmlDocument();
using (var stream = source.Open())
{
if (stream == null)
{
Debug.LogWarning("[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
return foundIds;
}
xmlDocument.Load(stream);
}
var items = xmlDocument.GetElementsByTagName("key");
for (var x = 0; x < items.Count; x++)
{
if (items[x].InnerText == k_SkAdNetworkIdentifier)
{
var nextSibling = items[x]?.NextSibling;
if (nextSibling != null)
{
foundIds.Add(nextSibling.InnerText);
}
}
}
}
catch (Exception)
{
Debug.LogWarning($"[Unity SKAdNetwork Parser] Unable to parse SKAdNetwork file: {source.Path}");
}
return foundIds;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b62c9c75b6cf84b3db11f5bb9f036169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: