Beispiel #1
0
        /// <summary>
        ///     Inserts a new key-value pair into the database and commits the changes.
        /// </summary>
        /// <param name="key">Key that identifies the value</param>
        /// <param name="value">Object to be stored</param>
        public void Set(string key, object value)
        {
            if (!IsOpen())
            {
                Debug.LogError(
                    $"You are trying to use 'Set' on a save file that is not open. ('{_filename}')");
                return;
            }

            _tree[key] = JsonConvert.SerializeObject(value, _defaultSettings);
            _tree.Commit();
        }
Beispiel #2
0
            protected override void Dispose(bool disposing)
            {
                if (_plusTree != null)
                {
                    try
                    {
                        // Save the system reflection database, if newly created...
                        if (_isSystem)
                        {
                            if (!_isExisted)
                            {
                                // Add some metadata...
                                _plusTree["$DataCount$"]   = _count.ToString();
                                _plusTree["$DataVersion$"] = "2.6.10621.1";

                                _plusTree.Commit();
                            }
                        }

                        _plusTree.Shutdown();
                        _plusTree = null;

                        // For the non-system reflection database, delete after use...
                        if (!_isSystem)
                        {
                            if (!String.IsNullOrEmpty(_treeFileName) &&
                                File.Exists(_treeFileName))
                            {
                                File.Delete(_treeFileName);
                            }
                            if (!String.IsNullOrEmpty(_blockFileName) &&
                                File.Exists(_blockFileName))
                            {
                                File.Delete(_blockFileName);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
Beispiel #3
0
        private static void ProcessReceivedService(string serviceXML)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(serviceXML);
            XmlNodeList guids       = xmlDoc.GetElementsByTagName("GUID");
            string      serviceGUID = guids[0].InnerText;

            if (_tree.ContainsKey(serviceGUID))
            {
                string currentService = _tree[serviceGUID];
                if (currentService != serviceXML)
                {
                    _tree[serviceGUID]            = serviceXML;
                    _changedServices[serviceGUID] = serviceXML;
                }
            }
            else
            {
                _tree[serviceGUID]            = serviceXML;
                _changedServices[serviceGUID] = serviceXML;
            }
            _tree.Commit();
        }