public FirebaseMessage(WriteBehavior behavior, FirebasePath path, string value, FirebasePriority priority, FirebaseStatusCallback callback, MessageSouce source) { Behavior = behavior; Path = path; Value = value; Callback = callback; Priority = priority; Source = source; }
internal DataSnapshot SnapFor(FirebasePath path) { lock (_lock) { JToken token; if (TryGetChild(path, out token)) { return new DataSnapshot(_app, path, token); } return new DataSnapshot(_app, null, null); } }
public Guid Subscribe(FirebasePath path, string eventName, SnapshotCallback callback, object context, bool once, IEnumerable<ISubscriptionFilter> filters) { var sub = new Subscription(_app, filters) { Event = eventName, Callback = callback, Context = context, Once = once, Path = path, }; if (!once) { lock (_lock) { _subscriptions.Add(sub); } } _syncDb.ExecuteInitial(sub); return sub.SubscriptionId; }
internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback) { Set(path.Child(".priority"), priority.JsonValue, callback); }
private bool DeleteFromTarget(FirebasePath targetPath, JToken newData, string path) { if (newData[path].Type == JTokenType.Null) { Delete(targetPath.Child(path)); return true; } return false; }
private void InsertAt(FirebasePath path, JToken newData) { // if there is aleady a node at the path, delete it Delete(path); string[] segments = path.Segments.ToArray(); if (segments.Length > 0) { JToken node = _root; for (int i = 0; i < segments.Length - 1; i++) { string segment = segments[i]; var child = node[segment]; if (child == null) { node[segment] = new JObject(); node = node[segment]; } else { node = child; } } string newPath = segments[segments.Length - 1]; JObject newObj = node as JObject; if (newObj == null) { throw new Exception("Node object must be a JSON object type - illegal type: " + newData.Type); } if (newData is JProperty) { newObj.Add(newData); } else { newObj[newPath] = newData; } } else { JObject newObj = newData as JObject; if (newObj == null) { throw new Exception("Root object must be a JSON object type - illegal type: " + newData.Type); } _root = newObj; } }
public void Update(FirebasePath path, string data, FirebaseStatusCallback callback) { var message = new FirebaseMessage(WriteBehavior.Merge, path, data, callback, MessageSouce.Local); UpdateLocal(message); }
public string Push(FirebasePath path, object data, FirebaseStatusCallback callback) { string json = null; if (data != null) { json = JToken.FromObject(data).ToString(); } return Push(path, json, callback); }
public void Set(FirebasePath path, string data, FirebaseStatusCallback callback) { Set(path, data, null, callback, MessageSouce.Local); }
private Uri GetUri(FirebasePath path) { string uri = _root.AbsoluteUri + path.Path + ".json"; if (!string.IsNullOrEmpty(_authToken)) { uri += string.Format("?auth={0}", _authToken); } return new Uri(uri, UriKind.Absolute); }
private void Fire(FirebasePath path, JToken state) { SnapshotCallback callback; lock (_lock) { callback = Callback; if (callback == null) { return; } if (Once) { Callback = null; } } _app.Fire(callback, new DataSnapshot(_app, path, state), Context); }
public FirebaseMessage(WriteBehavior behavior, FirebasePath path, string value, FirebaseStatusCallback callback, MessageSouce source) : this(behavior, path, value, null, callback, source) { }
public FirebaseQuery(FirebaseApp app, FirebasePath path) { _app = app; _path = path; _filters = new List <ISubscriptionFilter>(); }
public FirebaseMessage(WriteBehavior behavior, FirebasePath path, string value, FirebaseStatusCallback callback, MessageSouce source) : this(behavior, path, value, null, callback, source) { }
public JsonCacheUpdateEventArgs(FirebasePath path) { Path = path; }
internal Firebase(FirebaseApp app, FirebasePath path) { _app = app; _path = path; }
public void Set(FirebasePath path, object data, FirebaseStatusCallback callback) { string strData = JToken.FromObject(data).ToString(Formatting.None); Set(path, strData, callback); }
internal string Push(FirebasePath path, object value, FirebaseStatusCallback callback) { return _cache.Push(path, value, callback); }
private void Set(FirebasePath path, string data, FirebasePriority priority, FirebaseStatusCallback callback, MessageSouce source) { var message = new FirebaseMessage(WriteBehavior.Replace, path, data, priority, callback, source); UpdateLocal(message); }
internal Guid Subscribe(string eventName, FirebasePath path, SnapshotCallback callback, object context, IEnumerable<ISubscriptionFilter> filters) { return _subscriptions.Subscribe(path, eventName, callback, context, false, filters); }
public string Push(FirebasePath path, string data, FirebaseStatusCallback callback) { string childPath = _idGenerator.Next(); if (data != null) { Set(path.Child(childPath), data, callback); } return childPath; }
internal Guid SubscribeOnce(string eventName, FirebasePath path, SnapshotCallback callback, object context, IEnumerable<ISubscriptionFilter> filters, FirebaseStatusCallback cancelledCallback) { return _subscriptions.Subscribe(path, eventName, callback, context, true, filters); }
private void Delete(FirebasePath path) { lock (_lock) { JToken node; if (TryGetChild(path, out node)) { if (node.Parent != null) { node.Parent.Remove(); } else { _root = new JObject(); } } } }
internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback) { _cache.SetPriority(path, priority, callback); }
private void Merge(FirebasePath root, JToken newData) { JToken found; if (TryGetChild(root, out found)) { if (!UpdateValues(found, newData)) { foreach (var newChild in newData.Children()) { if (DeleteFromTarget(root, newData, newChild.Path)) { continue; } InsertAt(root.Child(newChild.Path), newChild); } } } else { InsertAt(root, newData); } }
internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority, FirebaseStatusCallback callback) { _cache.SetWithPriority(path, value, priority, callback); }
private bool TryGetChild(FirebasePath path, out JToken node) { node = _root; if (node != null) { foreach (var segment in path.Segments) { if (!node.Children().Any()) { return false; } node = node[segment]; if (node == null) { return false; } } return true; } return false; }
internal Firebase Child(FirebasePath path) { return new Firebase(this, path); }
internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority, FirebaseStatusCallback callback) { Set(path, value, priority, callback, MessageSouce.Local); }
internal void Set(FirebasePath path, object value, FirebaseStatusCallback callback) { _cache.Set(path, value, callback); }
public FirebaseQuery(FirebaseApp app, FirebasePath path) { _app = app; _path = path; _filters = new List<ISubscriptionFilter>(); }
internal void Update(FirebasePath path, string value, FirebaseStatusCallback callback) { _cache.Update(path, value, callback); }