Esempio n. 1
0
        /// <summary>
        /// Examines the referenced assemblies list the user picked, and loads each
        /// assembly in turn and gets all the required namespaces, and includes these
        /// as valid Using statements in the generated code.
        ///
        /// NOTE: These referenced assemblies are loaded into a seperate AppDomain
        /// so that they can be unloaded. The use of the AppDomain also means the loaded
        /// assemblies are not loaded into the current AppDomain so do not impact the
        /// memory footpriont of the code generator app.
        /// </summary>
        /// <returns>A list of additional referenced assembly namespace strings to
        /// include in the generated code Using statements</returns>
        public static List <String> GetReferencedAssembliesUsingStatements()
        {
            try
            {
                //references assembly namespaces added
                List <String>   namespacesAdded = new List <String>();
                List <FileInfo> assemblies      =
                    ((App)App.Current).ReferencedAssemblies.ToList();

                //load them into new AppDomain and get the namespaces
                SeperateAppDomainAssemblyLoader appDomainAssemblyLoader =
                    new SeperateAppDomainAssemblyLoader();

                namespacesAdded = appDomainAssemblyLoader.LoadAssemblies(assemblies);
                return(namespacesAdded);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Examines the referenced assemblies list the user picked, and loads each
        /// assembly in turn and gets all the required namespaces, and includes these
        /// as valid Using statements in the generated code.
        /// 
        /// NOTE: These referenced assemblies are loaded into a seperate AppDomain
        /// so that they can be unloaded. The use of the AppDomain also means the loaded
        /// assemblies are not loaded into the current AppDomain so do not impact the
        /// memory footpriont of the code generator app.
        /// </summary>
        /// <returns>A list of additional referenced assembly namespace strings to
        /// include in the generated code Using statements</returns>
        public static List<String> GetReferencedAssembliesUsingStatements()
        {
            try
            {
                //references assembly namespaces added
                List<String> namespacesAdded = new List<String>();
                List<FileInfo> assemblies = 
                    ((App)App.Current).ReferencedAssemblies.ToList();
                
                //load them into new AppDomain and get the namespaces
                SeperateAppDomainAssemblyLoader appDomainAssemblyLoader = 
                    new SeperateAppDomainAssemblyLoader();

                namespacesAdded = appDomainAssemblyLoader.LoadAssemblies(assemblies);
                return namespacesAdded;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }