Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            StringWriter sw = new StringWriter();
            //创建XML命名空间

            var rtc = new RealTimeClock();

            rtc.IsRunModeClockChangeEnabled = true;
            rtc.IsFreeRunningRtcEnabled     = true;

            var serializableObj = new RealTimeClockCrcAdapter2(rtc);

            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            XmlSerializer serializer = new XmlSerializer(typeof(RealTimeClockCrcAdapter2));

            serializer.Serialize(sw, serializableObj, ns);
            sw.Close();

            var doc = new XmlDocument();

            doc.LoadXml(sw.ToString());
            doc.Save(@"C:\testXmlSerialable4.xml");

            using (var stream = new MemoryStream())
            {
                var x = new XmlSerializer(serializableObj.GetType());
                x.Serialize(stream, serializableObj);
                var crc = CalculateCrc16(stream.ToArray());
                Console.WriteLine(crc);
            }

            Console.WriteLine("Done");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public RealTimeClockCrcAdapter(RealTimeClock r)
 {
     rtc = r;
 }