Click here to Skip to main content
15,885,875 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w2-Jun-20 9:40
arnold_w2-Jun-20 9:40 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w2-Jun-20 22:59
arnold_w2-Jun-20 22:59 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 2:39
arnold_w3-Jun-20 2:39 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
Gerry Schmitz3-Jun-20 6:40
mveGerry Schmitz3-Jun-20 6:40 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 9:30
arnold_w3-Jun-20 9:30 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
kalberts3-Jun-20 10:10
kalberts3-Jun-20 10:10 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 10:34
arnold_w3-Jun-20 10:34 
QuestionConverting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 3:52
Exoskeletor2-Jun-20 3:52 
Hello Guys,
I have create a Android application in Xamarin and i would like to also have in on Amazon store.
It uses in App purchases
Currently im implementing those purchases with this code:
public async Task<bool> WasItemPurchased(string productId)  
{  
var billing = CrossInAppBilling.Current;  
var result = false;  
try  
{  
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);  
  
if (!connected)  
{  
//Couldn't connect  
return false;  
}  
  
//check purchases  
var verify = new InAppBillingVerify();  
var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase, verify);  
  
//check for null just incase  
if (purchases?.Any(p => p.ProductId == productId) ?? false)  
{  
//Purchase restored  
Preferences.Set(productId, true);  
return true;  
}  
else  
{  
//no purchases found  
//Toast.MakeText(this, GetString(Resource.String.Options_RestoreUnavailable), ToastLength.Long);  
return false;  
}  
}  
catch (InAppBillingPurchaseException purchaseEx)  
{  
var message = string.Empty;  
switch (purchaseEx.PurchaseError)  
{  
case PurchaseError.AppStoreUnavailable:  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);  
break;  
case PurchaseError.BillingUnavailable:  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);  
break;  
case PurchaseError.PaymentInvalid:  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);  
break;  
case PurchaseError.PaymentNotAllowed:  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);  
break;  
case PurchaseError.AlreadyOwned:  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAlreadyOwned);  
Preferences.Set(productId, true);  
result = true;  
break;  
}  
  
//Decide if it is an error we care about  
if (string.IsNullOrWhiteSpace(message))  
return false;  
  
//Display message to user  
//Toast.MakeText(this, message, ToastLength.Long);  
}  
catch (Exception exception)  
{  
Crashes.TrackError(exception);  
//Something has gone wrong  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);  
//Toast.MakeText(this, GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable), ToastLength.Long);  
}  
finally  
{  
await billing.DisconnectAsync();  
}  
  
return result;  
}  
  
public async Task<bool> PurchaseItem(string productId, string payload)  
{  
var billing = CrossInAppBilling.Current;  
try  
{  
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);  
if (!connected)  
{  
//we are offline or can't connect, don't try to purchase  
return false;  
}  
  
//check purchases  
var verify = new InAppBillingVerify();  
var purchase = await billing.PurchaseAsync(productId, ItemType.InAppPurchase, payload, verify);  
  
//possibility that a null came through.  
if (purchase == null)  
{  
//did not purchase  
}  
else if (purchase.State == PurchaseState.Purchased)  
{  
//purchased!  
Preferences.Set(productId, true);  
}  
}  
catch (InAppBillingPurchaseException purchaseEx)  
{  
var message = string.Empty;  
switch (purchaseEx.PurchaseError)  
{  
case PurchaseError.AppStoreUnavailable:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);  
break;  
case PurchaseError.BillingUnavailable:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);  
break;  
case PurchaseError.PaymentInvalid:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);  
break;  
case PurchaseError.PaymentNotAllowed:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);  
break;  
case PurchaseError.AlreadyOwned:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorAlreadyOwned);  
Preferences.Set(productId, true);  
EnableOrDisableProFeatures();  
break;  
}  
  
//Decide if it is an error we care about  
if (string.IsNullOrWhiteSpace(message))  
return false;  
  
//Display message to user  
DisplayToast(message, ToastLength.Long);  
  
}  
catch (Exception exception)  
{  
Crashes.TrackError(exception);  
//Something else has gone wrong, log it  
//Debug("Issue connecting: " + ex);  
DisplayToast(GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable), ToastLength.Long);  
  
}  
finally  
{  
await billing.DisconnectAsync();  
}  
return false;  
}  
  
private async Task RestorePurchases()  
{  
var currentConnectivity = Connectivity.NetworkAccess;  
var restorePurchasesResults = new List<bool>();  
if (currentConnectivity == NetworkAccess.Internet)  
{  
restorePurchasesResults.Add(await WasItemPurchased(GetString(Resource.String.Options_PaidFunctions_PurchaseTemplatesAndMoreButtons)));  
restorePurchasesResults.Add(await WasItemPurchased(GetString(Resource.String.Options_PaidFunctions_PurchaseCustomResources)));  
restorePurchasesResults.Add(await WasItemPurchased(GetString(Resource.String.Options_PaidFunctions_PurchaseDisplayWebpageAfterVote)));  
if (restorePurchasesResults.Contains(true))  
{  
DisplayToast(GetString(Resource.String.Options_PaidFunctions_PurchasesRestored), ToastLength.Long);  
  
EnableOrDisableProFeatures();  
}  
else  
{  
if (string.IsNullOrEmpty(RestorePurchasesStatusMessage))  
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_PurchasesNotFound);  
DisplayToast(RestorePurchasesStatusMessage, ToastLength.Long);  
  
}  
}  
else  
{  
DisplayToast(GetString(Resource.String.Options_InternetUnavailable), ToastLength.Long);  
  
}  
}  
  
private async Task<string> GetProductPrice(string productId)  
{  
var billing = CrossInAppBilling.Current;  
try  
{  
  
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);  
  
if (!connected)  
{  
//Couldn't connect  
return string.Empty;  
}  
  
//check purchases  
var item = await billing.GetProductInfoAsync(ItemType.InAppPurchase, productId);  
  
if (item != null)  
return item.ToList()[0].LocalizedPrice;  
}  
catch (InAppBillingPurchaseException purchaseEx)  
{  
var message = string.Empty;  
switch (purchaseEx.PurchaseError)  
{  
case PurchaseError.AppStoreUnavailable:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);  
break;  
case PurchaseError.BillingUnavailable:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);  
break;  
case PurchaseError.PaymentInvalid:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);  
break;  
case PurchaseError.PaymentNotAllowed:  
message = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);  
break;  
}  
  
//Decide if it is an error we care about  
if (string.IsNullOrWhiteSpace(message))  
return string.Empty;  
  
//Display message to user  
DisplayToast(message, ToastLength.Long);  
  
}  
catch (Exception exception)  
{  
Crashes.TrackError(exception);  
//Something has gone wrong  
}  
finally  
{  
await billing.DisconnectAsync();  
}  
return string.Empty;  
}

And i have to do similar function for the Amazon store like the API details here:
https://developer.amazon.com/docs/cross-platform-plugins/cpp-use-the-iap-plugin-for-xamarin.html
However i dont even know where to start to convert those functions, Amazon API confuse me, can someone help me?
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
OriginalGriff2-Jun-20 4:38
mveOriginalGriff2-Jun-20 4:38 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 4:56
Exoskeletor2-Jun-20 4:56 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
OriginalGriff2-Jun-20 5:18
mveOriginalGriff2-Jun-20 5:18 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 7:40
Exoskeletor2-Jun-20 7:40 
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
Kris Lantz2-Jun-20 9:13
professionalKris Lantz2-Jun-20 9:13 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 9:24
Exoskeletor2-Jun-20 9:24 
QuestionState machine performance woes in .NET Pin
kalberts2-Jun-20 3:04
kalberts2-Jun-20 3:04 
AnswerRe: State machine performance woes in .NET Pin
kalberts2-Jun-20 3:41
kalberts2-Jun-20 3:41 
GeneralRe: State machine performance woes in .NET Pin
F-ES Sitecore2-Jun-20 4:08
professionalF-ES Sitecore2-Jun-20 4:08 
QuestionProblem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
Member 1467808531-May-20 6:47
Member 1467808531-May-20 6:47 
AnswerRe: Problem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
OriginalGriff31-May-20 20:34
mveOriginalGriff31-May-20 20:34 
QuestionMulti threading in C# Pin
bjwaldo28-May-20 9:21
bjwaldo28-May-20 9:21 
AnswerRe: Multi threading in C# Pin
JudyL_MD28-May-20 10:45
JudyL_MD28-May-20 10:45 
AnswerRe: Multi threading in C# Pin
F-ES Sitecore29-May-20 1:17
professionalF-ES Sitecore29-May-20 1:17 
GeneralRe: Multi threading in C# Pin
bjwaldo30-May-20 7:30
bjwaldo30-May-20 7:30 
QuestionLinq TO SQL - Pass Table Name Pin
Kevin Marois28-May-20 8:57
professionalKevin Marois28-May-20 8:57 
AnswerRe: Linq TO SQL - Pass Table Name Pin
Richard Deeming29-May-20 0:11
mveRichard Deeming29-May-20 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.