summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/Interactivity/Condition.cs
blob: aad921cfd40b5f9fddfc92893a4acc851bff5b8b (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;

namespace Xamarin.Forms
{
	public abstract class Condition
	{
		Action<BindableObject, bool, bool> _conditionChanged;

		bool _isSealed;

		internal Condition()
		{
		}

		internal Action<BindableObject, bool, bool> ConditionChanged
		{
			get { return _conditionChanged; }
			set
			{
				if (_conditionChanged == value)
					return;
				if (_conditionChanged != null)
					throw new InvalidOperationException("The same condition instance can not be reused");
				_conditionChanged = value;
			}
		}

		internal bool IsSealed
		{
			get { return _isSealed; }
			set
			{
				if (_isSealed == value)
					return;
				if (!value)
					throw new InvalidOperationException("What is sealed can not be unsealed.");
				_isSealed = value;
				OnSealed();
			}
		}

		internal abstract bool GetState(BindableObject bindable);

		internal virtual void OnSealed()
		{
		}

		internal abstract void SetUp(BindableObject bindable);
		internal abstract void TearDown(BindableObject bindable);
	}
}