void IFlickrParsable.Load(System.Xml.XmlReader reader) { if (reader.LocalName != "count" && !reader.ReadToFollowing("count")) { UtilityMethods.CheckParsingException(reader); return; } Count = reader.ReadElementContentAsInt(); if( reader.LocalName != "prevphotos" ) reader.ReadToFollowing("prevphotos"); reader.ReadToDescendant("photo"); while (reader.LocalName == "photo") { FavoriteContextPhoto photo = new FavoriteContextPhoto(); ((IFlickrParsable)photo).Load(reader); PreviousPhotos.Add(photo); } if (reader.LocalName != "nextphotos") reader.ReadToFollowing("nextphotos"); reader.ReadToDescendant("photo"); while (reader.LocalName == "photo") { FavoriteContextPhoto photo = new FavoriteContextPhoto(); ((IFlickrParsable)photo).Load(reader); NextPhotos.Add(photo); } }
void IFlickrParsable.Load(System.Xml.XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); if (!reader.ReadToFollowing("photos")) throw new ResponseXmlException("Unable to find \"photos\" element in response."); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "maxdisplaypx": MaximumDisplayPixels = reader.ReadContentAsInt(); break; case "maxupload": MaximumPhotoUpload = reader.ReadContentAsLong(); break; default: UtilityMethods.CheckParsingException(reader); break; } } if (!reader.ReadToFollowing("videos")) throw new ResponseXmlException("Unable to find \"videos\" element in response."); while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "maxduration": MaximumVideoDuration = reader.ReadContentAsInt(); break; case "maxupload": MaximumVideoUpload = reader.ReadContentAsLong(); break; default: UtilityMethods.CheckParsingException(reader); break; } } reader.Skip(); }
public void ReadXml(System.Xml.XmlReader reader) { this.Clear(); XmlSerializer x = new XmlSerializer(typeof(StoredRegion)); while (reader.ReadToFollowing("StoredRegion")) { object o = x.Deserialize(reader); if (o is StoredRegion) this.Add(o); } }
public void DoSearch(string[] parts, ArrayList result, System.Xml.XmlReader reader, bool securityTrimmingEnabled) { if (reader.ReadToFollowing("category", ns) && reader.MoveToAttribute("name") && reader.Value == "Root" && reader.MoveToElement()) { int i = 1; if (i < parts.Length) { ReadSubElements(reader, parts, i, result, securityTrimmingEnabled); } else { ReadSubItems(reader, result, securityTrimmingEnabled); } } }
/// <summary> /// Generate object from its XML representation</summary> /// <param name="reader">XmlReader stream from which object is deserialized</param> public void ReadXml(System.Xml.XmlReader reader) { if (reader.ReadToFollowing(this.GetType().Name)) { if (reader.ReadToDescendant("Content")) { do { String ucid = reader.GetAttribute("UCID"); DockContent content = Root.GetContent(ucid); if (content != null) { AddContent(content); } } while (reader.ReadToNextSibling("Content")); } reader.Read(); } }
/// <summary> /// Loads the inventory from XML. /// </summary> /// <param name="reader">Reader.</param> public void LoadInventory(System.Xml.XmlReader reader) { int itemCount = 0; reader.ReadToFollowing ("Inventory"); reader.ReadToDescendant ("Item"); do { string id = reader.GetAttribute ("ID"); inventory [itemCount] = database [int.Parse (id)].Clone (); reader.ReadToDescendant ("Quantity"); inventory [itemCount].stackSize = reader.ReadElementContentAsInt(); Debug.Log ("Just parsed " + inventory [itemCount]); itemCount++; reader.ReadEndElement(); } while(reader.ReadToNextSibling("Item")); reader.ReadEndElement (); }
public void ReadXml(System.Xml.XmlReader reader) { if (reader.ReadToFollowing(this.GetType().Name)) { reader.ReadStartElement(this.GetType().Name); if (reader.LocalName == typeof(TabLayout).Name || reader.LocalName == "MultiContent") // MultiContent is old name and is used here for compatibility with old saved layouts { DockedContent = new TabLayout(Root, reader.ReadSubtree()); if (DockedContent.Children.Count > 0) { ContentSettings contentSettings = DockedContent.Children[0].Settings; Left = contentSettings.Location.X; Top = contentSettings.Location.Y; Width = contentSettings.Size.Width; Height = contentSettings.Size.Height; Left = Math.Max(0, Math.Min(Left, SystemParameters.VirtualScreenWidth - Width)); Top = Math.Max(0, Math.Min(Top, SystemParameters.VirtualScreenHeight - Height)); Width = Math.Max(Math.Min(Width, SystemParameters.VirtualScreenWidth - Left), 100); Height = Math.Max(Math.Min(Height, SystemParameters.VirtualScreenHeight - Top), 100); reader.ReadEndElement(); } } reader.ReadEndElement(); } }
private void CreateSourceTable(System.Xml.XmlReader reader) { string[] columnNames; ArrayList names = new ArrayList(); reader.MoveToAttribute("TableName"); string codeTableName = reader.Value.ToString(); DataTable fromXml = new DataTable(codeTableName); DataRow rowFromXml; reader.ReadToFollowing("Item"); do { if (reader.MoveToFirstAttribute()) { string columnName = reader.Name.Replace("__space__", " "); if (fromXml.Columns.Contains(columnName) == false) { fromXml.Columns.Add(columnName, System.Type.GetType("System.String")); } rowFromXml = fromXml.NewRow(); rowFromXml[columnName] = reader.Value; while (reader.MoveToNextAttribute()) { columnName = reader.Name.Replace("__space__", " "); if (fromXml.Columns.Contains(columnName) == false) { fromXml.Columns.Add(columnName, System.Type.GetType("System.String")); DataRow tempRow = fromXml.NewRow(); tempRow.ItemArray = rowFromXml.ItemArray; } rowFromXml[columnName] = reader.Value; } fromXml.Rows.Add(rowFromXml); } } while (reader.ReadToNextSibling("Item")); if (mediator.Project.Metadata.TableExists(codeTableName)) { DataTable existing = mediator.Project.Metadata.GetCodeTableData(codeTableName); if (TablesAreDifferent(existing, fromXml)) { foreach (DataColumn column in fromXml.Columns) { names.Add(column.ColumnName); } columnNames = (string[])names.ToArray(typeof(string)); DialogResult replaceWithTemplate = MsgBox.ShowQuestion("A code table with the following name already exists in the database: " + existing + ". Replace code table with the code table defined in the template?" ); if (replaceWithTemplate == DialogResult.Yes) { mediator.Project.Metadata.DeleteCodeTable(codeTableName); mediator.Project.Metadata.CreateCodeTable(codeTableName, columnNames); mediator.Project.Metadata.SaveCodeTableData(fromXml, codeTableName, columnNames); } else { string newCodeTableName = codeTableName; DataSets.TableSchema.TablesDataTable tables = mediator.Project.Metadata.GetCodeTableList(); int arbitraryMax = 2048; for (int nameExtension = 1; nameExtension < arbitraryMax; nameExtension++) { foreach (DataRow row in tables) { if (newCodeTableName.ToLower() == ((string)row[ColumnNames.TABLE_NAME]).ToLower()) { newCodeTableName = codeTableName + nameExtension.ToString(); break; } } if (newCodeTableName != codeTableName + nameExtension.ToString()) { break; } } _sourceTableRenames.Add(codeTableName, newCodeTableName); mediator.Project.Metadata.CreateCodeTable(newCodeTableName, columnNames); mediator.Project.Metadata.SaveCodeTableData(fromXml, newCodeTableName, columnNames); } } } else { foreach (DataColumn column in fromXml.Columns) { string columnName = column.ColumnName.Replace("__space__", " "); names.Add(columnName); } columnNames = (string[])names.ToArray(typeof(string)); mediator.Project.Metadata.CreateCodeTable(codeTableName, columnNames); mediator.Project.Metadata.SaveCodeTableData(fromXml, codeTableName, columnNames); } }
/// <summary> /// Generate object from its XML representation</summary> /// <param name="reader">XmlReader stream from which object is deserialized</param> public void ReadXml(System.Xml.XmlReader reader) { if (reader.ReadToFollowing(this.GetType().Name)) { reader.ReadStartElement(); if (reader.LocalName == typeof(TabLayout).Name || reader.LocalName == "MultiContent") // MultiContent is old name and is used here for compatibility with old saved layouts { DockedContent = new TabLayout(Root, reader.ReadSubtree()); Content = DockedContent; reader.ReadEndElement(); } reader.ReadEndElement(); } }
public void ReadXml(System.Xml.XmlReader reader) { this.Clear(); XmlSerializer x = new XmlSerializer(typeof(ExternalTool)); while (reader.ReadToFollowing("ExternalTool")) { object o = x.Deserialize(reader); if (o is ExternalTool) this.Add(o); } }
public void ReadXml(System.Xml.XmlReader reader) { if (reader.ReadToFollowing(this.GetType().Name)) { String s = reader.GetAttribute(Orientation.GetType().Name); m_orientation = (Orientation)(Enum.Parse(Orientation.GetType(), s)); switch (m_orientation) { case Orientation.Horizontal: if (reader.ReadToDescendant("Column")) { RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Height)); do { double width = double.Parse(reader.GetAttribute("Width")); IDockLayout layout = null; reader.ReadStartElement(); if (reader.LocalName == typeof(DockedWindow).Name) { DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree()); layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null; reader.ReadEndElement(); } else if (reader.LocalName == typeof(GridLayout).Name) { GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree()); layout = gridLayout.Layouts.Count > 0 ? gridLayout : null; reader.ReadEndElement(); } if (layout != null) { if (Children.Count > 0) { ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Auto), 0)); Children.Add(NewGridSplitter(Orientation)); } ColumnDefinitions.Add(NewColumnDefinition(new GridLength(width, GridUnitType.Star), m_minGridSize.Width)); m_children.Add(layout); Children.Add((FrameworkElement)layout); } } while (reader.ReadToNextSibling("Column")); } break; case Orientation.Vertical: if (reader.ReadToDescendant("Row")) { ColumnDefinitions.Add(NewColumnDefinition(new GridLength(1, GridUnitType.Star), m_minGridSize.Width)); do { double height = double.Parse(reader.GetAttribute("Height")); IDockLayout layout = null; reader.ReadStartElement(); if (reader.LocalName == typeof(DockedWindow).Name) { DockedWindow dockedWindow = new DockedWindow(Root, reader.ReadSubtree()); layout = dockedWindow.DockedContent.Children.Count != 0 ? dockedWindow : null; reader.ReadEndElement(); } else if (reader.LocalName == typeof(GridLayout).Name) { GridLayout gridLayout = new GridLayout(Root, reader.ReadSubtree()); layout = gridLayout.Layouts.Count > 0 ? gridLayout : null; reader.ReadEndElement(); } if (layout != null) { if (Children.Count > 0) { RowDefinitions.Add(NewRowDefinition(new GridLength(1, GridUnitType.Auto), 0)); Children.Add(NewGridSplitter(Orientation)); } RowDefinitions.Add(NewRowDefinition(new GridLength(height, GridUnitType.Star), m_minGridSize.Height)); m_children.Add(layout); Children.Add((FrameworkElement)layout); } } while (reader.ReadToNextSibling("Row")); } break; } for(int i = 0; i < Children.Count; i++) { Grid.SetColumn(Children[i], Orientation == Orientation.Horizontal ? i : 0); Grid.SetRow(Children[i], Orientation == Orientation.Vertical ? i : 0); } reader.ReadEndElement(); } }
public void ReadXml(System.Xml.XmlReader reader) { // reset the counter of modifications because we just load the map (no modification done) mNumberOfModificationSinceLastSave = 0; // version readVersionNumber(reader); // check if the BlueBrick program is not too old, that // means the user try to load a file generated with /// a earlier version of BlueBrick if (mDataVersionOfTheFileLoaded > CURRENT_DATA_VERSION) { MessageBox.Show(null, Properties.Resources.ErrorMsgProgramObsolete, Properties.Resources.ErrorMsgTitleError, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } // get the number of layer for the progressbar if (mDataVersionOfTheFileLoaded >= 3) { int nbItems = reader.ReadElementContentAsInt(); // init the progress bar with the real number of layer items (+1 for the header +1 for the link rebuilding) MainForm.Instance.resetProgressBar(nbItems + 2); } // check is there is a background color if (reader.Name.Equals("BackgroundColor")) mBackgroundColor = XmlReadWrite.readColor(reader); // data of the map mAuthor = reader.ReadElementContentAsString(); mLUG = reader.ReadElementContentAsString(); mShow = reader.ReadElementContentAsString(); reader.ReadToDescendant("Day"); int day = reader.ReadElementContentAsInt(); int month = reader.ReadElementContentAsInt(); int year = reader.ReadElementContentAsInt(); mDate = new DateTime(year, month, day); // read the comment if the version is greater than 0 if (mDataVersionOfTheFileLoaded > 0) { reader.ReadToFollowing("Comment"); mComment = reader.ReadElementContentAsString().Replace("\n", Environment.NewLine); } else { reader.ReadToFollowing("CurrentSnapGridSize"); } if (mDataVersionOfTheFileLoaded < 2) { // skip the static data of layers that before we were saving // but now I think it is stupid, since we don't have action to change that // and we don't have way to update the enabled of the buttons reader.ReadElementContentAsFloat(); // CurrentSnapGridSize reader.ReadElementContentAsBoolean(); // SnapGridEnabled reader.ReadElementContentAsFloat(); // CurrentRotationStep } // read the export data if the version is 5 or higher if (mDataVersionOfTheFileLoaded > 4) { reader.ReadToDescendant("ExportPath"); // read the relative export path and store it temporarly in the absolute path variable // the absolute path will be computed after the xml serialization is finished mExportAbsoluteFileName = reader.ReadElementContentAsString(); // read the other export info mExportFileTypeIndex = reader.ReadElementContentAsInt(); mExportArea = XmlReadWrite.readRectangleF(reader); mExportScale = reader.ReadElementContentAsFloat(); // read even more info from version 8 if (mDataVersionOfTheFileLoaded > 7) { mExportWatermark = XmlReadWrite.readBoolean(reader); mExportBrickHull = XmlReadWrite.readBoolean(reader); mExportElectricCircuit = XmlReadWrite.readBoolean(reader); mExportConnectionPoints = XmlReadWrite.readBoolean(reader); } reader.ReadEndElement(); } // selected layer int selectedLayerIndex = reader.ReadElementContentAsInt(); // step the progress bar after the read of the header MainForm.Instance.stepProgressBar(); // layers // first clear the hashtable that contains all the bricks Map.sHashtableForRulerAttachementRebuilding.Clear(); // then load all the layers bool layerFound = reader.ReadToDescendant("Layer"); while (layerFound) { // get the 'type' attribute of the layer reader.ReadAttributeValue(); string layerType = reader.GetAttribute(0); // instantiate the right layer according to the type Layer layer = null; if (layerType.Equals("grid")) layer = new LayerGrid(); else if (layerType.Equals("brick")) layer = new LayerBrick(); else if (layerType.Equals("text")) layer = new LayerText(); else if (layerType.Equals("area")) layer = new LayerArea(); else if (layerType.Equals("ruler")) layer = new LayerRuler(); // read and add the new layer if (layer != null) { layer.ReadXml(reader); mLayers.Add(layer); } // read the next layer layerFound = reader.ReadToNextSibling("Layer"); } reader.ReadEndElement(); // end of Layers // once we have finished to read all the layers thus all the items, we need to recreate all the links they have between them foreach (Layer layer in mLayers) layer.recreateLinksAfterLoading(); // then clear again the hash table to free the memory Map.sHashtableForRulerAttachementRebuilding.Clear(); // step the progress bar after the rebuilding of links MainForm.Instance.stepProgressBar(); // if the selected index is valid, reset the selected layer // use the setter in order to enable the toolbar buttons if ((selectedLayerIndex >= 0) && (selectedLayerIndex < mLayers.Count)) SelectedLayer = mLayers[selectedLayerIndex]; else SelectedLayer = null; // DO NOT READ YET THE BRICK URL LIST, BECAUSE THE BRICK DOWNLOAD FEATURE IS NOT READY if (false) { // read the url of all the parts for version 5 or later if ((mDataVersionOfTheFileLoaded > 5) && !reader.IsEmptyElement) { bool urlFound = reader.ReadToDescendant("BrickUrl"); while (urlFound) { // read the next url urlFound = reader.ReadToNextSibling("BrickUrl"); } reader.ReadEndElement(); } } // construct the watermark computeGeneralInfoWatermark(); // for old version, make disapear the progress bar, since it was just an estimation MainForm.Instance.finishProgressBar(); }
public void ReadXml(System.Xml.XmlReader reader) { reader.ReadToFollowing(xmlFlujogramaType.Name); XmlSerializer serializer = new XmlSerializer(xmlFlujogramaType); FlujogramaDef = serializer.Deserialize(reader) as IFlujograma; //EntidadIDentificable.IdEntidad = FlujogramaDef.IdEntidad; //EntidadIDentificable.Entidad = FlujogramaDef.Entidad; reader.ReadToFollowing(xmlEstadoType.Name); if (reader.Name.Equals(xmlEstadoType.Name)) { serializer = new XmlSerializer(xmlEstadoType); EstadoActual = serializer.Deserialize(reader) as IEstado; EstadoActual.Flujograma = FlujogramaDef; } reader.ReadToFollowing(xmlTransicionType.Name); if (reader.Name.Equals(xmlTransicionType.Name)) { serializer = new XmlSerializer(xmlTransicionType); UltimaTransicion = serializer.Deserialize(reader) as ITransicion; UltimaTransicion.Flujograma = FlujogramaDef; UltimaTransicion.Origen = FlujogramaDef.Estados[UltimaTransicion.Origen.Estado]; UltimaTransicion.Destino = FlujogramaDef.Estados[UltimaTransicion.Destino.Estado]; } reader.ReadToFollowing("Historico"); if (reader.Name.Equals("Historico")) { XmlReader hijos = reader.ReadSubtree(); serializer = new XmlSerializer(xmlTransicionType); while (hijos.ReadToFollowing(xmlTransicionType.Name)) { ITransicion tran = serializer.Deserialize(hijos) as ITransicion; tran.Flujograma = FlujogramaDef; tran.Origen = FlujogramaDef.Estados[tran.Origen.Estado]; tran.Destino = FlujogramaDef.Estados[tran.Destino.Estado]; _procesosAnteriores.Add(tran.FechaTransicion, tran); } } }
/// <summary> /// Parse the image response. /// </summary> /// <param name="oReader">The GeosoftXML response</param> /// <param name="oBitmap">The image</param> public void Legend(System.Xml.XmlReader oReader, out System.Drawing.Bitmap oBitmap) { System.IO.MemoryStream oMemStream = new System.IO.MemoryStream(); oBitmap = null; try { // --- find the dataset edition element --- if (oReader.ReadToFollowing(Constant.Tag.LEGEND_TAG)) { string strValue = oReader.GetAttribute(Constant.Attribute.VALUE_ATTR); bool bValue; if (string.IsNullOrEmpty(strValue)) return; if (!bool.TryParse(strValue, out bValue)) return; if (!bValue) return; byte[] bImage = new byte[4096]; int iCount = 0; do { iCount = oReader.ReadContentAsBase64(bImage, 0, 4096); if (iCount > 0) oMemStream.Write(bImage, 0, iCount); } while (iCount > 0); oMemStream.Seek(0, System.IO.SeekOrigin.Begin); oBitmap = new System.Drawing.Bitmap(oMemStream); } } catch (Exception e) { throw new DapException("Error retrieving legend", e); } finally { oMemStream.Close(); } }
/// <summary> /// Parse the extract response. /// </summary> /// <param name="oReader">The GeosoftXML response</param> /// <param name="oStream">The extracted data in a stream</param> public void ExtractData(System.Xml.XmlReader oReader, System.IO.Stream oStream) { byte[] bExtract = new byte[4096]; if (oReader.ReadToFollowing(Constant.Tag.EXTRACT_DATA_TAG)) { int iCount = 0; do { iCount = oReader.ReadElementContentAsBase64(bExtract, 0, 4096); oStream.Write(bExtract, 0, iCount); } while (iCount != 0); } }
protected string ReceiveXmlMessage(System.Xml.XmlReader reader) { string strCommand = ""; if (reader.ReadToFollowing("Command")) //if (reader.Name == "Command") { strCommand = reader.GetAttribute("Type"); Dictionary<string, string> parameterList = new Dictionary<string, string>(); if (reader.ReadToDescendant("Parameter")) { do { string strParameterName = reader.GetAttribute("Name"); string strParameterValue = reader.ReadElementString(); parameterList.Add(strParameterName, strParameterValue); } while (reader.ReadToNextSibling("Parameter")); } switch (strCommand) { case Commands.Configuration.Command: //load saved configuration values LoadingConfigValues(parameterList); return ""; case Commands.GetConfiguration.Command: return ReturnConfiguration(); //break; case Commands.GetSupportedFeatures.Command: // "GetSupportedFeatures": //e.g. Worklist, CurveData, Attachment_Type, Attachment_Path return ReturnSupportedFeatures(); //break; case Commands.SearchPatients.Command: // "SearchPatient": //list of patients return ReturnSearchPatientResult(parameterList); case Commands.TestResult.Command: // "TestResult": //Do nothing. Results are read from output file. return ""; default: return @" <ndd> <Command Type=""Error""> <Parameter Name=""Message"">Command not supported</Parameter> <Parameter Name=""Details"">" + strCommand + @"</Parameter> </Command> </ndd>"; } } while (reader.Read()) { if (reader.Name == "Patients") { System.Xml.XmlReader patientReader = reader.ReadSubtree(); while (patientReader.ReadToFollowing("Patient")) { if (patientReader.ReadAttributeValue() && patientReader.AttributeCount > 0) { string strPatientID = patientReader.GetAttribute("ID"); string strPatientNone = patientReader.GetAttribute("NotAvailable"); } while (patientReader.Read()) { if (patientReader.Name == "FirstName") { string strName = patientReader.ReadString(); } } } if (reader.ReadToFollowing("Patient")) { } } } Console.Beep(); return ""; }