Software-Develop-Web

使用 HTTP 上下文的Wen场景,以及使用 桌面的客户端。 NHibernate 框架的使用

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5
 6 using NHibernate;
 7 using NHibernate.Cfg;
 8 using System.Web;
 9
10 namespace Agathas.Storefront.Repository.NHibernate.SessionStorage
11 {
12     /// <summary>
13     /// (在实现了保存会话的功能后)需要某种方式来创建会话。
14     /// 能够使用 NHibernate 来持久化和检索业务实体。
15     /// </summary>
16     public class SessionFactory
17     {
18         // NHibernate.ISessionFactory 由会话工厂来创建
19         private static ISessionFactory _sessionFactory;
20
21         // 初始化
22
23         public static void Init()
24         {
25             // 创建实例及配置组装
26             Configuration config = new Configuration();
27             config.AddAssembly("Agatha.Storefront.Repository.NHibernate");
28
29             // 日志 log4net
30             log4net.Config.XmlConfigurator.Configure();
31
32             // 实施配置
33             config.Configure();
34
35             // 获取会话工厂
36             _sessionFactory = config.BuildSessionFactory();
37         }
38
39         // 获取会话工厂
40         private static ISessionFactory GetSessionFactory()
41         {
42             if (_sessionFactory == null)
43                 Init();
44
45             return _sessionFactory;
46         }
47
48         private static ISession GetNewSession()
49         {
50             return GetSessionFactory().OpenSession();
51         }
52
53         public static ISession GetCurrentSession()
54         {
55             ISessionStorageContainer sessionStorageContainer =
56                 SessionStorageFactory.GetSessionStorageContainer();
57
58             ISession currenSession = sessionStorageContainer.GetCurrentSession();
59
60             if (currenSession == null)
61             {
62                 currenSession = GetNewSession();
63                 sessionStorageContainer.Store(currenSession);
64             }
65
66             return currenSession;
67         }
68
69     }
70 }

时间: 2024-11-16 08:41:18

Software-Develop-Web的相关文章

Example: Develop Web application on Baidu App Engine using CherryPy

In the past few months, I have developed two simple applications on Baidu App Engine. Compared to Google App Engine, or Nitrous.Io, the documentation of BAE is really not good enough. The only advantage of BAE is stable - you needn't to worry about G

nios ii software develop handbook

1.The Nios II processor’s JTAG debug module provides a single, consistent method to connect to the processor using a JTAG download cable. 2. Altera BSPs contain the Altera hardware abstraction layer (HAL), an optional RTOS, and device drivers. 3.The

微软职位内部推荐-Senior Software Engineer -Web

微软近期Open的职位: Location: Beijing, China The Office App Services team is working on the powerful Office Web Apps including Word Web App, PowerPoint Web App and Web App Engineering Infrastructure. We deliver great cloud experience for Office products, wh

Using mongo in django to develop web app with python

1. install mongoengine 2. demo with html page and the model operations Links: 1. https://github.com/xhan-shannon/django_mongo_demo 2. https://www.ibm.com/developerworks/cn/opensource/os-django-mongo/index.html

web服务器tomcat入门

一.tomcat介绍1.1 引入tomcat Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache.Sun 和其他一些公司及个人共同开发而成.由于有了Sun 的参与和支持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5支持最新的Servlet 2.4 和JSP 2.0 规范.因为Tomcat 技术先进.性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部

Claim-based-security for ASP.NET Web APIs using DotNetOpenAuth

Recently I worked with a customer assisting them in implementing their Web APIs using the new ASP.NET Web API framework. Their API would be public so obviously security came up as the key concern to address. Claims-Based-Security is widely used in SO

How to activate MB Star Diagnostic Tool Xentry Develop Mode

With Developer Mode you can do irreversible setting changes like deploy airbags, reset SBC program Tire size along with Rims and sizes, disable seat belt chime etc. How to open / activate Mercedes Benz MB Star Diagnostic multiplexer Xentry Develop mo

《Hexo+github搭建个人博客》

<Hexo+github搭建个人博客> 文/冯皓林 完稿:2016.4.22-2016.4.23 注意:本节教程只针对Windows用户.本教程由无人赞助,赞助写出. <Hexo+github搭建个人博客>1 思维导图总览:2 What?2 简介:2 Hexo:2 NodeJs2 Github4 Git5 Github page:5 Markdown6 How?7 环境配置:7 安装Git8 安装Node.js9 安装hexo13 第一步:打开cmd.13 第二步:进入NodeJS

Java入门-第2篇

第一个Java程序 package com.java24hours; //这一行告诉计算机将程序的包名称命名为com.java24hours class Saluton{                   //这句话意思是请将我的Java程序命名为Saluton public static void main(string[] arguments){  //这句话是告诉计算机:程序的主要部分从这里开始 //My first Java program goes here } } 运行该程序之前必

PHP开发调试环境配置

——基于wamp和Eclipse for PHP Developers 引言 为了搭建PHP开发调试环境,我曾经在网上查阅了无数的资料,但没有一种真正能够行的通的.因为PHP开发环境需要很多种软件相互配合,软件之间版本必须相互匹配,而具体到底怎么个匹配法也很难说,至于最新版本的软件之间相互匹配就更加缺少相应的资料了.哪怕版本之间有细微的版本不匹配情况,最后的结果都会是徒劳无功. 不过,通过不懈的坚持和努力,在失败了一次又一次之后,终于在凌晨1点半将PHP开发调试环境全部搭建完毕,看到运行网页后,