コード例 #1
0
        public static MongoDatabase Pool(string keys)
        {
            if (keys.IsNullEmpty())
            {
                keys = "";
            }
            string[] _keys = keys.ToLower().Split(';');
            if (pool.Count == 0)
            {
                Pool();
            }
            string _key = _keys[0];

            if (_keys.Length == 1)
            {
                if (pool.ContainsKey(_key))
                {
                    return(pool[_key]);
                }
            }
            else
            {
                _key = _keys[Rand.RndInt(0, _keys.Length)];
                if (pool.ContainsKey(_key))
                {
                    return(pool[_key]);
                }
            }
            return(Pool());
        }
コード例 #2
0
 /// <summary>
 /// ɾ³ý»º´æ
 /// </summary>
 /// <param name="key">»º´æ¼üÃû</param>
 public void Remove(string key)
 {
     if (cacheList.ContainsKey(key))
     {
         cacheList.Remove(key);
     }
 }
コード例 #3
0
 public static MongodbDatabase Pool(string key)
 {
     key = key.ToLower();
     if (pool.ContainsKey(key))
     {
         return(pool[key]);
     }
     return(Pool());
 }
コード例 #4
0
 /// <summary>
 /// 将对像的属性CACHE
 /// </summary>
 /// <param name="type">Type扩展</param>
 /// <returns></returns>
 public static PropertyInfo[] GetPropertiesCache(this Type type)
 {
     if (!t_cache2.ContainsKey(type))
     {
         PropertyInfo[] value = type.GetProperties();
         t_cache2[type] = value;
         return(value);
     }
     return(t_cache2[type]);
 }
コード例 #5
0
 /// <summary>
 /// 取语言
 /// </summary>
 /// <param name="key">key</param>
 /// <returns></returns>
 public string GetLang(string key)
 {
     if (!langList.ContainsKey(lang))
     {
         langList[lang] = GetLang();
     }
     if (!langList[lang].ContainsKey(key))
     {
         return(string.Empty);
     }
     return(langList[lang][key]);
 }
コード例 #6
0
 /// <summary>
 /// 将对像的属性CACHE
 /// </summary>
 /// <param name="type">Type扩展</param>
 /// <param name="propertyName">属性</param>
 /// <returns></returns>
 public static PropertyInfo GetPropertyCache(this Type type, string propertyName)
 {
     if (!t_cache.ContainsKey(type))
     {
         t_cache[type] = new Dictionary <string, PropertyInfo>();
     }
     if (!t_cache[type].ContainsKey(propertyName))
     {
         PropertyInfo value = type.GetProperty(propertyName);
         t_cache[type][propertyName] = value;
         return(value);
     }
     return(t_cache[type][propertyName]);
 }
コード例 #7
0
ファイル: TaskTimer.cs プロジェクト: AdvanceEnemy/pub.class
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task">任务</param>
        public static void AddTask(TaskInfo task)
        {
            if (tasksInfo.ContainsKey(task.Class))
            {
                RemoveTask(task.Class);
            }

            Timer  timer  = new Timer(true);
            Action action = () => SingletonAddIn <IPlugin> .Instance(task.Class + "," + task.Assembly).Main(task.Parameter);

            if (task.Interval > 0)
            {
                timer.Start(action, task.Interval, task.Degree);
            }
            if (!task.HHmm.IsNullEmpty())
            {
                timer.Start(action, task.HHmm, task.Degree, task.Format);
            }
            if (!tasksInfo.ContainsKey(task.Class))
            {
                tasksInfo.Add(task.Class, timer);
            }
        }
コード例 #8
0
ファイル: WebService.cs プロジェクト: AdvanceEnemy/pub.class
        /// <summary>
        /// GetWsProxyType 获取目标Web服务对应的代理类型 CACHE
        /// </summary>
        /// <param name="wsUrl">目标Web服务的url</param>
        /// <param name="classname">Web服务的class名称,如果不需要指定,则传入null</param>
        /// <returns>Type</returns>
        public static Type GetWsProxyType(string wsUrl, string classname)
        {
            string @namespace = "Pub.Class.WebServiceHelper.DynamicWebCalling";

            if ((classname.IsNull()) || (classname == ""))
            {
                classname = GetWsClassName(wsUrl);
            }
            string cacheKey = wsUrl + "@" + classname;

            if (WSProxyTypeDictionary.ContainsKey(cacheKey))
            {
                return(WSProxyTypeDictionary[cacheKey]);
            }


            //获取WSDL
            WebClient                  wc     = new WebClient();
            Stream                     stream = wc.OpenRead(wsUrl + "?WSDL");
            ServiceDescription         sd     = ServiceDescription.Read(stream);
            ServiceDescriptionImporter sdi    = new ServiceDescriptionImporter();

            sdi.AddServiceDescription(sd, "", "");
            CodeNamespace cn = new CodeNamespace(@namespace);

            //生成客户端代理类代码
            CodeCompileUnit ccu = new CodeCompileUnit();

            ccu.Namespaces.Add(cn);
            sdi.Import(cn, ccu);
            CSharpCodeProvider csc = new CSharpCodeProvider();
            ICodeCompiler      icc = csc.CreateCompiler();

            //设定编译参数
            CompilerParameters cplist = new CompilerParameters();

            cplist.GenerateExecutable = false;
            cplist.GenerateInMemory   = true;
            cplist.ReferencedAssemblies.Add("System.dll");
            cplist.ReferencedAssemblies.Add("System.XML.dll");
            cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
            cplist.ReferencedAssemblies.Add("System.Data.dll");

            //编译代理类
            CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);

            if (true == cr.Errors.HasErrors)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                {
                    sb.Append(ce.ToString());
                    sb.Append(System.Environment.NewLine);
                }
                throw new Exception(sb.ToString());
            }

            //生成代理实例,并调用方法
            System.Reflection.Assembly assembly = cr.CompiledAssembly;
            Type wsProxyType = assembly.GetType(@namespace + "." + classname, true, true);

            if (!WSProxyTypeDictionary.ContainsKey(cacheKey))
            {
                WSProxyTypeDictionary.Add(cacheKey, wsProxyType);
            }
            return(wsProxyType);
        }
コード例 #9
0
 public bool Contains(Type type)
 {
     return(services.ContainsKey(type));
 }