Ejemplo n.º 1
0
        public static IReadOnlyEventField <B> Watch <T, B> (this IReadOnlyEventField <T> field, Func <T, IReadOnlyEventField <B> > chain)
        {
            var watcher = new EventField <B> ();

            field.Handlers[watcher].Add(new EventFieldChainHandler <T, B> (field, watcher, chain));
            return(watcher);
        }
Ejemplo n.º 2
0
        public EventFieldChainHandler(IReadOnlyEventField <T> source, IEventField <B> target, Func <T, IReadOnlyEventField <B> > chain)
        {
            SourceField = source;
            TargetField = target;
            Chain       = chain;

            ChainedField = Chain(SourceField.Value);
        }
Ejemplo n.º 3
0
        public void OnAfterChanged()
        {
            ChainedField = Chain(SourceField.Value);
            if (ChainedField == null)
            {
                TargetField.Value = default(B);
                return;
            }

            ChainedField.Handlers[this].Add(new EventFieldMirrorHandler <B> (ChainedField, TargetField));
            TargetField.Value = ChainedField.Value;
        }
Ejemplo n.º 4
0
        void IHandlerUsedCallback.OnUse(IReadOnlyEventField field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field), $"{nameof(field)} is null");
            }
            if (eventField != null)
            {
                throw new InvalidOperationException($"Event handler of type {GetType()} cannot be used on multiple EventFields.");
            }

            if (field is IReadOnlyEventField <TValue> castedField)
            {
                eventField = castedField;
            }
            else
            {
                throw new InvalidOperationException($"Event handler for type {typeof(TValue)} cannot be used on event field of type {field.GetType()}.");
            }
        }
Ejemplo n.º 5
0
 public void StartMirroring(IReadOnlyEventField <T> target)
 {
     Connection.StartMirroring(target);
 }
Ejemplo n.º 6
0
 public AddToListEventHandler(IReadOnlyEventField <T> source, List <T> target)
 {
     this.source = source;
     this.target = target;
 }
Ejemplo n.º 7
0
 public EventFieldMirrorHandler(IReadOnlyEventField <T> source, IEventField <T> target)
 {
     SourceField = source;
     Target      = target;
 }
Ejemplo n.º 8
0
 public StatModifier(StatModificationPhase phase, StatModificationType type, IReadOnlyEventField <float> currentValue)
 {
     Phase        = phase;
     Type         = type;
     CurrentValue = currentValue ?? throw new ArgumentNullException(nameof(currentValue));
 }
Ejemplo n.º 9
0
 public ContextWrapped(IReadOnlyEventField field, object context)
 {
     this.field   = field;
     this.context = context;
 }