summaryrefslogtreecommitdiff
path: root/dsa/FireBase/Streaming/FirebaseEvent.cs
blob: 2a1ec6dce6d113281507b6e3a357e8872c768363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace Firebase.Database.Streaming {
    /// <summary>
    ///     Firebase event which hold <see cref="EventType" /> and the object affected by the event.
    /// </summary>
    /// <typeparam name="T"> Type of object affected by the event. </typeparam>
    public class FirebaseEvent<T> : FirebaseObject<T> {
        /// <summary>
        ///     Initializes a new instance of the <see cref="FirebaseEvent{T}" /> class.
        /// </summary>
        /// <param name="key"> The key of the object. </param>
        /// <param name="obj"> The object. </param>
        /// <param name="eventType"> The event type. </param>
        public FirebaseEvent(string key, T obj, FirebaseEventType eventType, FirebaseEventSource eventSource)
            : base(key, obj) {
            EventType = eventType;
            EventSource = eventSource;
        }

        /// <summary>
        ///     Gets the source of the event.
        /// </summary>
        public FirebaseEventSource EventSource { get; }

        /// <summary>
        ///     Gets the event type.
        /// </summary>
        public FirebaseEventType EventType { get; }

        public static FirebaseEvent<T> Empty(FirebaseEventSource source) {
            return new FirebaseEvent<T>(string.Empty, default(T), FirebaseEventType.InsertOrUpdate, source);
        }
    }
}