Exemplo n.º 1
0
        /// <summary>
        /// Get element documentation
        /// </summary>
        public static string GetElementDocumentation(Type type, MetaDataElementType docType = MetaDataElementType.Summary)
        {
            var docName   = $"T:{type.FullName}";
            var cacheName = $"{docName}@{docType}";
            var retVal    = type.GetCustomAttribute <DescriptionAttribute>()?.Description;

            if (String.IsNullOrEmpty(retVal) && !s_documentationCache.TryGetValue(cacheName, out retVal)) // Attempt to load the documentation from disk
            {
                retVal = GetElementDocumentation(type.Assembly, docName, docType.ToString().ToLower());
                lock (s_documentationCache)
                    if (!s_documentationCache.ContainsKey(cacheName))
                    {
                        s_documentationCache.Add(cacheName, retVal);
                    }
            }
            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get element documentation
        /// </summary>
        public static string GetElementDocumentation(MethodInfo method, MetaDataElementType docType = MetaDataElementType.Summary)
        {
            var docName   = $"M:{method.DeclaringType.FullName}.{method.Name}({String.Join(",", method.GetParameters().Select(o=>o.ParameterType.FullName))})";
            var cacheName = $"{docName}@{docType}";
            var retVal    = method.GetCustomAttribute <DescriptionAttribute>()?.Description;

            if (String.IsNullOrEmpty(retVal) && !s_documentationCache.TryGetValue(cacheName, out retVal)) // Attempt to load the documentation from disk
            {
                retVal = GetElementDocumentation(method.DeclaringType.Assembly, docName, docType.ToString().ToLower());
                lock (s_documentationCache)
                    if (!s_documentationCache.ContainsKey(cacheName))
                    {
                        s_documentationCache.Add(cacheName, retVal);
                    }
            }
            return(retVal);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get element documentation
        /// </summary>
        public static string GetElementDocumentation(PropertyInfo property, MetaDataElementType docType = MetaDataElementType.Summary)
        {
            var declType = property.DeclaringType.FullName;

            if (property.DeclaringType.IsGenericType)
            {
                declType = declType.Substring(0, declType.IndexOf("["));
            }
            var docName   = $"P:{declType}.{property.Name}";
            var cacheName = $"{docName}@{docType}";
            var retVal    = property.GetCustomAttribute <DescriptionAttribute>()?.Description;

            if (String.IsNullOrEmpty(retVal) && !s_documentationCache.TryGetValue(cacheName, out retVal)) // Attempt to load the documentation from disk
            {
                retVal = GetElementDocumentation(property.DeclaringType.Assembly, docName, docType.ToString().ToLower());
                lock (s_documentationCache)
                    if (!s_documentationCache.ContainsKey(cacheName))
                    {
                        s_documentationCache.Add(cacheName, retVal);
                    }
            }
            return(retVal);
        }