private static void AdLoaderDidReceiveNativeCustomTemplateAdCallback(

            IntPtr adLoader, IntPtr nativeCustomTemplateAd, string templateID)

        {
            AdLoaderClient client = IntPtrToAdLoaderClient(adLoader);

            Action <CustomNativeTemplateAd, string> clickHandler =

                client.customNativeTemplateCallbacks.ContainsKey(templateID) ?

                client.customNativeTemplateCallbacks[templateID] : null;

            if (client.OnCustomNativeTemplateAdLoaded != null)

            {
                CustomNativeEventArgs args = new CustomNativeEventArgs()

                {
                    nativeAd = new CustomNativeTemplateAd(new CustomNativeTemplateClient(

                                                              nativeCustomTemplateAd, clickHandler))
                };

                client.OnCustomNativeTemplateAdLoaded(client, args);
            }
        }
Beispiel #2
0
        private static void AdLoaderDidReceiveNativeCustomTemplateAdCallback(
            IntPtr adLoader, IntPtr nativeCustomTemplateAd, string templateID)
        {
            AdLoaderClient             client   = IntPtrToAdLoaderClient(adLoader);
            CustomNativeTemplateClient adClient = new CustomNativeTemplateClient(
                nativeCustomTemplateAd);

            if (client.OnCustomNativeTemplateAdClicked != null &&
                client.TemplateIds[templateID] == true)
            {
                WeakReference weakClient = new WeakReference(adClient);
                adClient.clickHandler = delegate(string assetName)
                {
                    if (weakClient.IsAlive)
                    {
                        CustomNativeTemplateClient  strongClient = weakClient.Target as CustomNativeTemplateClient;
                        CustomNativeClientEventArgs args         = new CustomNativeClientEventArgs()
                        {
                            nativeAdClient = strongClient,
                            assetName      = assetName
                        };
                        client.OnCustomNativeTemplateAdClicked(client, args);
                    }
                };
            }

            if (client.OnCustomNativeTemplateAdLoaded != null)
            {
                CustomNativeClientEventArgs args = new CustomNativeClientEventArgs()
                {
                    nativeAdClient = adClient,
                    assetName      = null
                };
                client.OnCustomNativeTemplateAdLoaded(client, args);
            }
        }