Пример #1
0
        /// <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);
        }
Пример #2
0
 /// <summary>
 /// Pathes this instance.
 /// </summary>
 /// <returns>System.String.</returns>
 public string path()
 {
     return(Firebase.exec(this, "toString", null));
 }
Пример #3
0
 /// <summary>
 /// Removes this instance.
 /// </summary>
 /// <returns>System.String.</returns>
 public string remove()
 {
     return(Firebase.remove(this.path()));
 }
Пример #4
0
 /// <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));
 }
Пример #5
0
 /// <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));
 }
Пример #6
0
 /// <summary>
 /// Sets the specified object.
 /// </summary>
 /// <param name="Object">The object.</param>
 public void set(string Object)
 {
     Firebase.set(this.path(), Object);
 }