Example #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);
        }
Example #2
0
        /// <summary>
        /// 从缓存中获得描述信息
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static DescriptionModel GetDescriptionFromCache(Type t)
        {
            var description = DescriptionModelCacheManager.Get(t.Assembly.FullName);

            if (description == null)
            {
                description = ResolverHelper.LoadDescription(t.Assembly);
            }

            return(description);
        }