namespace ServiceCenter.Data.CastleActiveRecord
{
    #region Using
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;

    using Castle.ActiveRecord;
    using Castle.ActiveRecord.Framework;
    using Castle.ActiveRecord.Framework.Config;
    #endregion

    public static class DataService
    {
        public static void Initialize()
        {
            //Dictionary<string, string> properties = new Dictionary<string, string>();

            //properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
            //properties.Add("dialect", "NHibernate.Dialect.MsSql2000Dialect");
            //properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            //properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle");
            //properties.Add("connection.connection_string", System.Configuration.ConfigurationManager.ConnectionStrings["ServiceCenter"].ConnectionString);

            //InPlaceConfigurationSource source = new InPlaceConfigurationSource();
            //source.DefaultFlushType = DefaultFlushType.Auto;
            //source.IsRunningInWebApp = true;
            //source.PluralizeTableNames = false;
            //source.VerifyModelsAgainstDBSchema = true;
            //source.Add(typeof(ActiveRecordBase), properties);


            XmlConfigurationSource source = new XmlConfigurationSource(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase), "source.xml"));
            source.DefaultFlushType = DefaultFlushType.Auto;
            source.VerifyModelsAgainstDBSchema = true;

            ActiveRecordStarter.Initialize(source, typeof(DeviceType), typeof(Employee), typeof(Manufacturer), typeof(Position), typeof(Request), typeof(Status));
        }
    }
}
