DF to XML

Initialization:

Ensure that "/files/xml" folder has appropriate read/write permissions. Tables will be created automatically if they do not exist.

using Microsoft.Practices.Unity;
using Fuse8.DomainFramework.Common.Locator;
using Fuse8.DomainFramework.DataAccess.XmlDatabase;
using Fuse8.DomainFramework.UnityLocator;

public class MvcApplication : HttpApplication
{
    protected void Application_Start()
    {
        IUnityContainer container = new UnityContainer();
        var locator = new UnityServiceLocatorWithLazy(container);
        DependencyServiceLocator.SetLocatorProvider(() => locator);

        XmlDatabaseConfiguration.XmlDBPath = HttpContext.Current.Server.MapPath("~/files/xml");

        container.RegisterInstance<IEntityDataRepository<ContentEntity, string>>(new XmlEntityDataRepository<ContentEntity, string>());
    }
}

Domain entity

public class ContentEntity : Int32EntityObject
{
	public string Summary { get; set; }
	public string Description { get; set; }
}

XML file

<?xml version="1.0" encoding="utf-8"?>
<XmlFileDBEntryOfContentEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Entries>
    <ContentEntity>
      <Id>123</Id>
      <Summary>Lorem</Summary>
      <Description>&lt;p&gt;Some description&lt;/p&gt;</Description>
    </ContentEntity>
  </Entries>
</XmlFileDBEntryOfContentEntity>

Last edited Apr 1, 2013 at 9:08 AM by olgabutova, version 2

Comments

No comments yet.