Ejemplo n.º 1
0
        /// <summary>
        /// 加载注释
        /// </summary>
        /// <param name="ass"></param>
        /// <returns></returns>
        public static DescriptionModel LoadDescription(Assembly ass)
        {
            DescriptionModel model = null;
            var path                = ass.Location;
            var fullname            = ass.FullName;
            var dllname             = fullname.Split(',')[0].Trim();
            var descriptionFileName = string.Format("{0}.xml", path.Remove(path.Length - 4, 4));

            if (!File.Exists(descriptionFileName))
            {
                path = AppDomain.CurrentDomain.BaseDirectory;
                descriptionFileName = string.Format("{0}\\{1}.xml", path.TrimEnd('\\'), dllname);
                if (!File.Exists(descriptionFileName))
                {
                    path += "bin";
                    descriptionFileName = string.Format("{0}\\{1}.xml", path.TrimEnd('\\'), dllname);
                    if (!File.Exists(descriptionFileName))
                    {
                        return(null);
                    }
                }
            }
            string xml = File.ReadAllText(descriptionFileName);

            try
            {
                model = XMLHelper.Deserialize <DescriptionModel>(xml);
                DescriptionModelCacheManager.Set(fullname, model);
            }
            catch (Exception ex)
            {
            }
            return(model);
        }
Ejemplo n.º 2
0
        public static void Set(string key, DescriptionModel t)
        {
            CacheManager <DescriptionModel> manager = new CacheManager <DescriptionModel>(_key);

            manager.SetItem(key, t);
        }