Click here to Skip to main content
15,569,774 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w2-Jun-20 10:40
arnold_w2-Jun-20 10:40 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w2-Jun-20 23:59
arnold_w2-Jun-20 23:59 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 3:39
arnold_w3-Jun-20 3:39 
AnswerRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
Gerry Schmitz3-Jun-20 7:40
mveGerry Schmitz3-Jun-20 7:40 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 10:30
arnold_w3-Jun-20 10:30 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
kalberts3-Jun-20 11:10
kalberts3-Jun-20 11:10 
GeneralRe: How can I compile code in runtime faster than CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromDom? Pin
arnold_w3-Jun-20 11:34
arnold_w3-Jun-20 11:34 
QuestionConverting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 4:52
Exoskeletor2-Jun-20 4: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 5:38
mvaOriginalGriff2-Jun-20 5:38 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 5:56
Exoskeletor2-Jun-20 5:56 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
OriginalGriff2-Jun-20 6:18
mvaOriginalGriff2-Jun-20 6:18 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 8:40
Exoskeletor2-Jun-20 8:40 
AnswerRe: Converting InAppBilling.Plugin to Amazon Pin
Kris Lantz2-Jun-20 10:13
professionalKris Lantz2-Jun-20 10:13 
GeneralRe: Converting InAppBilling.Plugin to Amazon Pin
Exoskeletor2-Jun-20 10:24
Exoskeletor2-Jun-20 10:24 
QuestionState machine performance woes in .NET Pin
kalberts2-Jun-20 4:04
kalberts2-Jun-20 4:04 
AnswerRe: State machine performance woes in .NET Pin
kalberts2-Jun-20 4:41
kalberts2-Jun-20 4:41 
GeneralRe: State machine performance woes in .NET Pin
F-ES Sitecore2-Jun-20 5:08
professionalF-ES Sitecore2-Jun-20 5:08 
QuestionProblem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
Member 1467808531-May-20 7:47
Member 1467808531-May-20 7:47 
AnswerRe: Problem with Currency format Column Calculation in my dGV in C# Winform Application. Pin
OriginalGriff31-May-20 21:34
mvaOriginalGriff31-May-20 21:34 
QuestionMulti threading in C# Pin
bjwaldo28-May-20 10:21
bjwaldo28-May-20 10:21 
AnswerRe: Multi threading in C# Pin
JudyL_MD28-May-20 11:45
JudyL_MD28-May-20 11:45 
AnswerRe: Multi threading in C# Pin
F-ES Sitecore29-May-20 2:17
professionalF-ES Sitecore29-May-20 2:17 
GeneralRe: Multi threading in C# Pin
bjwaldo30-May-20 8:30
bjwaldo30-May-20 8:30 
QuestionLinq TO SQL - Pass Table Name Pin
Kevin Marois28-May-20 9:57
professionalKevin Marois28-May-20 9:57 
AnswerRe: Linq TO SQL - Pass Table Name Pin
Richard Deeming29-May-20 1:11
mveRichard Deeming29-May-20 1: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.