Example #1
0
 /// <inheritdoc/>
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (TypeUtilities.CanCast <TIn>(value))
     {
         return(_convert((TIn)value));
     }
     else
     {
         return(AvaloniaProperty.UnsetValue);
     }
 }
 /// <summary>
 /// Casts a strongly typed match function to a weakly typed one.
 /// </summary>
 /// <param name="f">The strongly typed function.</param>
 /// <returns>The weakly typed function.</returns>
 private static Func <object?, bool> CastMatch(Func <T, bool> f)
 {
     return(o => TypeUtilities.CanCast <T>(o) && f((T)o !));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FuncDataTemplate{T}"/> class.
 /// </summary>
 /// <param name="build">
 /// A function which when passed an object of <typeparamref name="T"/> returns a control.
 /// </param>
 /// <param name="supportsRecycling">Whether the control can be recycled.</param>
 public FuncDataTemplate(Func <T, INameScope, IControl?> build, bool supportsRecycling = false)
     : base(o => TypeUtilities.CanCast <T>(o), CastBuild(build), supportsRecycling)
 {
 }