com.amanotes.gdk 0.2.46 → 0.2.48
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 +9 -1
- package/Editor/AmaGDKEditor.cs +281 -104
- package/Editor/MatchSDKVersion.cs +3 -6
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +5 -1
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -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/{FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta → AppsFlyerAdapter.unitypackage.meta} +1 -1
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/{AppsFlyerAdapter_v6.5.4.unitypackage.meta → FirebaseAnalyticsAdapter.unitypackage.meta} +1 -1
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/{IronSourceAdapter_v7.5.2.unitypackage.meta → FirebaseRemoteConfigAdapter.unitypackage.meta} +1 -1
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/{FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta → IronSourceAdapter.unitypackage.meta} +1 -1
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage.meta +7 -0
- package/Runtime/AmaGDK.Adapters.cs +55 -77
- package/Runtime/AmaGDK.Ads.cs +160 -174
- package/Runtime/AmaGDK.Analytics.cs +245 -125
- package/Runtime/AmaGDK.Config.cs +2 -1
- package/Runtime/AmaGDK.IAP.cs +47 -48
- package/Runtime/AmaGDK.RemoteConfig.cs +38 -35
- package/Runtime/AmaGDK.UserProfile.cs +27 -19
- package/Runtime/AmaGDK.cs +158 -111
- package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +8 -3
- package/Runtime/Internal/AmaGDK.Internal.SemVer.cs +21 -17
- package/Runtime/Internal/AmaGDK.Internal.cs +17 -6
- package/Runtime/Internal/AmaGDK.Utils.cs +78 -11
- 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 +12 -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/Klavar.meta +12 -0
- package/package.json +1 -1
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage.meta +0 -7
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage.meta +0 -7
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Min, Max validate param
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class MinMaxAttribute : ValidateLogEventAttribute
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
public readonly double min;
|
|
13
|
+
|
|
14
|
+
public readonly double max;
|
|
15
|
+
|
|
16
|
+
public MinMaxAttribute(double min, double max)
|
|
17
|
+
{
|
|
18
|
+
this.min = min;
|
|
19
|
+
this.max = max;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
24
|
+
{
|
|
25
|
+
if (!(param is int) && !(param is float) && !(param is double))
|
|
26
|
+
throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
|
|
27
|
+
|
|
28
|
+
double val = Convert.ToDouble(param);
|
|
29
|
+
if (val < min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current value: {param}");
|
|
30
|
+
if (val > max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current value: {param}");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
public class MinimumAttribute : ValidateLogEventAttribute
|
|
36
|
+
{
|
|
37
|
+
|
|
38
|
+
public readonly double min;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public MinimumAttribute(double min)
|
|
42
|
+
{
|
|
43
|
+
this.min = min;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
48
|
+
{
|
|
49
|
+
if (!(param is int) && !(param is float) && !(param is double))
|
|
50
|
+
throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
|
|
51
|
+
|
|
52
|
+
double val = Convert.ToDouble(param);
|
|
53
|
+
if (val < min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be greater or equal to {min}. Current value: {param}");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
public class ExclusiveMinimumAttribute : ValidateLogEventAttribute
|
|
59
|
+
{
|
|
60
|
+
|
|
61
|
+
public readonly double min;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
public ExclusiveMinimumAttribute(double min)
|
|
65
|
+
{
|
|
66
|
+
this.min = min;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
71
|
+
{
|
|
72
|
+
if (!(param is int) && !(param is float) && !(param is double))
|
|
73
|
+
throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
|
|
74
|
+
|
|
75
|
+
double val = Convert.ToDouble(param);
|
|
76
|
+
if (val <= min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be greater {min}. Current value: {param}");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
public class MaximumAttribute : ValidateLogEventAttribute
|
|
85
|
+
{
|
|
86
|
+
|
|
87
|
+
public readonly double max;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
public MaximumAttribute(double max)
|
|
91
|
+
{
|
|
92
|
+
this.max = max;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
97
|
+
{
|
|
98
|
+
if (!(param is int) && !(param is float) && !(param is double))
|
|
99
|
+
throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
|
|
100
|
+
|
|
101
|
+
double val = Convert.ToDouble(param);
|
|
102
|
+
if (val > max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be smaller or equal to {max}. Current value: {param}");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
public class ExclusiveMaximumAttribute : ValidateLogEventAttribute
|
|
108
|
+
{
|
|
109
|
+
|
|
110
|
+
public readonly double max;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
public ExclusiveMaximumAttribute(double max)
|
|
114
|
+
{
|
|
115
|
+
this.max = max;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
120
|
+
{
|
|
121
|
+
if (!(param is int) && !(param is float) && !(param is double))
|
|
122
|
+
throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
|
|
123
|
+
|
|
124
|
+
double val = Convert.ToDouble(param);
|
|
125
|
+
if (val >= max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be smaller to {max}. Current value: {param}");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Min, Max length valudate validate param. (Just apply for string only)
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class MinMaxLengthAttribute : ValidateLogEventAttribute
|
|
10
|
+
{
|
|
11
|
+
public readonly int min;
|
|
12
|
+
public readonly int max;
|
|
13
|
+
|
|
14
|
+
public MinMaxLengthAttribute(int min, int max)
|
|
15
|
+
{
|
|
16
|
+
this.min = min;
|
|
17
|
+
this.max = max;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
22
|
+
{
|
|
23
|
+
if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
|
|
24
|
+
if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
|
|
25
|
+
if (text.Length < min) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current length: {text.Length}");
|
|
26
|
+
if (text.Length > max) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current length: {text.Length}");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
public class MinLengthAttribute : ValidateLogEventAttribute
|
|
32
|
+
{
|
|
33
|
+
public readonly int min;
|
|
34
|
+
|
|
35
|
+
public MinLengthAttribute(int min)
|
|
36
|
+
{
|
|
37
|
+
this.min = min;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
42
|
+
{
|
|
43
|
+
if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
|
|
44
|
+
if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
|
|
45
|
+
if (text.Length < min) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be greater or equal to {min}. Current length: {text.Length}");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public class MaxLengthAttribute : ValidateLogEventAttribute
|
|
51
|
+
{
|
|
52
|
+
public readonly int max;
|
|
53
|
+
|
|
54
|
+
public MaxLengthAttribute(int max)
|
|
55
|
+
{
|
|
56
|
+
this.max = max;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
61
|
+
{
|
|
62
|
+
if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
|
|
63
|
+
if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
|
|
64
|
+
if (text.Length > max) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be smaller or equal to {max}. Current length: {text.Length}");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public class FixedLengthAttribute : ValidateLogEventAttribute
|
|
70
|
+
{
|
|
71
|
+
public readonly int length;
|
|
72
|
+
|
|
73
|
+
public FixedLengthAttribute(int length)
|
|
74
|
+
{
|
|
75
|
+
this.length = length;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
79
|
+
{
|
|
80
|
+
if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
|
|
81
|
+
if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
|
|
82
|
+
if (text.Length != length)
|
|
83
|
+
throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be equal to {length}. Current length: {text.Length}");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Change the Name of param
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class NameAttribute : NamingLogEventAttribute
|
|
11
|
+
{
|
|
12
|
+
public readonly string name;
|
|
13
|
+
|
|
14
|
+
public NameAttribute(string name)
|
|
15
|
+
{
|
|
16
|
+
this.name = name;
|
|
17
|
+
}
|
|
18
|
+
public override string GetName(object parent, FieldInfo fieldInfo) => name;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
/// Set the event name
|
|
25
|
+
/// </summary>
|
|
26
|
+
public class EventNameAttribute : KlavarEventAttribute
|
|
27
|
+
{
|
|
28
|
+
public readonly string name;
|
|
29
|
+
|
|
30
|
+
public EventNameAttribute(string name)
|
|
31
|
+
{
|
|
32
|
+
this.name = name;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
|
|
4
|
+
namespace Amanotes.Core
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Not null validate param
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class NotNullAttribute : ValidateLogEventAttribute
|
|
10
|
+
{
|
|
11
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
12
|
+
{
|
|
13
|
+
if (param is null) throw new ArgumentException($"Field `{fieldInfo.Name}` must not be null");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using System.Text.RegularExpressions;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
#pragma warning disable CS3015
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Apply Regex Validation for param
|
|
11
|
+
/// </summary>
|
|
12
|
+
public class RegexPatternAttribute : ValidateLogEventAttribute
|
|
13
|
+
{
|
|
14
|
+
public readonly string[] regexes;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
public RegexPatternAttribute(string regex)
|
|
18
|
+
{
|
|
19
|
+
this.regexes = new string[] { regex };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
public RegexPatternAttribute(string[] regexes)
|
|
24
|
+
{
|
|
25
|
+
this.regexes = regexes;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
public override void Validate(object parent, FieldInfo fieldInfo, object param)
|
|
30
|
+
{
|
|
31
|
+
if (param is null) throw new ArgumentException($"Field `{fieldInfo.Name}` must not be null");
|
|
32
|
+
foreach (var regex in regexes)
|
|
33
|
+
{
|
|
34
|
+
var match = Regex.Match(param.ToString(), regex);
|
|
35
|
+
if (match != null && match.Success) return;
|
|
36
|
+
}
|
|
37
|
+
throw new ArgumentException($"Field `{fieldInfo.Name}` is not match as {this.GetType().Name.Replace("Attribute", "")}");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pragma warning restore CA2200
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// Is Email validate Param
|
|
45
|
+
/// </summary>
|
|
46
|
+
public class IsEmailAddressAttribute : RegexPatternAttribute
|
|
47
|
+
{
|
|
48
|
+
public IsEmailAddressAttribute() : base(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$") { }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
/// Is ObjectID validate param
|
|
53
|
+
/// </summary>
|
|
54
|
+
public class IsObjectIDAttribute : RegexPatternAttribute
|
|
55
|
+
{
|
|
56
|
+
public IsObjectIDAttribute() : base(@"^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)") { }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
public class TimeDiffLastFireAttribute : ConverterLogEventAttribute
|
|
8
|
+
{
|
|
9
|
+
static readonly Dictionary<string, float> lastFireInSessions = new Dictionary<string, float>();
|
|
10
|
+
|
|
11
|
+
public override object Convert(object parent, FieldInfo fieldInfo, object param)
|
|
12
|
+
{
|
|
13
|
+
// return AmaGDK.Ads.InterstitialShowCalledInSession;
|
|
14
|
+
string name = parent.GetType().FullName;
|
|
15
|
+
if (!lastFireInSessions.TryGetValue(name, out var lastFire))
|
|
16
|
+
{
|
|
17
|
+
lastFireInSessions[name] = Time.realtimeSinceStartup;
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var current = Time.realtimeSinceStartup;
|
|
22
|
+
var diff = Mathf.RoundToInt(current - lastFire);
|
|
23
|
+
lastFireInSessions[name] = current;
|
|
24
|
+
return diff;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|