예제 #1
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public bool ReadValue(string expr, bool useJson, TakeValueCallback cback)
        {
            Stack <string> path;

            if (!ParsePathExpression(expr, out path))
            {
                return(false);
            }

            string pexpr = PathExpressionToKey(path);

            OSD result = ProcessPathExpression(ValueStore, path);

            if (result == null)
            {
                m_ReadStore.Add(new TakeValueCallbackClass(pexpr, useJson, cback));
                return(false);
            }

            string value = String.Empty;

            if (!ConvertOutputValue(result, out value, useJson))
            {
                // the structure does not match the request so i guess we'll wait
                m_ReadStore.Add(new TakeValueCallbackClass(pexpr, useJson, cback));
                return(false);
            }

            cback(value);

            return(true);
        }
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
        {
            if (!m_enabled)
            {
                cback(String.Empty);
                return;
            }

            JsonStore map = null;

            lock (m_JsonValueStore)
            {
                if (!m_JsonValueStore.TryGetValue(storeID, out map))
                {
                    cback(String.Empty);
                    return;
                }
            }

            try
            {
                lock (map)
                {
                    map.ReadValue(path, useJson, cback);
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.Error("[JsonStore]: unable to retrieve value", e);
            }

            cback(String.Empty);
        }
예제 #3
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
        {
            if (!m_enabled)
            {
                cback(String.Empty);
                return;
            }

            JsonStore map = null;

            lock (m_JsonValueStore)
            {
                if (!m_JsonValueStore.TryGetValue(storeID, out map))
                {
                    cback(String.Empty);
                    return;
                }
            }

            try
            {
                lock (map)
                {
                    map.TakeValue(path, useJson, cback);
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.InfoFormat("[JsonStore] unable to retrieve value; {0}", e.ToString());
            }

            cback(String.Empty);
        }
예제 #4
0
        // -----------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        // -----------------------------------------------------------------
        public void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
        {
            if (! m_enabled)
            {
                cback(String.Empty);
                return;
            }

            JsonStore map = null;
            if(!m_JsonValueStore.TryGetValue(storeID, out map))
            {
                cback(String.Empty);
                return;
            }

            try
            {
                lock (map)
                {
                    map.ReadValue(path, useJson, cback);
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.Error("[JsonStore]: unable to retrieve value", e);
            }
            
            cback(String.Empty);
        }
예제 #5
0
 public TakeValueCallbackClass(string spath, bool usejson, TakeValueCallback cback)
 {
     Path = spath;
     UseJson = usejson;
     Callback = cback;
 }
예제 #6
0
        // -----------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        // -----------------------------------------------------------------
        public bool ReadValue(string expr, bool useJson, TakeValueCallback cback)
        {
            Stack<string> path;
            if (! ParsePathExpression(expr,out path))
                return false;

            string pexpr = PathExpressionToKey(path);

            OSD result = ProcessPathExpression(ValueStore,path);
            if (result == null)
            {
                m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
                return false;
            }
            
            string value = String.Empty;
            if (! ConvertOutputValue(result,out value,useJson))
            {
                // the structure does not match the request so i guess we'll wait
                m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
                return false;
            }

            cback(value);

            return true;
        }
예제 #7
0
 public TakeValueCallbackClass(string spath, bool usejson, TakeValueCallback cback)
 {
     Path     = spath;
     UseJson  = usejson;
     Callback = cback;
 }
예제 #8
0
        // -----------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        // -----------------------------------------------------------------
        public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
        {
            if (! m_enabled)
            {
                cback(String.Empty);
                return;
            }

            JsonStore map = null;
            lock (m_JsonValueStore)
            {
                if (! m_JsonValueStore.TryGetValue(storeID,out map))
                {
                    cback(String.Empty);
                    return;
                }
            }

            try
            {
                lock (map)
                {
                    map.TakeValue(path, useJson, cback);
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.InfoFormat("[JsonStore] unable to retrieve value; {0}",e.ToString());
            }
            
            cback(String.Empty);
        }
        // -----------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        // -----------------------------------------------------------------
        public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
        {
            bool gotItem;
            if (! m_enabled)
            {
                cback(String.Empty);
                return;
            }

            JsonStore map = null;
            m_JsonValueStoreRwLock.AcquireReaderLock(-1);
            try
            {
                gotItem = m_JsonValueStore.TryGetValue(storeID, out map);
            }
            finally
            {
                m_JsonValueStoreRwLock.ReleaseReaderLock();
            }

            if (!gotItem)
            {
                cback(String.Empty);
                return;
            }

            try
            {
                lock (map)
                {
                    map.TakeValue(path, useJson, cback);
                    return;
                }
            }
            catch (Exception e)
            {
                m_log.Error("[JsonStore] unable to retrieve value", e);
            }

            cback(String.Empty);
        }