summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/ExportRendererAttribute.cs
blob: 50bba17f3161050958810efa557dd6a23bc5ee36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using UIKit;

namespace Xamarin.Forms
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	public sealed class ExportRendererAttribute : HandlerAttribute
	{
		public ExportRendererAttribute(Type handler, Type target, UIUserInterfaceIdiom idiom) : base(handler, target)
		{
			Idiomatic = true;
			Idiom = idiom;
		}

		public ExportRendererAttribute(Type handler, Type target) : base(handler, target)
		{
			Idiomatic = false;
		}

		internal UIUserInterfaceIdiom Idiom { get; }

		internal bool Idiomatic { get; }

		public override bool ShouldRegister()
		{
			return !Idiomatic || Idiom == UIDevice.CurrentDevice.UserInterfaceIdiom;
		}
	}
}