Dev2.Runtime.ServiceModel.Data.DbSource.ToXml C# (CSharp) Method

ToXml() public method

public ToXml ( ) : System.Xml.Linq.XElement
return System.Xml.Linq.XElement
        public override XElement ToXml()
        {
            var result = base.ToXml();
            result.Add(new XAttribute("ServerType", ServerType));
            result.Add(new XAttribute("Type", ServerType));
            result.Add(new XAttribute("ConnectionString", DpapiWrapper.Encrypt(ConnectionString) ?? string.Empty));

            result.Add(new XElement("AuthorRoles", string.Empty));
            result.Add(new XElement("Comment", string.Empty));
            result.Add(new XElement("HelpLink", string.Empty));
            result.Add(new XElement("Tags", string.Empty));
            result.Add(new XElement("UnitTestTargetWorkflowService", string.Empty));
            result.Add(new XElement("BizRule", string.Empty));
            result.Add(new XElement("WorkflowActivityDef", string.Empty));
            return result;
        }

Usage Example

        public void ToXmlEmptyObjectExpectedXElementContainingNoInformationRegardingSource()
        {
            var testDbSource = new DbSource();
            XElement expectedXml = testDbSource.ToXml();

            IEnumerable<XAttribute> attrib = expectedXml.Attributes();
            IEnumerator<XAttribute> attribEnum = attrib.GetEnumerator();
            while(attribEnum.MoveNext())
            {
                if(attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }