forked from xamarin/xamarin-macios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tj_devel709
committed
Oct 16, 2023
1 parent
c661ef5
commit 2de0968
Showing
14 changed files
with
319 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#nullable enable | ||
|
||
#if IOS && !__MACCATALYST__ | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.CompilerServices; | ||
using ObjCRuntime; | ||
using Foundation; | ||
using PassKit; | ||
|
||
#if !NET | ||
using NativeHandle = System.IntPtr; | ||
#endif | ||
|
||
namespace PassKit { | ||
|
||
public partial class PKPayLaterView { | ||
|
||
#if !NET | ||
delegate void PKPayLaterValidateAmountCompletionHandler (IntPtr block, byte eligible); | ||
static PKPayLaterValidateAmountCompletionHandler static_ValidateAmount = TrampolineValidateAmount; | ||
|
||
[MonoPInvokeCallback (typeof (PKPayLaterValidateAmountCompletionHandler))] | ||
#else | ||
[UnmanagedCallersOnly] | ||
#endif | ||
static void TrampolineValidateAmount (IntPtr block, byte eligible) | ||
{ | ||
var del = BlockLiteral.GetTarget<Action<bool>> (block); | ||
if (del is not null) { | ||
del (eligible != 0); | ||
} | ||
} | ||
|
||
#if NET | ||
[SupportedOSPlatform ("ios17.0")] | ||
[UnsupportedOSPlatform ("maccatalyst")] | ||
[UnsupportedOSPlatform ("macos")] | ||
[UnsupportedOSPlatform ("tvos")] | ||
#endif | ||
[BindingImpl (BindingImplOptions.Optimizable)] | ||
public void ValidateAmount (NSDecimalNumber amount, string currencyCode, Action<bool> callback) | ||
{ | ||
if (callback is null) | ||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (callback)); | ||
|
||
unsafe { | ||
#if NET | ||
delegate* unmanaged<IntPtr, byte, void> trampoline = &TrampolineValidateAmount; | ||
using var block = new BlockLiteral (trampoline, callback, typeof (PKPayLaterView), nameof (TrampolineValidateAmount)); | ||
#else | ||
using var block = new BlockLiteral (); | ||
block.SetupBlockUnsafe (static_ValidateAmount, callback); | ||
#endif | ||
using var nsCurrencyCode = new NSString (currencyCode); | ||
PKPayLaterValidateAmount (amount.Handle, nsCurrencyCode.Handle, &block); | ||
} | ||
} | ||
|
||
[DllImport (Constants.PassKitLibrary)] | ||
unsafe static extern void PKPayLaterValidateAmount (IntPtr /* NSDecimalNumber */ amount, IntPtr /* NSString */ currencyCode, BlockLiteral* callback); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.