/// <summary>
        /// Retreaves StringDictionary object from database or file system
        /// </summary>
        /// <param name="exType">Extension Type</param>
        /// <param name="exId">Extension Id</param>
        /// <returns>StringDictionary object as Stream</returns>
        public object GetSettings(ExtensionType exType, string exId)
        {
            SerializableStringDictionary ssd = null;
            StringDictionary             sd  = new StringDictionary();
            XmlSerializer serializer         = new XmlSerializer(typeof(SerializableStringDictionary));

            if (_section.DefaultProvider == "XmlBlogProvider")
            {
                Stream stm = (Stream)BlogService.LoadFromDataStore(exType, exId);
                if (stm != null)
                {
                    ssd = (SerializableStringDictionary)serializer.Deserialize(stm);
                    stm.Close();
                    sd = (StringDictionary)ssd;
                }
            }
            else
            {
                object o = BlogService.LoadFromDataStore(exType, exId);
                if (!string.IsNullOrEmpty((string)o))
                {
                    using (StringReader reader = new StringReader((string)o))
                    {
                        ssd = (SerializableStringDictionary)serializer.Deserialize(reader);
                    }
                    sd = (StringDictionary)ssd;
                }
            }
            return(sd);
        }
Beispiel #2
0
        /// <summary>
        /// Saves String Dictionary to Data Store
        /// </summary>
        /// <param name="extensionType">
        /// Extension Type
        /// </param>
        /// <param name="extensionId">
        /// Extension Id
        /// </param>
        /// <param name="settings">
        /// StringDictionary settings
        /// </param>
        /// <returns>
        /// The save settings.
        /// </returns>
        public bool SaveSettings(ExtensionType extensionType, string extensionId, object settings)
        {
            var sd  = (StringDictionary)settings;
            var ssd = new SerializableStringDictionary();

            foreach (DictionaryEntry de in sd)
            {
                ssd.Add(de.Key.ToString(), de.Value.ToString());
            }

            BlogService.SaveToDataStore(extensionType, extensionId, ssd);
            return(true);
        }
        /// <summary>
        /// Saves String Dictionary to Data Store
        /// </summary>
        /// <param name="extensionType">
        /// Extension Type
        /// </param>
        /// <param name="extensionId">
        /// Extension Id
        /// </param>
        /// <param name="settings">
        /// StringDictionary settings
        /// </param>
        /// <returns>
        /// The save settings.
        /// </returns>
        public bool SaveSettings(ExtensionType extensionType, string extensionId, object settings)
        {
            var sd = (StringDictionary)settings;
            var ssd = new SerializableStringDictionary();

            foreach (DictionaryEntry de in sd)
            {
                ssd.Add(de.Key.ToString(), de.Value.ToString());
            }

            BlogService.SaveToDataStore(extensionType, extensionId, ssd);
            return true;
        }