示例#1
0
        /// <summary>
        /// Adds all class-members (<see cref="KindOfMemeber.F"/>, <see cref="KindOfMemeber.P"/>, <see cref="KindOfMemeber.M"/>) to the member list.
        /// </summary>
        static void FindAllMembers_FPM(Type ty, string type_name, AssemblyAndOtherStuff a, KindOfMemeber K, MemberInfo[] members)
        {
            foreach (MemberInfo fi in members)
            {
                Member F_mem = new Member();
                F_mem.kom      = K;
                F_mem.OrgName  = fi.Name;
                F_mem.FullName = type_name + "." + fi.Name;

                //a.xmldoc.SelectSingleNode("/doc/members/member[@name='T:BoSSS.Foundation.Basis']");
                F_mem.xmldocEntry = a.xmldoc.SelectSingleNode("/doc/members/member[@name='" + K.ToString() + ":" + F_mem.FullName + "']");

                if (F_mem.xmldocEntry != null)
                {
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    // add only members for which we can find an XMLDOC entry;
                    // Otherwise, documentation is not supported.
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                    AllMembers.Add(F_mem);
                }
                else
                {
                    // skip;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Recursively walks through the dependencies of the .NET assembly
        /// <paramref name="rootAssemblyFile"/>
        /// and collects them in
        /// <paramref name="assemblyPaths"/>.
        /// </summary>
        /// <param name="rootAssemblyFile">The root of the recursion.</param>
        /// <param name="assemblies">
        /// output;
        /// </param>
        static private void CollectAllDependenciesRecursive(string rootAssemblyFilePath, List <AssemblyAndOtherStuff> assemblies)
        {
            if (!File.Exists(rootAssemblyFilePath))
            {
                throw new FileNotFoundException();
            }

            string searchPath       = Path.GetDirectoryName(rootAssemblyFilePath);
            string rootAssemblyFile = Path.GetFileNameWithoutExtension(rootAssemblyFilePath);



            if (assemblies.SingleOrDefault(a => a.assi.GetName().Name == rootAssemblyFile) != null)
            {
                // Already added, end of recursion
                return;
            }
            else
            {
                string[] allFiles = Directory.GetFiles(searchPath);

                AssemblyAndOtherStuff a = new AssemblyAndOtherStuff();
                assemblies.Add(a);

                // load assembly
                // -------------
                a.FilePath = rootAssemblyFile;
                a.assi     = Assembly.LoadFile(rootAssemblyFilePath);


                // load xmldoc, if present
                // -----------------------

                string xmldocFile = allFiles.SingleOrDefault(delegate(string ss) {
                    string ssName  = Path.GetFileNameWithoutExtension(ss);
                    string ssLow   = ss.ToLower();
                    bool fileMatch = ssName.Equals(rootAssemblyFile);
                    bool extMatch  = ssLow.EndsWith(".xml");
                    return(fileMatch && extMatch);
                });

                if (xmldocFile != null)
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load(xmldocFile);
                    a.xmldoc = xmldoc;
                    //Console.WriteLine("Found XML for: " + xmldocFile);
                }
                else
                {
                    a.xmldoc = null;
                    //Console.WriteLine("Missing XML for: " + rootAssemblyFile);
                }

                // Collect all directly referenced assemblies (recursion)
                // ------------------------------------------------------

                foreach (AssemblyName dependencyName in a.assi.GetReferencedAssemblies())
                {
                    //string refAssemblyfilePath = Path.Combine(searchPath, dependencyName.FullName);

                    string refAssemblyFile = allFiles.SingleOrDefault(delegate(string ss) {
                        string ssName  = Path.GetFileNameWithoutExtension(ss);
                        string ssLow   = ss.ToLower();
                        bool fileMatch = ssName.Equals(dependencyName.Name);
                        bool extMatch  = (ssLow.EndsWith(".dll") || ssLow.EndsWith(".exe"));
                        return(fileMatch && extMatch);
                    });


                    if (refAssemblyFile != null)
                    {
                        //Console.WriteLine(refAssemblyFile);
                        CollectAllDependenciesRecursive(refAssemblyFile, assemblies);
                    }
                    else
                    {
                    }
                }
            }
        }