2016-03-22 23:02:25 +03:00
|
|
|
using System;
|
|
|
|
using System.ComponentModel;
|
2017-03-07 22:56:24 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
namespace Xamarin.Forms
|
|
|
|
{
|
|
|
|
public abstract class Effect
|
|
|
|
{
|
|
|
|
internal Effect()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Element Element { get; internal set; }
|
|
|
|
|
|
|
|
public bool IsAttached { get; private set; }
|
|
|
|
|
|
|
|
public string ResolveId { get; internal set; }
|
|
|
|
|
|
|
|
#region Statics
|
|
|
|
|
|
|
|
public static Effect Resolve(string name)
|
|
|
|
{
|
|
|
|
Effect result = null;
|
2018-02-26 14:48:15 +03:00
|
|
|
if (Internals.Registrar.Effects.TryGetValue(name, out Type effectType))
|
2016-03-22 23:02:25 +03:00
|
|
|
{
|
2018-02-26 14:48:15 +03:00
|
|
|
result = (Effect)DependencyResolver.ResolveOrCreate(effectType);
|
2016-03-22 23:02:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
result = new NullEffect();
|
|
|
|
result.ResolveId = name;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
// Received after Control/Container/Element made valid
|
|
|
|
protected abstract void OnAttached();
|
|
|
|
|
|
|
|
// Received after Control/Container made invalid
|
|
|
|
protected abstract void OnDetached();
|
|
|
|
|
|
|
|
internal virtual void ClearEffect()
|
|
|
|
{
|
|
|
|
if (IsAttached)
|
|
|
|
SendDetached();
|
|
|
|
Element = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal virtual void SendAttached()
|
|
|
|
{
|
|
|
|
if (IsAttached)
|
|
|
|
return;
|
|
|
|
OnAttached();
|
|
|
|
IsAttached = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal virtual void SendDetached()
|
|
|
|
{
|
|
|
|
if (!IsAttached)
|
|
|
|
return;
|
|
|
|
OnDetached();
|
|
|
|
IsAttached = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal virtual void SendOnElementPropertyChanged(PropertyChangedEventArgs args)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|