Пример #1
0
        /// <summary>
        /// Parse .Net XML documentation for Indexer data.
        /// </summary>
        /// <param name="memberElement">Expects tag name "member".</param>
        /// <example><![CDATA[<member name="P:Namespace.Type.Item(System.Int32)"></member>]]></example>
        public static new DotNetIndexer FromVisualStudioXml(XElement memberElement)
        {
            string xmlName       = memberElement.GetAttributeValue("name");
            string xmlParameters = xmlName.Substring(xmlName.IndexOf("("));

            xmlName = xmlName.Substring(0, xmlName.IndexOf("("));

            DotNetQualifiedName    name       = DotNetQualifiedName.FromVisualStudioXml(xmlName);
            List <DotNetParameter> parameters = DotNetQualifiedMethodName.ParametersFromVisualStudioXml(xmlParameters);
            DotNetIndexer          indexer    = new DotNetIndexer(name, parameters);

            indexer.ParseVisualStudioXmlDocumentation(memberElement);
            return(indexer);
        }
Пример #2
0
        /// <summary>
        /// Parse .Net XML documentation for Property data.
        /// </summary>
        /// <param name="memberElement">Expects tag name "member".</param>
        /// <example><![CDATA[<member name="P:Namespace.Type.PropertyName"></member>]]></example>
        public static new DotNetProperty FromVisualStudioXml(XElement memberElement)
        {
            string xmlName = memberElement.GetAttributeValue("name");

            if (xmlName.IndexOf("(") > -1)
            {
                return(DotNetIndexer.FromVisualStudioXml(memberElement));
            }

            DotNetQualifiedName name     = DotNetQualifiedName.FromVisualStudioXml(xmlName);
            DotNetProperty      property = new DotNetProperty(name);

            property.ParseVisualStudioXmlDocumentation(memberElement);
            return(property);
        }
Пример #3
0
        /// <summary>
        /// Load additional information from the assembly for this type.
        /// </summary>
        private void AddAssemblyInfo(Type type)
        {
            if (type.Attributes.IsAbstract())
            {
                Category = TypeCategory.Abstract;
            }
            if (type.Attributes.IsStatic())
            {
                Category = TypeCategory.Static;
            }
            if (type.Attributes.IsInterface())
            {
                Category = TypeCategory.Interface;
            }
            if (type.IsEnum())
            {
                Category = TypeCategory.Enum;
            }
            if (type.IsException())
            {
                Category = TypeCategory.Exception;
            }
            if (type.IsValueType && !type.IsEnum())
            {
                Category = TypeCategory.Struct;
            }

            if (Category == TypeCategory.Unknown)
            {
                Category = TypeCategory.Normal;
            }

            IsSealed = type.IsSealed;

            ClassName.AddAssemblyInfo(type);

            if (type.BaseType != null)
            {
                BaseType = new DotNetBaseType(type.BaseType);
            }

            Type[] implementedInterfaces = type.GetInterfaces();
            if (implementedInterfaces != null)
            {
                foreach (Type interfaceType in implementedInterfaces)
                {
                    ImplementedInterfaces.Add(new DotNetBaseType(interfaceType));
                }
            }

            foreach (FieldInfo fieldInfo in type.GetDeclaredFields())
            {
                DotNetField field = Fields.FirstOrDefault(f => fieldInfo.Name == f.Name.LocalName);
                if (field == null)
                {
                    continue;
                }
                field.AddAssemblyInfo(fieldInfo);
            }
            foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() == null || x.GetGetMethod().GetParameters().Count() == 0))
            {
                DotNetProperty property = Properties.FirstOrDefault(p => propertyInfo.Name == DotNetQualifiedName.Combine(p.Name.ExplicitInterface, p.Name.LocalName));
                if (property == null)
                {
                    continue;
                }
                property.AddAssemblyInfo(propertyInfo);
            }
            foreach (PropertyInfo propertyInfo in type.GetDeclaredProperties().Where(x => x.GetGetMethod() != null && x.GetGetMethod().GetParameters().Count() > 0))
            {
                DotNetIndexer indexer = Properties.OfType <DotNetIndexer>().Cast <DotNetIndexer>().FirstOrDefault(i => i.MatchesSignature(propertyInfo.GetGetMethod()));
                if (indexer == null)
                {
                    continue;
                }
                indexer.AddAssemblyInfo(propertyInfo);
            }
            foreach (MethodInfo methodInfo in type.GetDeclaredMethods())
            {
                DotNetMethod method = Methods.FirstOrDefault(m => m.MatchesSignature(methodInfo));
                if (method == null)
                {
                    continue;
                }

                if (methodInfo.Attributes.IsPrivate() && method.Name.ExplicitInterface == null)
                {
                    Methods.Remove(method);
                    continue;
                }

                method.AddAssemblyInfo(methodInfo);
            }
            foreach (ConstructorInfo constructorInfo in type.GetDeclaredConstructors())
            {
                DotNetMethodConstructor method = Methods.OfType <DotNetMethodConstructor>().Cast <DotNetMethodConstructor>().FirstOrDefault(m => m.MatchesArguments(constructorInfo.GetParameters()));
                if (method == null)
                {
                    continue;
                }
                method.AddAssemblyInfo(constructorInfo);
            }
            foreach (EventInfo eventInfo in type.GetDeclaredEvents())
            {
                DotNetEvent e = Events.FirstOrDefault(m => m.Name.LocalName == eventInfo.Name);
                if (e == null)
                {
                    continue;
                }
                e.AddAssemblyInfo(eventInfo);
            }

            foreach (Type nestedType in type.GetDeclaredNestedTypes())
            {
                DotNetQualifiedName qualifiedName    = DotNetQualifiedName.FromAssemblyInfo(nestedType);
                DotNetType          dotNetNestedType = NestedTypes.FirstOrDefault(x => x.Owns(qualifiedName));
                if (dotNetNestedType == null)
                {
                    continue;
                }
                dotNetNestedType.AddAssemblyInfo(type, qualifiedName);
            }

            PushGenericTypes();
        }