maui-linux/Xamarin.Forms.ControlGaller.../RegistrarValidationService.cs

31 строка
738 B
C#

using Xamarin.Forms;
using Xamarin.Forms.ControlGallery.MacOS;
using Xamarin.Forms.Controls;
using Xamarin.Forms.Platform.MacOS;
[assembly: Dependency(typeof(RegistrarValidationService))]
namespace Xamarin.Forms.ControlGallery.MacOS
{
public class RegistrarValidationService : IRegistrarValidationService
{
public bool Validate(VisualElement element, out string message)
{
message = "Success";
if (element == null)
return true;
var renderer = Platform.MacOS.Platform.CreateRenderer(element);
if (renderer == null
|| renderer.GetType().Name == "DefaultRenderer"
)
{
message = $"Failed to load proper MacOS renderer for {element.GetType().Name}";
return false;
}
return true;
}
}
}