public object Load(System.IO.Stream s) { SerializableXmlDocument doc = new SerializableXmlDocument(); try { doc.Load(s); return(doc); } catch (Exception e) { Common.WarningFormatted(typeof(XmlLoadableFactory), "Could not load Xml document from stream '{0}': {1}", s, e); return(null); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); UnifiedFile selectedFile = FileManager.SingleSelectedFile; // Init the XForm. SerializableXmlDocument rawFile = new SerializableXmlDocument(); VirtualFile vf = HostingEnvironment.VirtualPathProvider.GetFile(selectedFile.Parent.CustomFileSummaryVirtualPath); using (Stream stream = vf.Open()) { rawFile.Load(stream); } XForm form = new XForm(); form.Document = rawFile; _data = form.CreateFormData(); // Populate the XForm. IDictionary dict = selectedFile.Summary.Dictionary; foreach (DictionaryEntry entry in dict) { if (entry.Value != null) { _data.SetValue(entry.Key.ToString(), entry.Value.ToString()); } } XFormCtrl.Data = _data; XFormCtrl.FormDefinition = form; if (!FileSystemUtility.CanEdit(selectedFile)) { SaveButton.Enabled = false; Page.Validators.Add(new StaticValidator(Translate("/filemanager/errormessage/cannotchange"))); } }