/// <summary>
        /// Gets settings from data store
        /// </summary>
        /// <param name="exType">Extension Type</param>
        /// <param name="exId">Extension ID</param>
        /// <returns>Settings as Stream</returns>
        public object GetSettings(ExtensionType exType, string exId)
        {
            WidgetData wd = new WidgetData();
              XmlDocument xml = new XmlDocument();

              if (_section.DefaultProvider == "XmlTrainProvider")
              {
            Stream stm = (Stream)TrainService.LoadFromDataStore(exType, exId);
            if (stm != null)
            {
              XmlSerializer x = new XmlSerializer(typeof(XmlDocument));
              xml = (XmlDocument)x.Deserialize(stm);
              stm.Close();
            }
              }
              else
              {
            object o = TrainService.LoadFromDataStore(exType, exId);
            if (!string.IsNullOrEmpty((string)o))
            {
              XmlSerializer serializer = new XmlSerializer(typeof(WidgetData));
              using (StringReader reader = new StringReader((string)o))
              {
            wd = (WidgetData)serializer.Deserialize(reader);
              }

              if (wd.Settings.Length > 0)
            xml.InnerXml = wd.Settings;
            }
              }
              return xml;
        }
Пример #2
0
        /// <summary>
        /// Gets settings from data store
        /// </summary>
        /// <param name="exType">Extension Type</param>
        /// <param name="exId">Extension ID</param>
        /// <returns>Settings as Stream</returns>
        public object GetSettings(ExtensionType exType, string exId)
        {
            WidgetData  wd  = new WidgetData();
            XmlDocument xml = new XmlDocument();

            if (_section.DefaultProvider == "XmlTrainProvider")
            {
                Stream stm = (Stream)TrainService.LoadFromDataStore(exType, exId);
                if (stm != null)
                {
                    XmlSerializer x = new XmlSerializer(typeof(XmlDocument));
                    xml = (XmlDocument)x.Deserialize(stm);
                    stm.Close();
                }
            }
            else
            {
                object o = TrainService.LoadFromDataStore(exType, exId);
                if (!string.IsNullOrEmpty((string)o))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(WidgetData));
                    using (StringReader reader = new StringReader((string)o))
                    {
                        wd = (WidgetData)serializer.Deserialize(reader);
                    }

                    if (wd.Settings.Length > 0)
                    {
                        xml.InnerXml = wd.Settings;
                    }
                }
            }
            return(xml);
        }
Пример #3
0
        /// <summary>
        /// Saves XML document to data storage
        /// </summary>
        /// <param name="exType">Extension Type</param>
        /// <param name="exId">Extension ID</param>
        /// <param name="settings">Settings as XML document</param>
        /// <returns>True if saved</returns>
        public bool SaveSettings(ExtensionType exType, string exId, object settings)
        {
            try
            {
                XmlDocument xml = (XmlDocument)settings;

                if (_section.DefaultProvider == "XmlTrainProvider")
                {
                    TrainService.SaveToDataStore(exType, exId, xml);
                }
                else
                {
                    WidgetData wd = new WidgetData();
                    wd.Settings = xml.InnerXml;
                    TrainService.SaveToDataStore(exType, exId, wd);
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Saves XML document to data storage
        /// </summary>
        /// <param name="exType">Extension Type</param>
        /// <param name="exId">Extension ID</param>
        /// <param name="settings">Settings as XML document</param>
        /// <returns>True if saved</returns>
        public bool SaveSettings(ExtensionType exType, string exId, object settings)
        {
            try
              {
            XmlDocument xml = (XmlDocument)settings;

            if (_section.DefaultProvider == "XmlTrainProvider")
            {
              TrainService.SaveToDataStore(exType, exId, xml);
            }
            else
            {
              WidgetData wd = new WidgetData();
              wd.Settings = xml.InnerXml;
              TrainService.SaveToDataStore(exType, exId, wd);
            }
            return true;
              }
              catch (Exception)
              {
            throw;
              }
        }