Skip to content

Instantly share code, notes, and snippets.

View giuseppenovielli's full-sized avatar

Giuseppe Novielli giuseppenovielli

  • https://www.hrcoffee.us/
  • Bari, Italy
  • 13:25 (UTC +02:00)
View GitHub Profile
@mattjohnsonpint
mattjohnsonpint / LICENSE
Last active June 19, 2024 14:19
Unified global Unhandled Exception event for .NET MAUI
MIT License
Copyright (c) 2022 Matt Johnson-Pint
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@fiftyonemoon
fiftyonemoon / AndroidXI
Created July 12, 2021 14:57
File create, rename, duplicate and delete in Android11.
import android.app.PendingIntent;
import android.app.RecoverableSecurityException;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.IntentSender;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
@dansiegel
dansiegel / EnumBindingSourceExtension.cs
Created August 18, 2020 18:59
Binding Enums in Xamarin.Forms
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace AwesomeApp.Xaml
{
[ContentProperty(nameof(Type))]
public class EnumBindingSourceExtension : IMarkupExtension
{
public Type Type { get; set; }
namespace ValidationsXFSample.ViewModels
{
public class RegisterPageViewModel: INotifyPropertyChanged
{
public ValidatableObject<string> FirstName { get; set; } = new ValidatableObject<string>();
public ValidatableObject<string> LastName { get; set; } = new ValidatableObject<string>();
public ValidatableObject<DateTime> BirthDay { get; set; } = new ValidatableObject<DateTime>() { Value = DateTime.Now };
public ValidatableObject<string> PhoneNumber { get; set; } = new ValidatableObject<string>();
public ValidatablePair<string> Email { get; set; } = new ValidatablePair<string>();
public ValidatablePair<string> Password { get; set; } = new ValidatablePair<string>();
{
public class EntryLineValidationBehaviour : BehaviorBase<Entry>
{
#region StaticFields
public static readonly BindableProperty IsValidProperty = BindableProperty.Create(nameof(IsValid), typeof(bool), typeof(EntryLineValidationBehaviour), true, BindingMode.Default, null, (bindable, oldValue, newValue) => OnIsValidChanged(bindable, newValue));
#endregion
#region Properties
public bool IsValid
{
get
public class InverseBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(bool)value;
public class FirstValidationErrorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ICollection<string> errors = value as ICollection<string>;
return errors != null && errors.Count > 0 ? errors.ElementAt(0) : null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
public class RegisterPageViewModel: INotifyPropertyChanged
{
...
bool AreFieldsValid()
{
bool isFirstNameValid = FirstName.Validate();
bool isLastNameValid = LastName.Validate();
bool isBirthDayValid = BirthDay.Validate();
bool isPhoneNumberValid = PhoneNumber.Validate();
bool isEmailValid = Email.Validate();
public class RegisterPageViewModel: INotifyPropertyChanged
{
public ValidatableObject<string> FirstName { get; set; } = new ValidatableObject<string>();
public ValidatableObject<string> LastName { get; set; } = new ValidatableObject<string>();
public ValidatableObject<DateTime> BirthDay { get; set; } = new ValidatableObject<DateTime>() { Value = DateTime.Now };
public ValidatableObject<string> PhoneNumber { get; set; } = new ValidatableObject<string>();
public ValidatablePair<string> Email { get; set; } = new ValidatablePair<string>();
public ValidatablePair<string> Password { get; set; } = new ValidatablePair<string>();
public ValidatableObject<bool> TermsAndCondition { get; set; } = new ValidatableObject<bool>();
}
public class ValidatableObject<T> : IValidatable<T>
{
public event PropertyChangedEventHandler PropertyChanged;
public List<IValidationRule<T>> Validations { get; } = new List<IValidationRule<T>>();
public List<string> Errors { get; set; } = new List<string>();
public bool CleanOnChange { get; set; } = true;