本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcSerializer.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcSerializer.Serialize方法的具体用法?C# XmlRpcSerializer.Serialize怎么用?C# XmlRpcSerializer.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CookComputing.XmlRpc.XmlRpcSerializer
的用法示例。
在下文中一共展示了XmlRpcSerializer.Serialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
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: Serialize
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;
}
示例3: SerializeToString
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();
}
示例4: SerializeValue
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();
}