Esempio n. 1
0
        /// <summary>
        /// 获取程序集信息
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        private unsafe static XmlDocumentAssembly get(Assembly assembly)
        {
            if (assembly != null)
            {
                XmlDocumentAssembly value;
                if (assemblyLock.TryGetValue(assembly, out value))
                {
                    return(value);
                }
                try
                {
                    string fileName = assembly.Location;
                    if (fileName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        if (File.Exists(fileName = fileName.Substring(0, fileName.Length - 3) + "xml"))
                        {
                            Xml.Node xmlNode = AutoCSer.Xml.Parser.Parse <Xml.Node>(File.ReadAllText(fileName, Encoding.UTF8), xmlParserConfig)["members"];
                            if (xmlNode.Type == Xml.NodeType.Node)
                            {
                                fixed(char *nameFixed = "name")
                                {
                                    value = new XmlDocumentAssembly();
                                    Range attribute = default(Range);

                                    foreach (KeyValue <SubString, Xml.Node> node in xmlNode.Nodes)
                                    {
                                        if (node.Value.Type == Xml.NodeType.Node && node.Key.Equals("member"))
                                        {
                                            if (node.Value.GetAttribute(nameFixed, 4, ref attribute) && attribute.Length > 2)
                                            {
                                                value.LoadMember(new SubString {
                                                    String = node.Key.String, Start = attribute.StartIndex, Length = attribute.Length
                                                }, node.Value);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                AutoCSer.Log.Pub.Log.wait(Log.LogType.All, "XML文档解析失败 " + fileName);
                            }
                        }
                        else
                        {
                            AutoCSer.Log.Pub.Log.wait(Log.LogType.All, "没有找到XML文档注释 " + fileName);
                        }
                    }
                    assemblyLock.Set(assembly, value);
                }
                finally { assemblyLock.Exit(); }
                return(value);
            }
            return(null);
        }
Esempio n. 2
0
        public static string Get(Type type)
        {
            XmlDocumentAssembly assembly = get(type.Assembly);

            return(assembly == null ? string.Empty : assembly.GetSummary(type));
        }
Esempio n. 3
0
        public static string Get(MethodInfo method, ParameterInfo parameter)
        {
            XmlDocumentAssembly assembly = get(method.DeclaringType.Assembly);

            return(assembly == null ? string.Empty : assembly.Get(method, parameter));
        }
Esempio n. 4
0
        public static string GetReturn(MethodInfo method)
        {
            XmlDocumentAssembly assembly = get(method.DeclaringType.Assembly);

            return(assembly == null ? string.Empty : assembly.GetReturn(method));
        }
Esempio n. 5
0
        public static string Get(PropertyInfo property)
        {
            XmlDocumentAssembly assembly = get(property.DeclaringType.Assembly);

            return(assembly == null ? string.Empty : assembly.GetSummary(property));
        }
Esempio n. 6
0
        public static string Get(FieldInfo field)
        {
            XmlDocumentAssembly assembly = get(field.DeclaringType.Assembly);

            return(assembly == null ? string.Empty : assembly.GetSummary(field));
        }
Esempio n. 7
0
 internal static HashAssembly GetAssembly(XmlDocumentAssembly value)
 {
     return(value.assembly);
 }