Exemplo n.º 1
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public bool SetValue(UUID storeID, string path, string value, bool useJson)
        {
            if (!m_enabled)
            {
                return(false);
            }

            JsonStore map = null;

            lock (m_JsonValueStore)
            {
                if (!m_JsonValueStore.TryGetValue(storeID, out map))
                {
                    m_log.InfoFormat("[JsonStore] Missing store {0}", storeID);
                    return(false);
                }
            }

            try
            {
                lock (map)
                    if (map.SetValue(path, value, useJson))
                    {
                        return(true);
                    }
            }
            catch (Exception e)
            {
                m_log.InfoFormat("[JsonStore] Unable to assign {0} to {1} in {2}; {3}", value, path, storeID, e.Message);
            }

            return(false);
        }
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public bool SetValue(UUID storeID, string path, string value, bool useJson)
        {
            if (!m_enabled)
            {
                return(false);
            }

            JsonStore map = null;

            lock (m_JsonValueStore)
            {
                if (!m_JsonValueStore.TryGetValue(storeID, out map))
                {
                    m_log.InfoFormat("[JsonStore] Missing store {0}", storeID);
                    return(false);
                }
            }

            try
            {
                lock (map)
                {
                    if (map.StringSpace > m_maxStringSpace)
                    {
                        m_log.WarnFormat("[JsonStore] {0} exceeded string size; {1} bytes used of {2} limit",
                                         storeID, map.StringSpace, m_maxStringSpace);
                        return(false);
                    }

                    return(map.SetValue(path, value, useJson));
                }
            }
            catch (Exception e)
            {
                m_log.Error(string.Format("[JsonStore]: Unable to assign {0} to {1} in {2}", value, path, storeID), e);
            }

            return(false);
        }