public void XmlDeserializePerson()
        {
            var jalalx = Person.GetJalalx();
            var stream = new System.IO.MemoryStream();

            jalalx.XmlSerialize <Person>(stream);

            var newJalalx = stream.XmlDeserialize <Person>();

            Assert.AreEqual(jalalx, newJalalx);
        }
Exemple #2
0
        private void DisplayDataObject(String textHeader, IDataObject dataObject)
        {
            string[] formats = dataObject.GetFormats();
            normalText.Remove(0, normalText.Length);
            richText.Remove(0, richText.Length);
            xmlText.Remove(0, xmlText.Length);
            normalText.Append(textHeader);
            bool   isDataPresent;
            object data;
            string dataString;

            foreach (string format in formats)
            {
                try
                {
                    isDataPresent = dataObject.GetDataPresent(format);
                    // ???mért nem tudja konvertálni az enhanced metafile-t????
                    if (isDataPresent && !DenyList.Contains(format) && (data = dataObject.GetData(format)) != null)
                    {
                        dataString = data.ToString();
                        normalText.Append(format + ": " + dataString + "\r\n");

                        switch (dataString)
                        {
                        case "System.IO.MemoryStream":
                        {
                            System.IO.MemoryStream ms = (System.IO.MemoryStream)data;
                            int  b;
                            long position = ms.Position;
                            b           = DisplayMemory(normalText, ms);
                            ms.Position = position;
                            if (format.ToLower().Contains("xml"))
                            {
                                xmlText.Append(ms.XmlDeserialize <Feed>().ToString());
                            }
                            break;
                        }

                        case "System.String[]":
                        {
                            foreach (string s2 in (System.String[])data)
                            {
                                normalText.Append(s2 + "\r\n");
                            }
                            break;
                        }

                        default:
                        {
                            switch (format)
                            {
                            case "Rich Text Format":
                                normalText.Append(format + ": " + dataString + "\r\n");
                                richText.Append(dataString);
                                break;

                            case "Rich Text Format Without Objects":
                            case "RTF As Text":
                            case "System.String":
                            case "UnicodeText":
                            case "Text":
                                normalText.Append(format + ": " + dataString + "\r\n");
                                break;

                            default:

                                break;
                            }
                            break;
                        }
                        }
                        normalText.Append("\r\n");
                    }
                }
                catch (ExecutionEngineException ex)
                {
                    Forms.MessageBox.Show(String.Format("Cannot get format:{0}", format));
                    normalText.AppendFormat("Cannot get format:{0}", format);
                }
                catch (ExternalException ex)
                {
                    Forms.MessageBox.Show(String.Format("Cannot get format:{0}", format));
                    normalText.AppendFormat("Cannot get format:{0}", format);
                }
                catch (Exception ex)
                {
                    Forms.MessageBox.Show(String.Format("Cannot get format:{0}", format));
                    normalText.AppendFormat("Cannot get format:{0}", format);
                }
            }
            //this.textBox1.Text = "Hello World";
            //textBox1.Text = normalText.ToString();
            //richTextBox1.Rtf = richText.ToString();
            //richTextBox2.Text = xmlText.ToString();
        }