summaryrefslogtreecommitdiff
path: root/FireBase/Streaming/FirebaseEvent.cs
blob: 1761a728a99fe630fb927a2717ba4467a5108ee0 (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
34
35
36
37
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);
        }
    }
}