Beispiel #1
0
 internal EventHandle(EventManager.HandlerSetCell cell, IHandler handler, DataOrigin origin)
 {
     Cell       = cell;
     Handler    = handler;
     Origin     = origin;
     UnsubEvent = () => { };
 }
Beispiel #2
0
 /// <summary>
 /// Constructs an <see cref="EventName"/> from a <see cref="DataOrigin"/> and name.
 /// </summary>
 /// <param name="origin">The origin associated with the event.</param>
 /// <param name="name">The name of the event.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="origin"/> is null
 /// -OR- if <paramref name="name"/> is null.</exception>
 /// <exception cref="ArgumentException">Thrown if <paramref name="origin"/> is not a valid origin.</exception>
 public EventName(DataOrigin origin, string name)
 {
     if (origin is null)
     {
         throw new ArgumentNullException(nameof(origin));
     }
     if (!origin.IsValid)
     {
         throw new ArgumentException(SR.EventName_OriginNotValid, nameof(origin));
     }
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentNullException(nameof(name));
     }
     Origin = origin;
     Name   = name;
 }
Beispiel #3
0
        /// <summary>
        /// Creates a new <see cref="EventSource"/> using the <see cref="DataOrigin"/> <paramref name="origin"/>.
        /// This origin cannot be associated with any other <see cref="EventSource"/>.
        /// </summary>
        /// <param name="origin">The origin to use for this <see cref="EventSource"/>.</param>
        /// <exception cref="ArgumentException">Thrown if <paramref name="origin"/> is already associated with another <see cref="EventSource"/>.</exception>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="origin"/> is <see langword="null"/>.</exception>
        public EventSource(DataOrigin origin)
        {
            if (origin is null)
            {
                throw new ArgumentNullException(nameof(origin));
            }
            if (origin.IsValid)
            {
                throw new ArgumentException(SR.EventSource_OriginAlreadyAttached, nameof(origin));
            }

            originAssocObj = new();
            Origin         = origin;
            origin.SetSource(originAssocObj);

            if (!origin.IsValid)
            {
                throw new ArgumentException(SR.EventSource_OriginAlreadyAttached, nameof(origin));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructs a <see cref="DataWithOrigin"/> struct with the specified data and origin.
 /// </summary>
 /// <param name="origin">The origin to associate with the data.</param>
 /// <param name="data">The data to wrap.</param>
 public DataWithOrigin(DataOrigin origin, dynamic?data)
 => (Origin, Data) = (origin, (object?)data);