/// <summary> /// Compiles this instance. /// </summary> private void compile() { //reset code code = "var " + this.name + "_sender='" + this.name + "';\n"; // listener and event string onValue = " " + this.name + @".on('value', function(snap) { if((typeof snap.val())=='object') { window.external.onValue(JSON.stringify(snap.val())," + this.name + @"_sender); } else { window.external.onValue(snap.val()," + this.name + @"_sender); } });"; // listener and event string onChildAdded = " " + this.name + @".on('child_added', function(snap) { if((typeof snap.val())=='object') { window.external.onChildAdded(JSON.stringify(snap.val())," + this.name + @"_sender); } else { window.external.onChildAdded(snap.val()," + this.name + @"_sender); } });"; // listener and event string onChildChanged = " " + this.name + @".on('child_changed', function(snap) { if((typeof snap.val())=='object') { window.external.onChildChanged(JSON.stringify(snap.val())," + this.name + @"_sender); } else { window.external.onChildChanged(snap.val()," + this.name + @"_sender); } });"; // listener and event string onChildRemoved = " " + this.name + @".on('child_removed', function(snap) { if((typeof snap.val())=='object') { window.external.onChildRemoved(JSON.stringify(snap.val())," + this.name + @"_sender); } else { window.external.onChildRemoved(snap.val()," + this.name + @"_sender); } });"; //push event string toSringFunc = "function " + this.name + @"_toString(){ return " + this.name + @".toString().substring(firebase.database().ref().toString().length-1) }"; if (parents.Count == 0) { code += this.ToString() + "\n"; } for (int i = 0; i < parents.Count; i++) { code += parents[i].ToString() + "\n"; } if (parents.Count > 0) { code += this.ToString() + "\n"; } //events code += onValue + "\n" + onChildAdded + "\n" + onChildChanged + "\n" + onChildRemoved + "\n"; code += toSringFunc + "\n"; //update Firebase.AddChild(this); }
/// <summary> /// Pathes this instance. /// </summary> /// <returns>System.String.</returns> public string path() { return(Firebase.exec(this, "toString", null)); }
/// <summary> /// Removes this instance. /// </summary> /// <returns>System.String.</returns> public string remove() { return(Firebase.remove(this.path())); }
/// <summary> /// Updates the specified object. /// </summary> /// <param name="Object">The object.</param> /// <returns>System.String.</returns> public string update(string Object) { return(Firebase.update(this.path(), Object)); }
/// <summary> /// Pushes the specified object. /// </summary> /// <param name="Object">The object.</param> /// <returns>System.String.</returns> public string push(string Object) { return(Firebase.push(this.path(), Object)); }
/// <summary> /// Sets the specified object. /// </summary> /// <param name="Object">The object.</param> public void set(string Object) { Firebase.set(this.path(), Object); }