maui-linux/Xamarin.Forms.Core/Effect.cs

70 строки
1.3 KiB
C#
Исходник Обычный вид История

2016-03-22 23:02:25 +03:00
using System;
using System.ComponentModel;
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;
if (Internals.Registrar.Effects.TryGetValue(name, out Type effectType))
2016-03-22 23:02:25 +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)
{
}
}
}