Dev2.Workspaces.WorkspaceItem.ToXml C# (CSharp) Method

ToXml() public method

Gets the XML representation of this instance.
public ToXml ( ) : System.Xml.Linq.XElement
return System.Xml.Linq.XElement
        public virtual XElement ToXml()
        {
            var result = new XElement("WorkspaceItem",
                new XAttribute("ID", ID),
                new XAttribute("WorkspaceID", WorkspaceID),
                new XAttribute("ServerID", ServerID),
                new XAttribute("EnvironmentID", EnvironmentID),
                new XAttribute("Action", Action),
                new XAttribute("ServiceName", ServiceName ?? string.Empty),
                new XAttribute("IsWorkflowSaved", IsWorkflowSaved),
                new XAttribute("ServiceType", ServiceType ?? string.Empty)
                );
            return result;
        }

Usage Example

 public void WorkspaceItem_UnitTest_ConstructorWhereParametersXML_ObjectHasProperties()
 {
     //------------Setup for test--------------------------
     Guid workspaceID = Guid.NewGuid();
     Guid resourceID = Guid.NewGuid();
     Guid environmentID = Guid.NewGuid();
     Guid serverID = Guid.NewGuid();
     WorkspaceItem workspaceItem = new WorkspaceItem(workspaceID, serverID, environmentID, resourceID);
     workspaceItem.IsWorkflowSaved = true;
     XElement xElement = workspaceItem.ToXml();
     //------------Execute Test---------------------------
     WorkspaceItem newWorkspaceItem = new WorkspaceItem(xElement);
     //------------Assert Results-------------------------
     Assert.AreEqual(workspaceID, newWorkspaceItem.WorkspaceID);
     Assert.AreEqual(serverID, newWorkspaceItem.ServerID);
     Assert.AreEqual(environmentID, newWorkspaceItem.EnvironmentID);
     Assert.IsTrue(newWorkspaceItem.IsWorkflowSaved);
 }
All Usage Examples Of Dev2.Workspaces.WorkspaceItem::ToXml