当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.Configure方法代码示例

本文整理汇总了C#中Configuration.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Configure方法的具体用法?C# Configuration.Configure怎么用?C# Configuration.Configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration.Configure方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDefaultConfiguration

		/// <summary>
		/// Standar Configuration for tests.
		/// </summary>
		/// <returns>The configuration using merge between App.Config and hibernate.cfg.xml if present.</returns>
		public static Configuration GetDefaultConfiguration()
		{
			Configuration result = new Configuration();
			if (hibernateConfigFile != null)
				result.Configure(hibernateConfigFile);
			return result;
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:11,代码来源:TestConfigurationHelper.cs

示例2: BuildSessionFactory

        /// <summary>
        /// Builds the session factory.
        /// </summary>
        /// <param name="sources">The <see cref="IEnumerable{T}"/> of <see cref="System.Reflection.Assembly"/> sources.</param>
        /// <param name="configurationFile">The configuration file.</param>
        public static void BuildSessionFactory(IEnumerable<Assembly> sources, string configurationFile = null)
        {
            if (Factory != null)
            {
                return;
            }

            Log.Info("Building SessionFactory");
            
            lock (lck)
            {
                Configuration = new Configuration();
                Configuration.Configure(configurationFile ?? CreateConfigurationFile());

                Factory = Fluently.Configure(Configuration).Mappings(m =>
                {
                    foreach (var assembly in sources)
                    {
                        Log.Info(x => x("Adding Mappings from assembly: {0}", assembly.FullName));
                        m.FluentMappings.AddFromAssembly(assembly);
                    }
                })
                .ExposeConfiguration(xConf => xConf.SetListener(global::NHibernate.Event.ListenerType.Delete, new DeleteEventListener()))
                .BuildSessionFactory();
            }
        }
开发者ID:ghorsey,项目名称:SHHH.Infrastructure.NHibernate,代码行数:31,代码来源:SessionSource.cs

示例3: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration configuration = new Configuration();
        configuration.Configure();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none");
        configuration.AddAssembly(typeof(Categoria).Assembly);

        new SchemaExport(configuration).Execute(true, false, false);

        ISessionFactory sessionFactory = configuration.BuildSessionFactory();

        //updateCategoria(sessionFactory);

        //insertCategoria(sessionFactory);

        //loadArticulo(sessionFactory);

        ISession session = sessionFactory.OpenSession();
        ICriteria criteria = session.CreateCriteria(typeof(Articulo));
        criteria.SetFetchMode("Categoria", FetchMode.Join);
        IList  list = criteria.List();
        foreach (Articulo articulo in list)
            Console.WriteLine("Articulo Id={0} Nombre={1} Precio={2} Categoria={3}",
                              articulo.Id, articulo.Nombre, articulo.Precio, articulo.Categoria);

        session.Close();

        sessionFactory.Close();
    }
开发者ID:KevinSotomayor,项目名称:AD,代码行数:32,代码来源:MainWindow.cs

示例4: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration configuration = new Configuration();
        configuration.Configure ();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none");
        configuration.AddAssembly(typeof(Categoria).Assembly);

        ISessionFactory sessionFactory = configuration.BuildSessionFactory();

        updateCategoria(sessionFactory);
        insertCategoria(sessionFactory);
        //new SchemaExport(configuration).Execute(true, false, false);

        /*ISession session = sessionFactory.OpenSession();
        Categoria categoria = (Categoria)session.Load(typeof(Categoria), 2L);
        Console.WriteLine("Categoria Id={0} Nombre={1}", categoria.Id, categoria.Nombre);
        categoria.Nombre = DateTime.Now.ToString ();
        session.SaveOrUpdate (categoria);
        session.Flush ();
        session.Close ();*/

        try{
        ISession session = sessionFactory.OpenSession();
        ICriteria criteria = session.CreateCriteria (typeof(/*Categoria*/articulo));
        IconList list = criteria.List ();
            foreach(/*Categoria categoria*/Articulo articulo in list)
                Console.WriteLine ("Articulo Id={0} Nombre={1} Precio{2}",/*categoria*/articulo.Id, /*categoria*/articulo.Nombre, articulo.Precio);
        }finally{
            sessionFactory.Close();
        }
        sessionFactory.Close ();
    }
开发者ID:AntonioAlvarez,项目名称:ad,代码行数:35,代码来源:MainWindow.cs

示例5: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        //http://darioquintana.com.ar/articles/tutorial-de-nhibernate-primeros-pasos
        //http://nhforge.org/doc/nh/en/index.html

        //Clase configuration de NHibernate
        Configuration configuration = new Configuration();
        configuration.Configure();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none");

        configuration.AddAssembly(typeof(Categoria).Assembly);

        /*new SchemaExport(configuration).execute(true,false,false);*/

        //Se encarga crear sesiones en nuestra aplicacion.
        ISessionFactory sessionFactory = configuration.BuildSessionFactory ();

        ISession session = sessionFactory.OpenSession();
        ICriteria criteria = session.CreateCriteria (typeof(Articulo));
        criteria.SetFetchMode("Categoria", FetchMode.Join);
        IList list = criteria.List();
            foreach (Articulo articulo in list)
                Console.WriteLine("Articulo Id={0} Nombre={1} Precio={2} Categoria={3}",
                articulo.Id, articulo.Nombre, articulo.Precio, articulo.Categoria);

            session.Close ();
    }
开发者ID:daalol,项目名称:ad,代码行数:29,代码来源:MainWindow.cs

示例6: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration configuration = new Configuration();
        configuration.Configure ();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none");
        configuration.AddAssembly(typeof(Categoria).Assembly);

        new SchemaExport(configuration).Execute(true, false, false);

        ISessionFactory sessionFactory = configuration.BuildSessionFactory ();

        //insertCategoria(sessionFactory);

        using (ISession session = sessionFactory.OpenSession()) {
            ICriteria criteria = session.CreateCriteria(typeof(Categoria));
            IList list = criteria.List();

            foreach (Categoria categoria in list) {
                Console.WriteLine("Categoria Id={0} Nombre={1}", categoria.Id, categoria.Nombre);
            }
        }

        sessionFactory.Close();
    }
开发者ID:borjadam,项目名称:ad,代码行数:27,代码来源:MainWindow.cs

示例7: NHibernateSession

    public NHibernateSession()
    {
        Assembly assembly = typeof(NHibernateSession).Assembly;
        configuration = new Configuration();
        configuration.Configure();
        configuration.AddAssembly(assembly);

        factory = configuration.BuildSessionFactory();
    }
开发者ID:wolverine169,项目名称:BikeWareHouse,代码行数:9,代码来源:NHibernateSession.cs

示例8: init

    public void init()
    {
        cfg = new Configuration();
        cfg.Configure();

        /* Add xml mappings created manually
         * - Because Web Site projects are only compiled during runtime, the hibernate mapping files will need to
         * be discovered and added to the assembly at runtime.
         */
        cfg.AddDirectory(new DirectoryInfo(HttpContext.Current.Server.MapPath("~/Mapping")));

        //Add your custom configurations here to override the Hibernate.xml configuration.
    }
开发者ID:hareluya86,项目名称:ProjectPortal,代码行数:13,代码来源:Hibernate.cs

示例9: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration configuration = new Configuration();
        configuration.Configure();
        configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords,"none");
        configuration.AddAssembly(typeof(Categoria).Assembly);
        new SchemaExport(configuration).Execute(true,false,false);

        ISessionFactory sessionFactory=configuration.BuildSessionFactory();

        //	updateCategoria(sessionFactory);

        //insertCategoria(sessionFactory);
         loadArticulo(sessionFactory);

        sessionFactory.Close();
    }
开发者ID:rubenGan,项目名称:AD,代码行数:20,代码来源:MainWindow.cs

示例10: MsSqlDaoFactory

 public MsSqlDaoFactory()
 {
     Configuration config = new Configuration();
     config.Configure();
     this.sessionFactory = config.BuildSessionFactory();
 }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:6,代码来源:MsSqlDaoFactory.cs

示例11: NHSessionManager

 static NHSessionManager()
 {
     try
     {
         Configuration cfg = new Configuration();
         string configFile = @"hibernate.cfg.xml";
         string mappingPath = PathFunctions.GetMappingPath();
         cfg.Configure(Path.Combine(mappingPath, configFile));
         foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
             cfg.AddXmlFile(file);
         factory = cfg.BuildSessionFactory();
     }
     catch(Exception ex)
     {
         Log.Add(ex.ToString());
     }
 }
开发者ID:Maasik,项目名称:mtbscout,代码行数:17,代码来源:DBHelper.cs

示例12: ConfigureNHibernate

        private static Configuration ConfigureNHibernate(string cfgFile, IDictionary<string, string> cfgProperties)
        {
            var cfg = new Configuration();

            if (cfgProperties != null)
            {
                cfg.AddProperties(cfgProperties);
            }

            if (string.IsNullOrEmpty(cfgFile) == false)
            {
                return cfg.Configure(cfgFile);
            }

            if (File.Exists("Hibernate.cfg.xml"))
            {
                return cfg.Configure();
            }

            return cfg;
        }
开发者ID:jongeorge1,项目名称:Sharp-Architecture-Features,代码行数:21,代码来源:NHibernateSession.cs

示例13: NHSessionManager

    static NHSessionManager()
    {
        try
        {
            Configuration cfg = new Configuration();
            string configFile = Helper.IsDevelopment()
                ? @"hibernate.debug.cfg.xml"
                : @"hibernate.cfg.xml";
            string mappingPath = PathFunctions.GetMappingPath();
            cfg.Configure(Path.Combine(mappingPath, configFile));
            foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
                cfg.AddXmlFile(file);
            factory = cfg.BuildSessionFactory();
        }
        catch
        {

        }
    }
开发者ID:jbvios,项目名称:mtbscout,代码行数:19,代码来源:DBHelper.cs


注:本文中的Configuration.Configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。