37 строки
871 B
C#
37 строки
871 B
C#
using Xamarin.Forms;
|
|
using Xamarin.Forms.ControlGallery.Android;
|
|
using Xamarin.Forms.Controls;
|
|
|
|
[assembly: Dependency(typeof(RegistrarValidationService))]
|
|
namespace Xamarin.Forms.ControlGallery.Android
|
|
{
|
|
public class RegistrarValidationService : IRegistrarValidationService
|
|
{
|
|
readonly global::Android.Content.Context _context;
|
|
|
|
public RegistrarValidationService()
|
|
{
|
|
_context = MainApplication.ActivityContext;
|
|
}
|
|
|
|
public bool Validate(VisualElement element, out string message)
|
|
{
|
|
message = "Success";
|
|
|
|
if (element == null)
|
|
return true;
|
|
|
|
var renderer = Platform.Android.Platform.CreateRendererWithContext(element, _context);
|
|
|
|
if (renderer == null
|
|
|| renderer.GetType().Name == "DefaultRenderer"
|
|
)
|
|
{
|
|
message = $"Failed to load Android renderer for {element.GetType().Name}";
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} |