本文整理汇总了C#中System.Xml.Serialization.XmlSerializer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializer.ToString方法的具体用法?C# XmlSerializer.ToString怎么用?C# XmlSerializer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlSerializer
的用法示例。
在下文中一共展示了XmlSerializer.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serializable_ArrayNonNullException
public void Serializable_ArrayNonNullException()
{
var serializer = new XmlSerializer(typeof(List<SiteStatusIssue>), new Type[] { typeof(SiteStatusIssue) });
Exception exception = null;
try
{
throw new ArgumentException();
}
catch (Exception ex)
{
exception = ex;
}
var issue2 = new SiteStatusIssue()
{
FailedTaskDescription = "",
Implications = "",
ProbableCause = "",
Exception = exception
};
var result = "";
using (var writer = new StringWriter())
{
serializer.Serialize(writer, new List<SiteStatusIssue>() { issue2 });
result = serializer.ToString();
}
}
示例2: Serializable_ArrayNullException
public void Serializable_ArrayNullException()
{
var serializer = new XmlSerializer(typeof(List<SiteStatusIssue>), new Type[] { typeof(SiteStatusIssue) });
var issue = new SiteStatusIssue()
{
FailedTaskDescription = "",
Implications = "",
ProbableCause = "",
Exception = null
};
var result = "";
using (var writer = new StringWriter())
{
serializer.Serialize(writer, new List<SiteStatusIssue>() { issue });
result = serializer.ToString();
}
}
示例3: Process
public override void Process(TList<EmailMessage> list)
{
if (list != null)
{
foreach (EmailMessage message in list)
{
message.NumberOfRetry = message.NumberOfRetry + 1;
// put the message in queue again if maximum retry not exceeded
if (message.NumberOfRetry < message.MaximumRetry)
{
string xml = "";
using (MemoryStream stream = new MemoryStream())
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(message.GetType());
x.Serialize(stream, message);
xml = ConvertByteArrayToString(stream.ToArray());
}
string sql =
string.Format(@"DECLARE @dialog_handle UNIQUEIDENTIFIER;
BEGIN DIALOG CONVERSATION @dialog_handle
FROM SERVICE [SMEPostingService]
TO SERVICE 'SMEService'
ON CONTRACT [SMEContract] ;
-- Send message on dialog conversation
SEND ON CONVERSATION @dialog_handle
MESSAGE TYPE [SMEMessageType]
('{0}') ;
End Conversation @dialog_handle
With cleanup", xml);
string connectionString = ConfigurationManager.ConnectionStrings["SmartMassEmailConnectionString2005"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = null;
try
{
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.Transaction = conn.BeginTransaction();
cmd.ExecuteNonQuery();
cmd.Transaction.Commit();
conn.Close();
}
catch (Exception x)
{
if (conn != null)
{
if (cmd != null)
{
if (cmd.Transaction != null)
cmd.Transaction.Rollback();
}
if (conn.State == System.Data.ConnectionState.Open)
conn.Close();
}
EntLibHelper.ErrorLog(x.ToString(), null);
}
}
}
}
}