Exemple #1
0
 public void SaveConfiguration()
 {
     agent.Erase(configFile);
     using (XmlTextWriter writer = new XmlTextWriter(agent.OpenStream(configFile), Encoding.UTF8))
     {
         writer.Formatting = Formatting.Indented;
         writer.WriteStartDocument();
         ToXml(writer);
     }
 }
Exemple #2
0
        public void Close()
        {
            if (null == this._agent)
            {
                throw new InvalidOperationException("Agent not set");
            }

            if (null != this._data)
            {
                if (this._data.Count > 0)
                {
                    XDocument doc = new XDocument(new XDeclaration("1.0", null, null),
                                                  new XElement("keys"));
                    // HttpContext.Current.Cache.Insert(User.CurrentUser.Name, this._data);
                    foreach (string key in this._data.Keys)
                    {
                        string sanitizedkey = key;
                        if (null != this._data[key])
                        {
                            sanitizedkey = _agent.Sanitize(key);
                            _agent.Write(sanitizedkey, SerializationServices.BinarySerialize(_data[key]));
                        }
                        doc.Element("keys").Add(new XElement("key",
                                                             new XAttribute("full", key),
                                                             new XAttribute("normalized", sanitizedkey)
                                                             ));
                    }
                    if (_agent.HasKey(STORAGE_KEY))
                    {
                        _agent.Erase(STORAGE_KEY);
                    }
                    _agent.Write(STORAGE_KEY, doc.ToString());
                    _data = null;
                }
            }

            _agent.CleanUp();
        }