public static string Serialize(ProfileItems obj) { var serialXml = new StringBuilder(); using (var xWriter = XmlWriter.Create(serialXml)) { _serializer.Serialize(xWriter, obj); xWriter.Flush(); return(serialXml.ToString()); } }
public static string Serialize(ProfileItems obj) { var serialXml = new StringBuilder(); using (var xWriter = XmlWriter.Create(serialXml)) { _serializer.Serialize(xWriter, obj); xWriter.Flush(); return serialXml.ToString(); } }
private static void RunPlaybackFile(object f) { try { if (f != null) { var playbackItem = f as PlaybackItem; if (playbackItem != null) { log.DebugFormat("Playing back file: {0}", playbackItem.FileName); var sb = new StringBuilder(); using (var sr = new StreamReader(playbackItem.FileName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { sb.AppendLine(line); } } var innerXml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ProfileItems xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><ProfileItems>" + sb + "</ProfileItems></ProfileItems>"; var profileItems = ProfileItems.Deserialize(innerXml); var stopwatch = Stopwatch.StartNew(); foreach (var profileItem in profileItems.Items) { ExecuteQuery(profileItem, playbackItem.ConnectionInfo, playbackItem); } playbackItem.QueryTab.AppendLogTabLine(string.Format("Executed {0} queries in {1} ms.", profileItems.Items.Count(), stopwatch.ElapsedMilliseconds)); } } } catch (Exception e) { log.Error(e); } }