1using System.Collections.Generic;
3using GoogleMobileAds.Api;
19 public abstract partial class GoogleAdUnit<TAd> : AdUnit<TAd>
43 var adRequest =
new AdRequest();
51 return loadingStarted;
67 protected virtual void OnLoad(TAd ad, LoadAdError error)
70 if (error !=
null || ad ==
null)
114 var replaceLogValues =
new Dictionary<string, Func<string>>
117 {
"{time}", () =>
LoadTime?.ToString(System.Globalization.CultureInfo.CurrentCulture) },
118 {
"{loadingTimeMs}", () =>
LoadingTimeMs?.ToString(System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty },
119 {
"{loadTimeMs}", () =>
LoadingTimeMs?.ToString(System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty },
120 {
"{name}", () => name },
121 {
"{adSourceName}", () =>
ResponseInfo?.GetLoadedAdapterResponseInfo()?.AdSourceName },
122 {
"{adSourceInstanceName}", () =>
ResponseInfo?.GetLoadedAdapterResponseInfo()?.AdSourceInstanceName },
123 {
"{adapterClassName}", () =>
ResponseInfo?.GetLoadedAdapterResponseInfo()?.AdapterClassName }
125 return new SpaceAdLogger(
this, replaceLogValues,
LogOptions.Channel, !
LogOptions.SuppressAllLogs);
TAd AdObject
The ad object associated with this unit. This property allows for direct interaction with the specifi...
string SystemAdTypeName
A convenient string representation of the system ad type, used primarily for logging and debugging pu...
virtual LogOptions LogOptions
void RegisterEventHandlers()
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecy...
override bool SdkInitialized
virtual void OnAdLoadFailed(LoadAdError error)
Handles the ad load failed event, logging the error encountered during ad loading.
override void OnAdLoaded()
Handles the ad loaded event, setting the load time, preparing the ad object for display,...
void SetLoadingStartTime()
Saves the start time of an ad-loading request.
long? LoadingTimeMs
Gets the duration of the latest successful ad-loading request in milliseconds. Divide the value by 10...
override void Unload()
Unloads the ad.
bool LoadInternal(AdRequest adRequest)
Abstract method for loading an ad with a specified request configuration. This method must be impleme...
ResponseInfo GetResponseInfo()
Retrieves detailed response information for the most recent ad request, providing insights into the a...
ResponseInfo ResponseInfo
Holds essential information for advertisements.
virtual void PrepareAdObject()
Optional overridable method for setting up the AdObject. This can be used for initializing or customi...
DateTime? LoadTime
Date and time when the ad was loaded.
void ResetLoadingStartTime()
Clears the saved start time when an ad-loading request cannot be started.
override SpaceAdLogger InitLogger()
virtual void PrepareAdRequest(AdRequest adRequest)
Optional overridable method for setting up the ad request. This can be used to customize ad requests.
override bool LoadInternal()
virtual void OnLoad(TAd ad, LoadAdError error)
Called when an ad loading attempt concludes. It evaluates the result of the loading process,...
static bool Ready
Indicates whether the SDK has been initialized.