示例#1
0
        private static object FindService(ServiceModule.SvcModule module, string user)
        {
            var key = BuildKey(module, user);

            //todo 丢弃缓存权限数据


            return(CreatedServices[key]);
            // return CreatedServices.Contains(key) ? CreatedServices[key] : null;
        }
示例#2
0
        private static string ObjIdByModule(ServiceModule.SvcModule module)
        {
            switch (module)
            {
            case ServiceModule.SvcModule.EastMoneyMain:
                return("EastMoneyMain");

            case ServiceModule.SvcModule.EastMoneyImp:
                return("EastMoneyImp");

            default:
                return(null);
            }
        }
示例#3
0
        private static void CacheService(ServiceModule.SvcModule module, string user, object svc)
        {
            var key = BuildKey(module, user);

            if (!CreatedServices.ContainsKey(key))
            {
                lock (CreatedServices)
                {
                    if (!CreatedServices.ContainsKey(key))
                    {
                        CreatedServices.Add(key, svc);
                    }
                }
            }
        }
示例#4
0
        private static object CreateEnergyService(ServiceModule.SvcModule module, string user)
        {
            var svc = FindService(module, user);

            if (svc == null)
            {
                var objId = ObjIdByModule(module);
                svc = ContextRegistry.GetContext()[objId];
                if (svc == null)
                {
                    throw new NotImplementedException(); // TODO: declare our own exceptions
                }

                CacheService(module, user, svc);
            }

            return(svc);
        }
示例#5
0
 private static string BuildKey(ServiceModule.SvcModule module, string user)
 {
     return(module + user);
 }
示例#6
0
        /// <summary>
        /// 获取spring注册对象工厂
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static T GetServiceImp <T>(ServiceModule.SvcModule svcModule)
        {
            string user = svcModule.GetDefaultValue();

            return((T)CreateEnergyService(svcModule, user));
        }