PaulStovell.TrialBalance.DomainModel.PackageDataProvider.ChangeSetHistoryXElementAdapter.ToXElement C# (CSharp) Метод

ToXElement() публичный Метод

Converts a given ChangeSetHistory into an T:XElement.
public ToXElement ( ChangeSetHistory changeSetHistory ) : XElement
changeSetHistory ChangeSetHistory The to convert.
Результат XElement
        public XElement ToXElement(ChangeSetHistory changeSetHistory)
        {
            XElement historyElement = new XElement("ChangeSetHistory");
            foreach (ChangeSet changeSet in changeSetHistory) {
                XElement changeSetElement = new XElement("ChangeSet",
                    new XElement("Applied", changeSet.Applied),
                    new XElement("Username", changeSet.Username));
                foreach (Change change in changeSet.Changes) {
                    XElement changeElement = new XElement("Change",
                        new XElement("PropertyName", change.PropertyName),
                        new XElement("OldValue", change.OldValue),
                        new XElement("NewValue", change.NewValue));
                    changeSetElement.Add(changeElement);
                }
                historyElement.Add(changeSetElement);
            }
            return historyElement;
        }

Usage Example

        /// <summary>
        /// Converts a given <see cref="Account"/> into an <see cref="T:XElement"/>.
        /// </summary>
        /// <param name="account">The <see cref="Account"/> to convert.</param>
        /// <returns>The newly created <see cref="T:XElement"/>.</returns>
        public XElement ToXElement(Account account)
        {
            XElement element = new XElement(account.AccountType.ToString());
            element.Add(new XElement("AccountID", account.AccountID));
            element.Add(new XElement("CreatedByUsername", account.CreatedByUsername));
            element.Add(new XElement("CreatedDate", account.CreatedDate));
            element.Add(new XElement("Description", account.Description));
            element.Add(new XElement("Name", account.Name));
            element.Add(new XElement("UpdatedByUsername", account.UpdatedByUsername));
            element.Add(new XElement("UpdatedDate", account.UpdatedDate));

            // Append the change history
            ChangeSetHistoryXElementAdapter adapter = new ChangeSetHistoryXElementAdapter();
            element.Add(adapter.ToXElement(account.ChangeSetHistory));

            return element;
        }
All Usage Examples Of PaulStovell.TrialBalance.DomainModel.PackageDataProvider.ChangeSetHistoryXElementAdapter::ToXElement
ChangeSetHistoryXElementAdapter