當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。