Exemple #1
0
        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);
        }
        /*
         * Children with no priority (the default) come first.
         * Children with a number as their priority come next.
         *  They are sorted numerically by priority, small to large.
         * Children with a string as their priority come last.
         *  They are sorted lexicographically by priority.
         * Whenever two children have the same priority (including no priority),
         *  they are sorted by key. Numeric keys come first (sorted numerically),
         *  followed by the remaining keys (sorted lexicographically).
         */

        public int CompareTo(FirebasePriority other)
        {
            // Children with no priority (the default) come first.
            if (Type == PriorityType.None)
            {
                if (other.Type == PriorityType.None)
                {
                    return(0);
                }

                return(-1);
            }
            else if (other.Type == PriorityType.None)
            {
                return(1);
            }

            // Children with a number as their priority come next.
            if (Type == PriorityType.Numeric)
            {
                if (other.Type == PriorityType.Numeric)
                {
                    if (_fp.HasValue && other._fp.HasValue)
                    {
                        return(_fp.Value.CompareTo(other._fp.Value));
                    }

                    throw new Exception("Priority is a numeric but value not set");
                }

                return(-1);
            }
            else if (other.Type == PriorityType.Numeric)
            {
                return(1);
            }

            // Children with a string as their priority come last.
            if (Type == PriorityType.String)
            {
                if (other.Type == PriorityType.String)
                {
                    if (_sp != null && other._sp != null)
                    {
                        return(String.Compare(_sp, other._sp, StringComparison.Ordinal));
                    }

                    throw new Exception("Priority is a string but value not set");
                }

                // will throw in a moment in release builds
                Debug.Assert(false, "It should not be possible for both to not be strings at this point");
            }
            else if (other.Type == PriorityType.String)
            {
                return(1);
            }

            throw new Exception("Priority sorting did not detect a valid state");
        }
Exemple #3
0
 internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority,
     FirebaseStatusCallback callback)
 {
     Set(path, value, priority, callback, MessageSouce.Local);
 }
Exemple #4
0
 internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback)
 {
     Set(path.Child(".priority"), priority.JsonValue, callback);
 }
Exemple #5
0
        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);
        }
Exemple #6
0
 internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority,
     FirebaseStatusCallback callback)
 {
     _cache.SetWithPriority(path, value, priority, callback);
 }
Exemple #7
0
 internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback)
 {
     _cache.SetPriority(path, priority, callback);
 }
Exemple #8
0
 internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority,
                               FirebaseStatusCallback callback)
 {
     Set(path, value, priority, callback, MessageSouce.Local);
 }
Exemple #9
0
 internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback)
 {
     Set(path.Child(".priority"), priority.JsonValue, callback);
 }
Exemple #10
0
 internal void SetWithPriority(FirebasePath path, string value, FirebasePriority priority,
                               FirebaseStatusCallback callback)
 {
     _cache.SetWithPriority(path, value, priority, callback);
 }
Exemple #11
0
 internal void SetPriority(FirebasePath path, FirebasePriority priority, FirebaseStatusCallback callback)
 {
     _cache.SetPriority(path, priority, callback);
 }
Exemple #12
0
        /*
         * Children with no priority (the default) come first.
         * Children with a number as their priority come next. 
         *  They are sorted numerically by priority, small to large.
         * Children with a string as their priority come last. 
         *  They are sorted lexicographically by priority.
         * Whenever two children have the same priority (including no priority), 
         *  they are sorted by key. Numeric keys come first (sorted numerically), 
         *  followed by the remaining keys (sorted lexicographically).
         */

        public int CompareTo(FirebasePriority other)
        {
            // Children with no priority (the default) come first.
            if (Type == PriorityType.None)
            {
                if (other.Type == PriorityType.None)
                {
                    return 0;
                }

                return -1;
            }
            else if (other.Type == PriorityType.None)
            {
                return 1;
            }

            // Children with a number as their priority come next. 
            if (Type == PriorityType.Numeric)
            {
                if (other.Type == PriorityType.Numeric)
                {
                    if (_fp.HasValue && other._fp.HasValue)
                    {
                        return _fp.Value.CompareTo(other._fp.Value);
                    }

                    throw new Exception("Priority is a numeric but value not set");
                }

                return -1;
            }
            else if (other.Type == PriorityType.Numeric)
            {
                return 1;
            }

            // Children with a string as their priority come last.
            if (Type == PriorityType.String)
            {
                if (other.Type == PriorityType.String)
                {
                    if (_sp != null && other._sp != null)
                    {
                        return String.Compare(_sp, other._sp, StringComparison.Ordinal);
                    }

                    throw new Exception("Priority is a string but value not set");
                }

                // will throw in a moment in release builds
                Debug.Assert(false, "It should not be possible for both to not be strings at this point");
            }
            else if (other.Type == PriorityType.String)
            {
                return 1;
            }

            throw new Exception("Priority sorting did not detect a valid state");
        }