com.amanotes.gdk 0.2.47 → 0.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/Editor/AmaGDKEditor.cs +133 -65
- package/Editor/AmaGDKExtra.cs +31 -0
- package/Editor/AmaGDKExtra.cs.meta +11 -0
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +1 -1
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Extra/SDKVersionTracking.unitypackage +0 -0
- package/Extra/SDKVersionTracking.unitypackage.meta +7 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Runtime/AmaGDK.Adapters.cs +0 -4
- package/Runtime/AmaGDK.Ads.cs +89 -29
- package/Runtime/AmaGDK.Analytics.cs +97 -64
- package/Runtime/AmaGDK.IAP.cs +39 -45
- package/Runtime/AmaGDK.RemoteConfig.cs +76 -52
- package/Runtime/AmaGDK.UserProfile.cs +106 -124
- package/Runtime/AmaGDK.cs +46 -35
- package/Runtime/Internal/AmaGDK.Event.cs +185 -0
- package/Runtime/Internal/AmaGDK.Event.cs.meta +3 -0
- package/Runtime/Internal/AmaGDK.Internal.cs +3 -0
- package/Runtime/Internal/AmaGDK.Utils.cs +85 -24
- package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs +19 -0
- package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/ConnectionAttribute.cs +18 -0
- package/Runtime/Klavar/Attributes/ConnectionAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs +27 -0
- package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/DescriptionAttribute.cs +7 -0
- package/Runtime/Klavar/Attributes/DescriptionAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs +30 -0
- package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/IgnoreAttribute.cs +16 -0
- package/Runtime/Klavar/Attributes/IgnoreAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/MinMaxAttribute.cs +130 -0
- package/Runtime/Klavar/Attributes/MinMaxAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs +88 -0
- package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/NameAttribute.cs +35 -0
- package/Runtime/Klavar/Attributes/NameAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/NotNullAttribute.cs +16 -0
- package/Runtime/Klavar/Attributes/NotNullAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs +58 -0
- package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs +28 -0
- package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/ToStringAttribute.cs +97 -0
- package/Runtime/Klavar/Attributes/ToStringAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes/ValueAttribute.cs +30 -0
- package/Runtime/Klavar/Attributes/ValueAttribute.cs.meta +11 -0
- package/Runtime/Klavar/Attributes.meta +8 -0
- package/Runtime/Klavar/KlavarEvent.cs +91 -0
- package/Runtime/Klavar/KlavarEvent.cs.meta +11 -0
- package/Runtime/Klavar/KlavarEventAttribute.cs +39 -0
- package/Runtime/Klavar/KlavarEventAttribute.cs.meta +11 -0
- package/Runtime/Klavar/KlavarEventTools.cs +92 -0
- package/Runtime/Klavar/KlavarEventTools.cs.meta +11 -0
- package/Runtime/Klavar/KlavarEventUtils.cs +58 -0
- package/Runtime/Klavar/KlavarEventUtils.cs.meta +11 -0
- package/Runtime/{Core.meta → Klavar.meta} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Reflection;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.Core
|
|
8
|
+
{
|
|
9
|
+
public partial class AmaGDK
|
|
10
|
+
{
|
|
11
|
+
internal static readonly Dispatcher dispatcher = new Dispatcher();
|
|
12
|
+
|
|
13
|
+
internal static void ThrowExceptionInEditor<T>(string message, Func<string, T> exceptionCreator) where T: Exception
|
|
14
|
+
{
|
|
15
|
+
#if UNITY_EDITOR
|
|
16
|
+
throw exceptionCreator(message);
|
|
17
|
+
#else
|
|
18
|
+
Debug.LogWarning(message);
|
|
19
|
+
#endif
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[Serializable] internal class EventEntry
|
|
23
|
+
{
|
|
24
|
+
public int nParams;
|
|
25
|
+
internal bool _dispatching;
|
|
26
|
+
public Delegate callbacks;
|
|
27
|
+
public Delegate callbackOnce;
|
|
28
|
+
|
|
29
|
+
public bool hasCallback => callbacks != null || callbackOnce != null;
|
|
30
|
+
|
|
31
|
+
internal void Add(Delegate d, bool once)
|
|
32
|
+
{
|
|
33
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
34
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
35
|
+
if (once)
|
|
36
|
+
{
|
|
37
|
+
callbackOnce = Delegate.Combine(callbackOnce, d);
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
{
|
|
41
|
+
callbacks = Delegate.Combine(callbacks, d);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
internal void Remove(Delegate d)
|
|
46
|
+
{
|
|
47
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
48
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
internal bool Dispatch(string eventName, object[] args)
|
|
54
|
+
{
|
|
55
|
+
if (_dispatching)
|
|
56
|
+
{
|
|
57
|
+
ThrowExceptionInEditor($"Nested dispatching is not supported, eventName: <{eventName}>",
|
|
58
|
+
(m) => new InvalidOperationException(m));
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (args.Length != nParams)
|
|
63
|
+
{
|
|
64
|
+
ThrowExceptionInEditor($"Dispatch <{eventName}> with incorrect number of params, expecting {nParams}, got {args.Length}!",
|
|
65
|
+
(m) => new TargetParameterCountException(m));
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_dispatching = true;
|
|
70
|
+
callbacks?.DynamicInvoke(args);
|
|
71
|
+
callbackOnce?.DynamicInvoke(args);
|
|
72
|
+
callbackOnce = null;
|
|
73
|
+
_dispatching = false;
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
internal class Dispatcher
|
|
80
|
+
{
|
|
81
|
+
internal readonly Dictionary<string, EventEntry> _eventMap = new Dictionary<string, EventEntry>();
|
|
82
|
+
internal void ClearAndReset()
|
|
83
|
+
{
|
|
84
|
+
_eventMap.Clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
internal EventEntry Get(string eventName)
|
|
88
|
+
{
|
|
89
|
+
if (string.IsNullOrEmpty(eventName)) return null;
|
|
90
|
+
_eventMap.TryGetValue(eventName, out EventEntry entry);
|
|
91
|
+
return entry;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
internal void AddListener(string eventName, Delegate d, bool once)
|
|
95
|
+
{
|
|
96
|
+
if (d == null)
|
|
97
|
+
{
|
|
98
|
+
Debug.LogWarning("Dispatcher.Add() error: d == null");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
int nParams = d.Method.GetParameters().Length;
|
|
103
|
+
EventEntry entry = Get(eventName);
|
|
104
|
+
|
|
105
|
+
if (entry == null)
|
|
106
|
+
{
|
|
107
|
+
entry = new EventEntry { nParams = nParams };
|
|
108
|
+
_eventMap.Add(eventName, entry);
|
|
109
|
+
}
|
|
110
|
+
else if (nParams != entry.nParams)
|
|
111
|
+
{
|
|
112
|
+
ThrowExceptionInEditor(string.Format(Internal.Messsage.DISPATCHER_WRONG_NUMBER_OF_PARAMS, eventName, entry.nParams, nParams),
|
|
113
|
+
(m) => new TargetParameterCountException(m));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Debug.Log("Add: " + eventName + " --> " + d + " | " + once);
|
|
118
|
+
entry.Add(d, once);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
internal void RemoveListener(string eventName, Delegate d)
|
|
122
|
+
{
|
|
123
|
+
if (d == null)
|
|
124
|
+
{
|
|
125
|
+
Debug.LogWarning("Dispatcher.Remove() error: d == null");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
EventEntry entry = Get(eventName);
|
|
130
|
+
entry?.Remove(d);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
internal void ClearListeners(string eventName)
|
|
134
|
+
{
|
|
135
|
+
if (_eventMap.ContainsKey(eventName)) _eventMap.Remove(eventName);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
internal void Dispatch(string eventName, params object[] data)
|
|
139
|
+
{
|
|
140
|
+
if (string.IsNullOrEmpty(eventName))
|
|
141
|
+
{
|
|
142
|
+
ThrowExceptionInEditor(
|
|
143
|
+
$"Invalid eventName: <{eventName}> (should not be null or empty)",
|
|
144
|
+
(m)=> new ArgumentException(m));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
EventEntry entry = Get(eventName);
|
|
149
|
+
if (entry == null) return;
|
|
150
|
+
|
|
151
|
+
if (!entry.hasCallback)
|
|
152
|
+
{
|
|
153
|
+
// string[] result = _eventMap
|
|
154
|
+
// .Select(kvp => kvp.Key + ":" + kvp.Value + "\n")
|
|
155
|
+
// .ToArray();
|
|
156
|
+
//
|
|
157
|
+
// Debug.LogWarning("AmaGDK [Event] No listener of type <" + eventName + ">\n\nRegistered events:\n\n" + string.Join("", result));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
TryCatchWrapper(() =>
|
|
162
|
+
{
|
|
163
|
+
entry.Dispatch(eventName, data);
|
|
164
|
+
}, !Application.isEditor);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
internal static void TryCatchWrapper(Action action, bool useTryCatch)
|
|
168
|
+
{
|
|
169
|
+
if (!useTryCatch)
|
|
170
|
+
{
|
|
171
|
+
action();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try
|
|
176
|
+
{
|
|
177
|
+
action();
|
|
178
|
+
} catch (Exception e)
|
|
179
|
+
{
|
|
180
|
+
Debug.LogWarning(e);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -26,6 +26,8 @@ namespace Amanotes.Core.Internal
|
|
|
26
26
|
public const string SDK_INIT_CALLED = "init has been called!";
|
|
27
27
|
public const string MULTIPLE_INSTANCE = "multiple instance found!";
|
|
28
28
|
public const string CONFIG_NOT_FOUND = "AmaGDKConfig not found in Resources!";
|
|
29
|
+
public const string DISPATCHER_WRONG_NUMBER_OF_PARAMS = "AddListener for eventName <{0}> expect {1} params but got {2}";
|
|
30
|
+
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
public static class Res
|
|
@@ -124,6 +126,7 @@ namespace Amanotes.Core.Internal
|
|
|
124
126
|
// Reset all modules
|
|
125
127
|
Ads.context = null;
|
|
126
128
|
Ads._adapter = null;
|
|
129
|
+
dispatcher.ClearAndReset();
|
|
127
130
|
|
|
128
131
|
_status = Status.None;
|
|
129
132
|
_allowInit = false;
|
|
@@ -66,6 +66,56 @@ namespace Amanotes.Core.Internal
|
|
|
66
66
|
if (Time.realtimeSinceStartup - time > timeoutInSecs) yield break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
public static bool IsFromTemplate(string formattedString, string template)
|
|
72
|
+
{
|
|
73
|
+
// Split the original template into segments based on the positions of placeholders
|
|
74
|
+
string[] segments = SplitTemplate(template);
|
|
75
|
+
|
|
76
|
+
// Check if each segment exists in the output string in the correct order
|
|
77
|
+
return AreSegmentsPresentInOrder(segments, formattedString);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static bool AreSegmentsPresentInOrder(string[] segments, string outputString)
|
|
81
|
+
{
|
|
82
|
+
var lastIndex = 0;
|
|
83
|
+
|
|
84
|
+
// Check if each segment exists in the output string in the correct order
|
|
85
|
+
foreach (string segment in segments)
|
|
86
|
+
{
|
|
87
|
+
int index = outputString.IndexOf(segment, lastIndex, StringComparison.Ordinal);
|
|
88
|
+
|
|
89
|
+
if (index == -1) return false;
|
|
90
|
+
lastIndex = index + segment.Length;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static string[] SplitTemplate(string template)
|
|
97
|
+
{
|
|
98
|
+
// Create a regex pattern to match placeholders like {0}, {1}, {2}, etc.
|
|
99
|
+
var pattern = @"\{(\d+)\}";
|
|
100
|
+
|
|
101
|
+
// Extract the indexes of placeholders from the original template
|
|
102
|
+
MatchCollection matches = Regex.Matches(template, pattern);
|
|
103
|
+
|
|
104
|
+
// Split the original template into segments based on the matched indexes
|
|
105
|
+
var segments = new string[matches.Count + 1];
|
|
106
|
+
var lastIndex = 0;
|
|
107
|
+
|
|
108
|
+
foreach (Match match in matches)
|
|
109
|
+
{
|
|
110
|
+
int index = int.Parse(match.Groups[1].Value);
|
|
111
|
+
segments[index] = template.Substring(lastIndex, match.Index - lastIndex);
|
|
112
|
+
lastIndex = match.Index + match.Length;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// The last segment corresponds to the content after the last placeholder
|
|
116
|
+
segments[matches.Count] = template.Substring(lastIndex);
|
|
117
|
+
return segments;
|
|
118
|
+
}
|
|
69
119
|
}
|
|
70
120
|
|
|
71
121
|
public static class GDKReflection
|
|
@@ -87,8 +137,8 @@ namespace Amanotes.Core.Internal
|
|
|
87
137
|
}
|
|
88
138
|
|
|
89
139
|
}
|
|
90
|
-
|
|
91
|
-
|
|
140
|
+
|
|
141
|
+
public static class GDKFileUtils
|
|
92
142
|
{
|
|
93
143
|
private static string _basePath;
|
|
94
144
|
private static string basePath
|
|
@@ -115,7 +165,7 @@ namespace Amanotes.Core.Internal
|
|
|
115
165
|
return File.Exists(GetPath(fileName));
|
|
116
166
|
}
|
|
117
167
|
|
|
118
|
-
|
|
168
|
+
public static void Save(string fileName, string content)
|
|
119
169
|
{
|
|
120
170
|
if (string.IsNullOrWhiteSpace(fileName))
|
|
121
171
|
{
|
|
@@ -188,7 +238,7 @@ namespace Amanotes.Core.Internal
|
|
|
188
238
|
}
|
|
189
239
|
}
|
|
190
240
|
|
|
191
|
-
|
|
241
|
+
public static string Load(string fileName)
|
|
192
242
|
{
|
|
193
243
|
var content = "";
|
|
194
244
|
|
|
@@ -247,6 +297,33 @@ namespace Amanotes.Core.Internal
|
|
|
247
297
|
}
|
|
248
298
|
Debug.Log(sb);
|
|
249
299
|
}
|
|
300
|
+
|
|
301
|
+
public static T LoadJsonFromFile<T>(T instance) where T: new()
|
|
302
|
+
{
|
|
303
|
+
instance ??= new T();
|
|
304
|
+
|
|
305
|
+
string fileName = instance.GetType().Name;
|
|
306
|
+
string json = Load(fileName);
|
|
307
|
+
if (!string.IsNullOrEmpty(json))
|
|
308
|
+
{
|
|
309
|
+
try
|
|
310
|
+
{
|
|
311
|
+
JsonUtility.FromJsonOverwrite(json, instance);
|
|
312
|
+
} catch (Exception e)
|
|
313
|
+
{
|
|
314
|
+
LogWarning("LoadJsonFromFile error: " + fileName + "\n" + e);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return instance;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public static void SaveJsonToFile<T>(T instance)
|
|
322
|
+
{
|
|
323
|
+
string fileName = instance.GetType().Name;
|
|
324
|
+
string json = JsonUtility.ToJson(instance);
|
|
325
|
+
Save(fileName, json);
|
|
326
|
+
}
|
|
250
327
|
}
|
|
251
328
|
|
|
252
329
|
public class ActionQueue
|
|
@@ -313,34 +390,18 @@ namespace Amanotes.Core.Internal
|
|
|
313
390
|
}
|
|
314
391
|
|
|
315
392
|
internal interface IJsonFile { }
|
|
393
|
+
|
|
316
394
|
|
|
317
395
|
internal static class JsonFileExtension
|
|
318
396
|
{
|
|
319
397
|
public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
|
|
320
398
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
string fileName = instance.GetType().Name;
|
|
324
|
-
string json = GDKFileUtils.Load(fileName);
|
|
325
|
-
if (!string.IsNullOrEmpty(json))
|
|
326
|
-
{
|
|
327
|
-
try
|
|
328
|
-
{
|
|
329
|
-
JsonUtility.FromJsonOverwrite(json, instance);
|
|
330
|
-
} catch (Exception e)
|
|
331
|
-
{
|
|
332
|
-
LogWarning("LoadJsonFromFile error: " + fileName + "\n" + e);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return instance;
|
|
399
|
+
return GDKFileUtils.LoadJsonFromFile(instance);
|
|
337
400
|
}
|
|
338
401
|
|
|
339
|
-
public static void SaveJsonToFile<T>(this T instance) where T
|
|
402
|
+
public static void SaveJsonToFile<T>(this T instance) where T: IJsonFile
|
|
340
403
|
{
|
|
341
|
-
|
|
342
|
-
string json = JsonUtility.ToJson(instance);
|
|
343
|
-
GDKFileUtils.Save(fileName, json);
|
|
404
|
+
GDKFileUtils.SaveJsonToFile(instance);
|
|
344
405
|
}
|
|
345
406
|
}
|
|
346
407
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Accumulated Count Attribute
|
|
8
|
+
/// </summary>
|
|
9
|
+
///
|
|
10
|
+
public class AccumulatedCountAttribute : ConverterLogEventAttribute
|
|
11
|
+
{
|
|
12
|
+
public override object Convert(object parent, FieldInfo fieldInfo, object param)
|
|
13
|
+
{
|
|
14
|
+
var classType = parent.GetType();
|
|
15
|
+
var attr = (EventNameAttribute) GetCustomAttribute(classType, typeof(EventNameAttribute));
|
|
16
|
+
return AmaGDK.Analytics.GetAccumulatedCount(attr.name) + 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Get Connection Attribute
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class ConnectionAttribute : ConverterLogEventAttribute
|
|
11
|
+
{
|
|
12
|
+
public override object Convert(object parent, FieldInfo fieldInfo, object param)
|
|
13
|
+
{
|
|
14
|
+
return Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork ?
|
|
15
|
+
"online" : "offline";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Get Connection Attribute
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class CountInSessionAttribute : ConverterLogEventAttribute
|
|
11
|
+
{
|
|
12
|
+
static readonly Dictionary<string, int> countInSessions = new Dictionary<string, int>();
|
|
13
|
+
|
|
14
|
+
public override object Convert(object parent, FieldInfo fieldInfo, object param)
|
|
15
|
+
{
|
|
16
|
+
// return AmaGDK.Ads.InterstitialShowCalledInSession;
|
|
17
|
+
string name = parent.GetType().FullName;
|
|
18
|
+
if (!countInSessions.TryGetValue(name, out var count))
|
|
19
|
+
{
|
|
20
|
+
count = countInSessions[name] = 1;
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
count = countInSessions[name] = count + 1;
|
|
24
|
+
return count;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Dynamic validate param by Function
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class DynamicValidateAttribute : ValidateLogEventAttribute
|
|
10
|
+
{
|
|
11
|
+
readonly string functioName;
|
|
12
|
+
public DynamicValidateAttribute(string functionName)
|
|
13
|
+
{
|
|
14
|
+
this.functioName = functionName;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
18
|
+
{
|
|
19
|
+
var function = param.GetType().GetMethod(functioName);
|
|
20
|
+
try
|
|
21
|
+
{
|
|
22
|
+
function?.Invoke(parent, new object[] { param });
|
|
23
|
+
}
|
|
24
|
+
catch (Exception e)
|
|
25
|
+
{
|
|
26
|
+
throw new ArgumentException($"Field {fieldInfo.Name} is in-valid with error {e.Message}");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|