示例#1
0
 protected virtual async ValueTask <bool> OnButtonClicked(GooglePayButton button)
 {
     if (ButtonClicked?.GetInvocationList() != null)
     {
         foreach (var handler in ButtonClicked?.GetInvocationList() !)
         {
             var isHandled = (bool)handler.DynamicInvoke(this, button);
             if (isHandled)
             {
                 return(isHandled);
             }
         }
     }
     return(false);
 }
示例#2
0
        public async ValueTask <GooglePayButton> CreateButtonAsync(GoogleButtonType type,
                                                                   GooglePayButtonColor?color = null)
        {
            var button   = new GooglePayButton(_jsRuntime, type, color);
            var callback = CallBackInteropWrapper.Create(async() =>
            {
                var isHandled = await OnButtonClicked(button);
                if (!isHandled)
                {
                    await button.OnClicked();
                }
            },
                                                         serializationSpec: false);

            button.JsObjectRef = await _jsRuntime.InvokeAsync <JsRuntimeObjectRef>(
                "blazorGooglePay.createButton",
                _jsObjectRef,
                callback,
                type,
                color);

            return(button);
        }