Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Remoting.Messaging;
- using System.Web;
- using EAbs.Common.DB;
- namespace EAbs.Web
- {
- public static class UnitOfWorkStore
- {
- public static object GetData(string key)
- {
- //if (HttpContext.Current != null)
- return HttpContext.Current.Items[key];
- //return CallContext.GetData(key);
- }
- public static void SetData(string key, object data)
- {
- //if (HttpContext.Current != null)
- HttpContext.Current.Items[key] = data;
- //else
- // CallContext.SetData(key, data);
- }
- }
- public class DBContextWrapper
- {
- private static readonly string UOW_INSTANCE_KEY = "ConfigContext_Instance";
- private static readonly object _objSync = new object();
- private readonly ConfigContext _context;
- private DBContextWrapper()
- {
- _context = new ConfigContext();
- }
- public ConfigContext Context
- {
- get { return _context; }
- }
- public static DBContextWrapper Instance
- {
- get
- {
- object instance = UnitOfWorkStore.GetData(UOW_INSTANCE_KEY);
- if (instance == null)
- {
- lock (_objSync)
- {
- if (instance == null)
- {
- instance = new DBContextWrapper();
- UnitOfWorkStore.SetData(UOW_INSTANCE_KEY, instance);
- }
- }
- }
- return (DBContextWrapper)instance;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement