public static void DebugException(this IMvxLog logger, string message, Exception exception, params object[] formatParams) { if (logger.IsDebugEnabled()) { logger.Log(MvxLogLevel.Debug, message.AsFunc(), exception, formatParams); } }
public static void Debug(this IMvxLog logger, string message) { if (logger.IsDebugEnabled()) { logger.Log(MvxLogLevel.Debug, message.AsFunc()); } }
public static void DebugException(this IMvxLog logger, string message, Exception exception) { if (logger.IsDebugEnabled()) { logger.Log(MvxLogLevel.Debug, message.AsFunc(), exception); } }
public static void Warn(this IMvxLog logger, string message) { if (logger.IsWarnEnabled()) { logger.Log(MvxLogLevel.Warn, message.AsFunc()); } }
public static void Info(this IMvxLog logger, string message) { if (logger.IsInfoEnabled()) { logger.Log(MvxLogLevel.Info, message.AsFunc()); } }
public static void Trace(this IMvxLog logger, string message) { if (logger.IsTraceEnabled()) { logger.Log(MvxLogLevel.Trace, message.AsFunc()); } }
public static void Error(this IMvxLog logger, string message) { if (logger.IsErrorEnabled()) { logger.Log(MvxLogLevel.Error, message.AsFunc()); } }
public static void Fatal(this IMvxLog logger, string message) { if (logger.IsFatalEnabled()) { logger.Log(MvxLogLevel.Fatal, message.AsFunc()); } }
public async Task <bool> PurchaseAsync(Rate rate) { try { var productId = rate.Id.ToString(); var connected = await CrossInAppBilling.Current.ConnectAsync(); if (!connected) { // Не удалось подключиться к биллингу, устройство в автономном режиме, оповещаем пользователя return(false); } // Пробуем купить товар var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.InAppPurchase, "apppayload"); if (purchase == null) { // Купить не удалось, оповещаем пользователя return(false); } else { // Покупка совершена, сохраняем информацию var id = purchase.Id; var token = purchase.PurchaseToken; var state = purchase.State; // Вызываем после успешной покупки или позднее (необходимо вызвать ConnectAsync() раньше времени): if (Device.RuntimePlatform == Device.Android) { var consumedItem = await CrossInAppBilling.Current.ConsumePurchaseAsync(purchase.ProductId, purchase.PurchaseToken); if (consumedItem != null) { // Товар использован } } else { // } } } catch (Exception ex) { // Произошла ошибка, оповещаем пользователя. _logger.Log(MvxLogLevel.Debug, () => "Purchase Error", ex); return(false); } finally { // Отключаемся, это нормально если не удалось связаться. await CrossInAppBilling.Current.DisconnectAsync(); } return(true); }
public async Task <string> GetLocationCityNameAsync() { try { var location = await geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Lowest, timeout)); var place = (await geocoding.GetPlacemarksAsync(location.Latitude, location.Longitude))?.First(); return(place.Locality); } catch (Exception ex) { logger.Log(MvxLogLevel.Warn, () => ex.Message, ex); throw new LocationException(AppResources.CanNotGetCityName, ex); } }
public async Task <CurrentWeatherResponse> GetWeatherAsync(string cityName) { try { return(await apiClient.GetWeatherByCityNameAsync(cityName)); } catch (Exception ex) when(ex is AggregateException || ex is ArgumentException || ex is OpenWeatherMapException) { throw new WeatherException(AppResources.CityNameIsIncorrect, ex); } catch (Exception ex) { logger.Log(MvxLogLevel.Error, () => ex.Message, ex); throw new WeatherException(AppResources.SomethingIsWrong, ex); } }
public static void Error(this IMvxLog logger, Func <string> messageFunc) { GuardAgainstNullLogger(logger); logger.Log(MvxLogLevel.Error, messageFunc); }
private static void LogFormat(this IMvxLog logger, MvxLogLevel logLevel, string message, params object[] args) { logger.Log(logLevel, message.AsFunc(), null, args); }
public static void Fatal(this IMvxLog logger, Func <string> messageFunc) { logger.Log(MvxLogLevel.Fatal, messageFunc); }
public static bool IsDebugEnabled(this IMvxLog logger) { GuardAgainstNullLogger(logger); return(logger.Log(MvxLogLevel.Debug, null)); }