示例#1
0
        public void SerializeTheListener()
        {
            EventLogListener original = new EventLogListener();

            original.MessagePrefix    = "MP";
            original.AppendFieldNames = true;
            original.Host             = "10.0.0.1";
            original.LogName          = "LN";
            original.PollInterval     = 100;

            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(original.GetType());
            StringBuilder sb = new StringBuilder();

            System.IO.StringWriter sw = new System.IO.StringWriter(sb);
            xs.Serialize(sw, original);

            System.IO.StringReader sr = new System.IO.StringReader(sb.ToString());

            EventLogListener copy = (EventLogListener)xs.Deserialize(sr);

            Assert.AreEqual(original.MessagePrefix, copy.MessagePrefix);
            Assert.AreEqual(original.AppendFieldNames, copy.AppendFieldNames);
            Assert.AreEqual(original.Host, copy.Host);
            Assert.AreEqual(original.LogName, copy.LogName);
            Assert.AreEqual(original.PollInterval, copy.PollInterval);

            original.Dispose();
            copy.Dispose();
        }
示例#2
0
 public void Dispose()
 {
     listener.Dispose();
 }