private 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); Type googleMobileAdsClientFactory = Type.GetType( "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp"); MethodInfo method = googleMobileAdsClientFactory.GetMethod( "BuildAdLoaderClient", BindingFlags.Static | BindingFlags.Public); this.adLoaderClient = (IAdLoaderClient)method.Invoke(null, new object[] { this }); GoogleMobileAds.Common.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); } }; }
private 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); this.adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(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); } }; }
private 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); this.adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(this); this.adLoaderClient.OnCustomNativeTemplateAdLoaded += (sender, args) => { if (this.OnCustomNativeTemplateAdLoaded != null) { this.OnCustomNativeTemplateAdLoaded(this, args); } }; this.adLoaderClient.OnAdFailedToLoad += (sender, args) => { if (this.OnAdFailedToLoad != null) { this.OnAdFailedToLoad(this, args); } }; }
private 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); Dictionary <string, bool> templateIdsDictionary = new Dictionary <string, bool>(); foreach (string templateId in TemplateIds) { templateIdsDictionary[templateId] = false; } foreach (var keyValuePair in this.CustomNativeTemplateClickHandlers) { templateIdsDictionary[keyValuePair.Key] = true; } AdLoaderClientArgs clientArgs = new AdLoaderClientArgs() { AdUnitId = this.AdUnitId, AdTypes = this.AdTypes, TemplateIds = templateIdsDictionary, }; this.adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(clientArgs); Utils.CheckInitialization(); this.adLoaderClient.OnCustomNativeTemplateAdLoaded += delegate(object sender, CustomNativeClientEventArgs args) { CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd(args.nativeAdClient); CustomNativeEventArgs adEventArgs = new CustomNativeEventArgs() { nativeAd = nativeAd }; this.OnCustomNativeTemplateAdLoaded(this, adEventArgs); }; this.adLoaderClient.OnCustomNativeTemplateAdClicked += delegate(object sender, CustomNativeClientEventArgs args) { CustomNativeTemplateAd nativeAd = new CustomNativeTemplateAd(args.nativeAdClient); if (this.CustomNativeTemplateClickHandlers.ContainsKey(nativeAd.GetCustomTemplateId())) { this.CustomNativeTemplateClickHandlers[nativeAd.GetCustomTemplateId()](nativeAd, args.assetName); } }; this.adLoaderClient.OnAdFailedToLoad += delegate( object sender, AdFailedToLoadEventArgs args) { if (this.OnAdFailedToLoad != null) { this.OnAdFailedToLoad(this, args); } }; }
private AdLoader(Builder builder) { AdUnitId = String.Copy(builder.AdUnitId); CustomNativeTemplateClickHandlers = new Dictionary<string, Action<CustomNativeTemplateAd, string>>(builder.CustomNativeTemplateClickHandlers); TemplateIds = new HashSet<string>(builder.TemplateIds); AdTypes = new HashSet<NativeAdType>(builder.AdTypes); adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(this); adLoaderClient.onCustomNativeTemplateAdLoaded += delegate(object sender, CustomNativeEventArgs args) { onCustomNativeTemplateAdLoaded(this, args); }; adLoaderClient.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) { OnAdFailedToLoad(this, args); }; }
private AdLoader(Builder builder) { AdUnitId = String.Copy(builder.AdUnitId); CustomNativeTemplateClickHandlers = new Dictionary <string, Action <CustomNativeTemplateAd, string> >(builder.CustomNativeTemplateClickHandlers); TemplateIds = new HashSet <string>(builder.TemplateIds); AdTypes = new HashSet <NativeAdType>(builder.AdTypes); adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(this); adLoaderClient.onCustomNativeTemplateAdLoaded += delegate(object sender, CustomNativeEventArgs args) { onCustomNativeTemplateAdLoaded(this, args); }; adLoaderClient.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args) { OnAdFailedToLoad(this, args); }; }