Beispiel #1
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();
        }
Beispiel #2
0
        private void CreateEmptyConfiguration()
        {
            XDocument doc = new XDocument(new XDeclaration("1.0", null, null),
                                          new XElement("config",
                                                       new XElement("views"),
                                                       new XElement("tables"),
                                                       new XElement("relations")
                                                       )
                                          );

            try
            {
                agent.Write(configFile, "");
                using (XmlTextWriter writer = new XmlTextWriter(agent.OpenStream(configFile), null))
                {
                    writer.Formatting = Formatting.Indented;
                    doc.WriteTo(writer);
                }
            }
            finally
            {
                agent.CloseStream(configFile);
            }
        }