where E2 : AtomEvent
where F : AtomFunction
{
///
/// Override to add implementation specific setup on `OnEnable`.
///
protected override void ImplSpecificSetup()
{
if (Base.Changed != null)
{
_inMemoryCopy.Changed = Instantiate(Base.Changed);
}
if (Base.ChangedWithHistory != null)
{
_inMemoryCopy.ChangedWithHistory = Instantiate(Base.ChangedWithHistory);
}
}
///
/// Get event by type.
///
///
/// The event.
public E GetEvent() where E : AtomEventBase
{
if (typeof(E) == typeof(E1))
return (_inMemoryCopy.Changed as E);
if (typeof(E) == typeof(E2))
return (_inMemoryCopy.ChangedWithHistory as E);
throw new Exception($"Event type {typeof(E)} not supported! Use {typeof(E1)} or {typeof(E2)}.");
}
///
/// Set event by type.
///
/// The new event value.
///
public void SetEvent(E e) where E : AtomEventBase
{
if (typeof(E) == typeof(E1))
{
_inMemoryCopy.Changed = (e as E1);
return;
}
if (typeof(E) == typeof(E2))
{
_inMemoryCopy.ChangedWithHistory = (e as E2);
return;
}
throw new Exception($"Event type {typeof(E)} not supported! Use {typeof(E1)} or {typeof(E2)}.");
}
}
}