Serialize() 공개 메소드

public Serialize ( XmlTextWriter xtw, Object o, MappingAction mappingAction ) : void
xtw System.Xml.XmlTextWriter
o Object
mappingAction MappingAction
리턴 void
예제 #1
0
 public static XmlDocument Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingAction action)
 {
   Stream stm = new MemoryStream();
   XmlTextWriter xtw = new XmlTextWriter(stm, Encoding.UTF8);
   xtw.Formatting = Formatting.Indented;
   xtw.Indentation = 2;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   stm.Position = 0;    
   TextReader trdr = new StreamReader(stm, new UTF8Encoding(), true, 4096);
   String s = trdr.ReadLine();
   while (s != null)
   {
     //Console.WriteLine(s);
     s = trdr.ReadLine();
   }            
   stm.Position = 0;    
   XmlDocument xdoc = new XmlDocument();
   xdoc.PreserveWhitespace = true;
   xdoc.Load(stm);
   return xdoc;
 }
예제 #2
0
        public static XmlReader Serialize(string testName, object obj, Encoding encoding, MappingActions actions)
        {
            Stream stm = new MemoryStream();

            var xtw = XmlRpcXmlWriter.Create(stm, new XmlRpcFormatSettings());

            xtw.WriteStartDocument();
            var ser = new XmlRpcSerializer();

            ser.Serialize(xtw, obj, actions);
            xtw.Flush();
            stm.Position = 0;

            return(XmlRpcXmlReader.Create(stm));
        }
예제 #3
0
 public static XmlReader Serialize(
   string testName,
   object obj, 
   Encoding encoding,
   MappingActions actions)
 {
   Stream stm = new MemoryStream();
   XmlWriter xtw = XmlRpcXmlWriter.Create(stm, new XmlRpcFormatSettings());
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, actions); 
   xtw.Flush();
   stm.Position = 0;    
   XmlReader rdr = XmlRpcXmlReader.Create(stm);
   return rdr;
 }
예제 #4
0
 public static string SerializeToString(
   string testName,
   object obj, 
   MappingAction action)
 {
   StringWriter strwrtr = new StringWriter();
   XmlTextWriter xtw = new XmlTextWriter(strwrtr);
   //      xtw.Formatting = formatting;
   //      xtw.Indentation = indentation;
   xtw.WriteStartDocument();      
   XmlRpcSerializer ser = new XmlRpcSerializer();
   ser.Serialize(xtw, obj, action); 
   xtw.Flush();
   //Console.WriteLine(testName);
   //Console.WriteLine(strwrtr.ToString());
   return strwrtr.ToString();
 }
예제 #5
0
        public static string SerializeValue(object value, bool indent)
        {
            var memStm = new MemoryStream();
            var writer = XmlRpcXmlWriter.Create(
                memStm,
                new XmlRpcFormatSettings {
                OmitXmlDeclaration = true, UseIndentation = indent
            });
            var serializer = new XmlRpcSerializer();

            serializer.Serialize(writer, value, new MappingActions {
                NullMappingAction = NullMappingAction.Error
            });
            writer.Flush();
            memStm.Position = 0;

            return(new StreamReader(memStm).ReadToEnd());
        }
예제 #6
0
        public static string SerializeValue(object value, bool indent)
        {
            var memStm = new MemoryStream();
            var writer = XmlRpcXmlWriter.Create(
                memStm,
                new XmlRpcFormatSettings { OmitXmlDeclaration = true, UseIndentation = indent });
            var serializer = new XmlRpcSerializer();
            serializer.Serialize(writer, value, new MappingActions { NullMappingAction = NullMappingAction.Error });
            writer.Flush();
            memStm.Position = 0;

            return new StreamReader(memStm).ReadToEnd();
        }