当前位置: 首页>>代码示例>>C#>>正文


C# XmlSerializer.ToString方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:iinteractive,项目名称:site-status,代码行数:28,代码来源:SiteStatusIssueTests.cs

示例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();
            }
        }
开发者ID:iinteractive,项目名称:site-status,代码行数:18,代码来源:SiteStatusIssueTests.cs

示例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);
                        }
                    }
                }
            }
                                
            
			
		}
开发者ID:chibuk,项目名称:krooe,代码行数:70,代码来源:Sql2005ProcessFailureProvider.cs


注:本文中的System.Xml.Serialization.XmlSerializer.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。