diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/GoogleMobileAds/Api |
+init
Diffstat (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Api')
20 files changed, 977 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdErrorEventArgs.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdErrorEventArgs.cs new file mode 100644 index 0000000..ab105d0 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdErrorEventArgs.cs @@ -0,0 +1,9 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class AdErrorEventArgs : EventArgs + { + public string Message { get; set; } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdFailedToLoadEventArgs.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdFailedToLoadEventArgs.cs new file mode 100644 index 0000000..42389fc --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdFailedToLoadEventArgs.cs @@ -0,0 +1,9 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class AdFailedToLoadEventArgs : EventArgs + { + public string Message { get; set; } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdLoader.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdLoader.cs new file mode 100644 index 0000000..3116a90 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdLoader.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class AdLoader + { + public Dictionary<string, Action<CustomNativeTemplateAd, string>> CustomNativeTemplateClickHandlers { get; private set; } + + public string AdUnitId { get; private set; } + + public HashSet<NativeAdType> AdTypes { get; private set; } + + public HashSet<string> TemplateIds { get; private set; } + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<CustomNativeEventArgs> OnCustomNativeTemplateAdLoaded; + + private IAdLoaderClient adLoaderClient; + + public class Builder + { + internal string AdUnitId { get; private set; } + + internal HashSet<NativeAdType> AdTypes { get; private set; } + + internal HashSet<string> TemplateIds { get; private set; } + + internal Dictionary<string, Action<CustomNativeTemplateAd, string>> CustomNativeTemplateClickHandlers { get; private set; } + + public Builder(string adUnitId) + { + this.AdUnitId = adUnitId; + this.AdTypes = new HashSet<NativeAdType>(); + this.TemplateIds = new HashSet<string>(); + this.CustomNativeTemplateClickHandlers = new Dictionary<string, Action<CustomNativeTemplateAd, string>>(); + } + + public AdLoader.Builder ForCustomNativeAd(string templateId) + { + this.TemplateIds.Add(templateId); + this.AdTypes.Add(NativeAdType.CustomTemplate); + return this; + } + + public AdLoader.Builder ForCustomNativeAd(string templateId, Action<CustomNativeTemplateAd, string> callback) + { + this.TemplateIds.Add(templateId); + this.CustomNativeTemplateClickHandlers[templateId] = callback; + this.AdTypes.Add(NativeAdType.CustomTemplate); + return this; + } + + public AdLoader Build() + { + return new AdLoader(this); + } + } + + private AdLoader(AdLoader.Builder builder) + { + this.AdUnitId = string.Copy(builder.AdUnitId); + this.CustomNativeTemplateClickHandlers = new Dictionary<string, Action<CustomNativeTemplateAd, string>>(builder.CustomNativeTemplateClickHandlers); + this.TemplateIds = new HashSet<string>(builder.TemplateIds); + this.AdTypes = new HashSet<NativeAdType>(builder.AdTypes); + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildAdLoaderClient", BindingFlags.Static | BindingFlags.Public); + this.adLoaderClient = (IAdLoaderClient)method.Invoke(null, new object[] + { + this + }); + Utils.CheckInitialization(); + this.adLoaderClient.OnCustomNativeTemplateAdLoaded += delegate(object sender, CustomNativeEventArgs args) + { + this.OnCustomNativeTemplateAdLoaded(this, args); + }; + this.adLoaderClient.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + } + + public void LoadAd(AdRequest request) + { + this.adLoaderClient.LoadAd(request); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdPosition.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdPosition.cs new file mode 100644 index 0000000..6bc2a49 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdPosition.cs @@ -0,0 +1,15 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public enum AdPosition + { + Top, + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight, + Center + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdRequest.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdRequest.cs new file mode 100644 index 0000000..a303ea9 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdRequest.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using GoogleMobileAds.Api.Mediation; + +namespace GoogleMobileAds.Api +{ + public class AdRequest + { + public List<string> TestDevices { get; private set; } + + public HashSet<string> Keywords { get; private set; } + + public DateTime? Birthday { get; private set; } + + public Gender? Gender { get; private set; } + + public bool? TagForChildDirectedTreatment { get; private set; } + + public Dictionary<string, string> Extras { get; private set; } + + public List<MediationExtras> MediationExtras { get; private set; } + + public const string Version = "3.17.0"; + + public const string TestDeviceSimulator = "SIMULATOR"; + + public class Builder + { + internal List<string> TestDevices { get; private set; } + + internal HashSet<string> Keywords { get; private set; } + + internal DateTime? Birthday { get; private set; } + + internal Gender? Gender { get; private set; } + + internal bool? ChildDirectedTreatmentTag { get; private set; } + + internal Dictionary<string, string> Extras { get; private set; } + + internal List<MediationExtras> MediationExtras { get; private set; } + + public Builder() + { + this.TestDevices = new List<string>(); + this.Keywords = new HashSet<string>(); + this.Birthday = null; + this.Gender = null; + this.ChildDirectedTreatmentTag = null; + this.Extras = new Dictionary<string, string>(); + this.MediationExtras = new List<MediationExtras>(); + } + + public AdRequest.Builder AddKeyword(string keyword) + { + this.Keywords.Add(keyword); + return this; + } + + public AdRequest.Builder AddTestDevice(string deviceId) + { + this.TestDevices.Add(deviceId); + return this; + } + + public AdRequest Build() + { + return new AdRequest(this); + } + + public AdRequest.Builder SetBirthday(DateTime birthday) + { + this.Birthday = new DateTime?(birthday); + return this; + } + + public AdRequest.Builder SetGender(Gender gender) + { + this.Gender = new Gender?(gender); + return this; + } + + public AdRequest.Builder AddMediationExtras(MediationExtras extras) + { + this.MediationExtras.Add(extras); + return this; + } + + public AdRequest.Builder TagForChildDirectedTreatment(bool tagForChildDirectedTreatment) + { + this.ChildDirectedTreatmentTag = new bool?(tagForChildDirectedTreatment); + return this; + } + + public AdRequest.Builder AddExtra(string key, string value) + { + this.Extras.Add(key, value); + return this; + } + } + + private AdRequest(AdRequest.Builder builder) + { + this.TestDevices = new List<string>(builder.TestDevices); + this.Keywords = new HashSet<string>(builder.Keywords); + this.Birthday = builder.Birthday; + this.Gender = builder.Gender; + this.TagForChildDirectedTreatment = builder.ChildDirectedTreatmentTag; + this.Extras = new Dictionary<string, string>(builder.Extras); + this.MediationExtras = builder.MediationExtras; + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdSize.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdSize.cs new file mode 100644 index 0000000..ec5f3f1 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdSize.cs @@ -0,0 +1,88 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class AdSize + { + public int Width + { + get + { + return this.width; + } + } + + public int Height + { + get + { + return this.height; + } + } + + public bool IsSmartBanner + { + get + { + return this.isSmartBanner; + } + } + + private bool isSmartBanner; + + private int width; + + private int height; + + public static readonly AdSize Banner = new AdSize(320, 50); + + public static readonly AdSize MediumRectangle = new AdSize(300, 250); + + public static readonly AdSize IABBanner = new AdSize(468, 60); + + public static readonly AdSize Leaderboard = new AdSize(728, 90); + + public static readonly AdSize SmartBanner = new AdSize(true); + + public static readonly int FullWidth = -1; + + public AdSize(int width, int height) + { + this.isSmartBanner = false; + this.width = width; + this.height = height; + } + + private AdSize(bool isSmartBanner) : this(0, 0) + { + this.isSmartBanner = isSmartBanner; + } + + public override bool Equals(object obj) + { + if (obj == null || base.GetType() != obj.GetType()) + { + return false; + } + AdSize adSize = (AdSize)obj; + return this.width == adSize.width && this.height == adSize.height && this.isSmartBanner == adSize.isSmartBanner; + } + + public static bool operator ==(AdSize a, AdSize b) + { + return a.Equals(b); + } + + public static bool operator !=(AdSize a, AdSize b) + { + return !a.Equals(b); + } + + public override int GetHashCode() + { + int num = 71; + int num2 = 11; + return ((num * num2 ^ this.width.GetHashCode()) * num2 ^ this.height.GetHashCode()) * num2 ^ this.isSmartBanner.GetHashCode(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterState.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterState.cs new file mode 100644 index 0000000..471e180 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterState.cs @@ -0,0 +1,10 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public enum AdapterState + { + NotReady, + Ready + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterStatus.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterStatus.cs new file mode 100644 index 0000000..31451e3 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/AdapterStatus.cs @@ -0,0 +1,20 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class AdapterStatus + { + public AdapterState InitializationState { get; private set; } + + public string Description { get; private set; } + + public int Latency { get; private set; } + + internal AdapterStatus(AdapterState state, string description, int latency) + { + this.InitializationState = state; + this.Description = description; + this.Latency = latency; + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs new file mode 100644 index 0000000..7ad2724 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/BannerView.cs @@ -0,0 +1,121 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class BannerView + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<EventArgs> OnAdLeavingApplication; + + private IBannerClient client; + + public BannerView(string adUnitId, AdSize adSize, AdPosition position) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildBannerClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IBannerClient)method.Invoke(null, null); + this.client.CreateBannerView(adUnitId, adSize, position); + this.ConfigureBannerEvents(); + } + + public BannerView(string adUnitId, AdSize adSize, int x, int y) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildBannerClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IBannerClient)method.Invoke(null, null); + this.client.CreateBannerView(adUnitId, adSize, x, y); + this.ConfigureBannerEvents(); + } + + public void LoadAd(AdRequest request) + { + this.client.LoadAd(request); + } + + public void Hide() + { + this.client.HideBannerView(); + } + + public void Show() + { + this.client.ShowBannerView(); + } + + public void Destroy() + { + this.client.DestroyBannerView(); + } + + public float GetHeightInPixels() + { + return this.client.GetHeightInPixels(); + } + + public float GetWidthInPixels() + { + return this.client.GetWidthInPixels(); + } + + public void SetPosition(AdPosition adPosition) + { + this.client.SetPosition(adPosition); + } + + public void SetPosition(int x, int y) + { + this.client.SetPosition(x, y); + } + + private void ConfigureBannerEvents() + { + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnAdLeavingApplication += delegate(object sender, EventArgs args) + { + if (this.OnAdLeavingApplication != null) + { + this.OnAdLeavingApplication(this, args); + } + }; + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeEventArgs.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeEventArgs.cs new file mode 100644 index 0000000..692b54b --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeEventArgs.cs @@ -0,0 +1,9 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class CustomNativeEventArgs : EventArgs + { + public CustomNativeTemplateAd nativeAd { get; set; } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeTemplateAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeTemplateAd.cs new file mode 100644 index 0000000..159341b --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/CustomNativeTemplateAd.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using GoogleMobileAds.Common; +using UnityEngine; + +namespace GoogleMobileAds.Api +{ + public class CustomNativeTemplateAd + { + private ICustomNativeTemplateClient client; + + internal CustomNativeTemplateAd(ICustomNativeTemplateClient client) + { + this.client = client; + } + + public List<string> GetAvailableAssetNames() + { + return this.client.GetAvailableAssetNames(); + } + + public string GetCustomTemplateId() + { + return this.client.GetTemplateId(); + } + + public Texture2D GetTexture2D(string key) + { + byte[] imageByteArray = this.client.GetImageByteArray(key); + if (imageByteArray == null) + { + return null; + } + return Utils.GetTexture2DFromByteArray(imageByteArray); + } + + public string GetText(string key) + { + return this.client.GetText(key); + } + + public void PerformClick(string assetName) + { + this.client.PerformClick(assetName); + } + + public void RecordImpression() + { + this.client.RecordImpression(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/Gender.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/Gender.cs new file mode 100644 index 0000000..afdd035 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/Gender.cs @@ -0,0 +1,11 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public enum Gender + { + Unknown, + Male, + Female + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs new file mode 100644 index 0000000..e9817bb --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/InterstitialAd.cs @@ -0,0 +1,88 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class InterstitialAd + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<EventArgs> OnAdLeavingApplication; + + private IInterstitialClient client; + + public InterstitialAd(string adUnitId) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildInterstitialClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IInterstitialClient)method.Invoke(null, null); + this.client.CreateInterstitialAd(adUnitId); + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnAdLeavingApplication += delegate(object sender, EventArgs args) + { + if (this.OnAdLeavingApplication != null) + { + this.OnAdLeavingApplication(this, args); + } + }; + } + + public void LoadAd(AdRequest request) + { + this.client.LoadAd(request); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.ShowInterstitial(); + } + + public void Destroy() + { + this.client.DestroyInterstitial(); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/Mediation/MediationExtras.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/Mediation/MediationExtras.cs new file mode 100644 index 0000000..1604ec7 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/Mediation/MediationExtras.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace GoogleMobileAds.Api.Mediation +{ + public abstract class MediationExtras + { + public Dictionary<string, string> Extras { get; protected set; } + + public abstract string AndroidMediationExtraBuilderClassName { get; } + + public abstract string IOSMediationExtraBuilderClassName { get; } + + public MediationExtras() + { + this.Extras = new Dictionary<string, string>(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/MobileAds.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/MobileAds.cs new file mode 100644 index 0000000..38199b3 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/MobileAds.cs @@ -0,0 +1,37 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class MobileAds + { + private static readonly IMobileAdsClient client = MobileAds.GetMobileAdsClient(); + + public static void Initialize(string appId) + { + MobileAds.client.Initialize(appId); + MobileAdsEventExecutor.Initialize(); + } + + public static void SetApplicationMuted(bool muted) + { + MobileAds.client.SetApplicationMuted(muted); + } + + public static void SetApplicationVolume(float volume) + { + MobileAds.client.SetApplicationVolume(volume); + } + + public static void SetiOSAppPauseOnBackground(bool pause) + { + MobileAds.client.SetiOSAppPauseOnBackground(pause); + } + + private static IMobileAdsClient GetMobileAdsClient() + { + return (IMobileAdsClient)Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("MobileAdsInstance", BindingFlags.Static | BindingFlags.Public).Invoke(null, null); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/NativeAdType.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/NativeAdType.cs new file mode 100644 index 0000000..98c1e39 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/NativeAdType.cs @@ -0,0 +1,9 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public enum NativeAdType + { + CustomTemplate + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/Reward.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/Reward.cs new file mode 100644 index 0000000..1e0beda --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/Reward.cs @@ -0,0 +1,11 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class Reward : EventArgs + { + public string Type { get; set; } + + public double Amount { get; set; } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs new file mode 100644 index 0000000..90f069a --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardBasedVideoAd.cs @@ -0,0 +1,125 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class RewardBasedVideoAd + { + public static RewardBasedVideoAd Instance + { + get + { + return RewardBasedVideoAd.instance; + } + } + + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdStarted; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<Reward> OnAdRewarded; + + public event EventHandler<EventArgs> OnAdLeavingApplication; + + public event EventHandler<EventArgs> OnAdCompleted; + + private IRewardBasedVideoAdClient client; + + private static readonly RewardBasedVideoAd instance = new RewardBasedVideoAd(); + + private RewardBasedVideoAd() + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildRewardBasedVideoAdClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IRewardBasedVideoAdClient)method.Invoke(null, null); + this.client.CreateRewardBasedVideoAd(); + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdStarted += delegate(object sender, EventArgs args) + { + if (this.OnAdStarted != null) + { + this.OnAdStarted(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnAdLeavingApplication += delegate(object sender, EventArgs args) + { + if (this.OnAdLeavingApplication != null) + { + this.OnAdLeavingApplication(this, args); + } + }; + this.client.OnAdRewarded += delegate(object sender, Reward args) + { + if (this.OnAdRewarded != null) + { + this.OnAdRewarded(this, args); + } + }; + this.client.OnAdCompleted += delegate(object sender, EventArgs args) + { + if (this.OnAdCompleted != null) + { + this.OnAdCompleted(this, args); + } + }; + } + + public void LoadAd(AdRequest request, string adUnitId) + { + this.client.LoadAd(request, adUnitId); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.ShowRewardBasedVideoAd(); + } + + public void SetUserId(string userId) + { + this.client.SetUserId(userId); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs new file mode 100644 index 0000000..48a43ff --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs @@ -0,0 +1,97 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class RewardedAd + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToLoad; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToShow; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<Reward> OnUserEarnedReward; + + private IRewardedAdClient client; + + public RewardedAd(string adUnitId) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildRewardedAdClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IRewardedAdClient)method.Invoke(null, null); + this.client.CreateRewardedAd(adUnitId); + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdErrorEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdFailedToShow += delegate(object sender, AdErrorEventArgs args) + { + if (this.OnAdFailedToShow != null) + { + this.OnAdFailedToShow(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnUserEarnedReward += delegate(object sender, Reward args) + { + if (this.OnUserEarnedReward != null) + { + this.OnUserEarnedReward(this, args); + } + }; + } + + public void LoadAd(AdRequest request) + { + this.client.LoadAd(request); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.Show(); + } + + public void SetServerSideVerificationOptions(ServerSideVerificationOptions serverSideVerificationOptions) + { + this.client.SetServerSideVerificationOptions(serverSideVerificationOptions); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/ServerSideVerificationOptions.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/ServerSideVerificationOptions.cs new file mode 100644 index 0000000..6f0e920 --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/ServerSideVerificationOptions.cs @@ -0,0 +1,41 @@ +using System; + +namespace GoogleMobileAds.Api +{ + public class ServerSideVerificationOptions + { + public string UserId { get; private set; } + + public string CustomData { get; private set; } + + public class Builder + { + internal string UserId { get; private set; } + + internal string CustomData { get; private set; } + + public ServerSideVerificationOptions.Builder SetUserId(string userId) + { + this.UserId = userId; + return this; + } + + public ServerSideVerificationOptions.Builder SetCustomData(string customData) + { + this.CustomData = customData; + return this; + } + + public ServerSideVerificationOptions Build() + { + return new ServerSideVerificationOptions(this); + } + } + + private ServerSideVerificationOptions(ServerSideVerificationOptions.Builder builder) + { + this.UserId = builder.UserId; + this.CustomData = builder.CustomData; + } + } +} |