private DateTime dateTimeAdapter(DateTime originalDateTime, Java.Lang.Integer hour, Java.Lang.Integer minute, int offset = 0) { string dateTimeString = originalDateTime.ToString().Remove(originalDateTime.ToString().Length - 8); minute = new Java.Lang.Integer(minute.IntValue() + offset); string timeString = hour.ToString() + ":" + minute.ToString() + ":00"; return(Convert.ToDateTime(dateTimeString + timeString)); }
internal static Notification ToNotification(this Huawei.Hms.Push.RemoteMessage.Notification notification) { Notification result = new Notification(); PropertyInfo[] properties = typeof(Notification).GetProperties(); foreach (PropertyInfo property in properties) { PropertyInfo notificationProperty = notification.GetType().GetProperty(property.Name); if (notificationProperty != null) { if (property.PropertyType == notificationProperty.PropertyType) { property.SetValue(result, notificationProperty.GetValue(notification, null)); } else if (notificationProperty.PropertyType == typeof(Java.Lang.Integer) && property.PropertyType == typeof(int?))//Java.Lang.Integer to int? { object valueToSet = notificationProperty.GetValue(notification, null); Java.Lang.Integer javaInt = valueToSet as Java.Lang.Integer; if (javaInt != null) { property.SetValue(result, javaInt.IntValue()); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else if (notificationProperty.PropertyType == typeof(Java.Lang.Long) && property.PropertyType == typeof(long?))//Java.Lang.Long to long? { object valueToSet = notificationProperty.GetValue(notification, null); Java.Lang.Long javaLong = valueToSet as Java.Lang.Long; if (javaLong != null) { property.SetValue(result, javaLong.IntValue()); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else if (notificationProperty.PropertyType == typeof(Android.Net.Uri) && property.PropertyType == typeof(System.Uri))//Android.Net to System.Uri { object valueToSet = notificationProperty.GetValue(notification, null); Android.Net.Uri androidUri = valueToSet as Android.Net.Uri; if (androidUri != null) { property.SetValue(result, new System.Uri(androidUri.ToString())); } else { Log.Error("ToNotification", $"({property.PropertyType.FullName}){property.Name} is null"); } } else { Log.Error("ToNotification", $"[{property.Name}]{property.PropertyType} is not equal to {notificationProperty.PropertyType}"); } } else { Log.Error("ToNotification", $"{property.Name} is null"); } } return(result); }
public static int intValue(this Java.Lang.Integer integer) { return(integer.IntValue()); }