Jul 04

I wasn’t going to do this, but I just can’t resist. Look carefully at the following…


// connect to the events web service
EventAccess eventAccessWS = new EventAccess();
EventSearchResults eventsResult = new EventSearchResults();

// return the results from the events web service
eventsResult = eventAccessWS.GetModifiedItems(updateTimeDate);
ParseXML.setXMLNodeValue(pathToXML,"/Indexer/collections/collection [@name='"+ repositoryToIndex +"']/lastindexed", DateTime.Now.ToString());

// convert the object into a serialized XML file
XmlSerializer serializer = new XmlSerializer(typeof (EventSearchResults));
tempXML = tempFilePath+ "\" + repositoryToIndex + srchTools.getUniqueFilename() + ".xml";
tempFiles.Add(tempXML);
Stream fs = new FileStream(tempXML, FileMode.Create);
XmlWriter writer = new XmlTextWriter(fs, new UTF8Encoding());

// Serialize using the XmlTextWriter
serializer.Serialize(writer, eventsResult);
writer.Close();
fs.Close();
...

This code snippet was part of a commercial .NET project developed by consultants that best remain unnamed. It calls a .NET web service, throws away the perfectly good returned .Net object, re-serializes it, manipulates the Xml directly (using a suite of custom Xml utility objects they built for that purpose), with the local file system standing in for temporary storage. No, really…

  • Share/Bookmark

Leave a Reply

preload preload preload