コード例 #1
0
        /// <summary>
        /// This method returns a list of assemblies whose contents depend on whether we
        /// are running in an ASP.NET environment. If we are indeed in a Web/ASP.NET
        /// scenario, we pick up the assemblies that all page compilations need to
        /// reference. If not, then we simply get the list of assemblies referenced by
        /// the entry assembly.
        /// </summary>
        /// <returns>A list of assemblies</returns>
        private static IEnumerable <Assembly> GetAllDiscoverableAssemblies()
        {
            Assembly           assembly     = Assembly.GetEntryAssembly();
            HashSet <Assembly> assemblyList = new HashSet <Assembly>(
                AssemblyComparer.Instance);

            foreach (Assembly loadedAssembly in GetAlreadyLoadedNonSystemAssemblies())
            {
                assemblyList.Add(loadedAssembly);
            }

            AspProxy aspProxy = new AspProxy();

            if (!aspProxy.IsAspNetEnvironment())
            {
                if (assembly == null)
                {
                    return(assemblyList);
                }

                assemblyList.Add(assembly);

                foreach (Assembly referenceAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(assembly))
                {
                    assemblyList.Add(referenceAssembly);
                }

                return(assemblyList);
            }

            if (aspProxy.HasBuildManagerType())
            {
                IEnumerable <Assembly> referencedAssemblies = aspProxy.GetBuildManagerReferencedAssemblies();
                // filter out system assemblies
                if (referencedAssemblies != null)
                {
                    foreach (Assembly referencedAssembly in referencedAssemblies)
                    {
                        if (MetadataAssemblyHelper.ShouldFilterAssembly(referencedAssembly))
                        {
                            continue;
                        }

                        assemblyList.Add(referencedAssembly);
                    }
                }
            }

            return(assemblyList.Where(a => a != null));
        }
コード例 #2
0
        [ResourceConsumption(ResourceScope.Machine)] //For Path.GetFullPath method call. But the path is not created in this method.
        static internal string NormalizeFilePaths(string path)
        {
            bool getFullPath = true;    // used to determine whether we need to invoke GetFullPath()

            if (!String.IsNullOrEmpty(path))
            {
                path = path.Trim();

                // If the path starts with a '~' character, try to resolve it as a Web/ASP.NET
                // application path.
                //
                if (path.StartsWith(EdmConstants.WebHomeSymbol, StringComparison.Ordinal))
                {
                    AspProxy aspProxy = new AspProxy();
                    path        = aspProxy.MapWebPath(path);
                    getFullPath = false;
                }

                if (path.Length == 2 && path[1] == System.IO.Path.VolumeSeparatorChar)
                {
                    path = path + System.IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    // See if the path contains the |DataDirectory| macro that we need to
                    // expand. Note that ExpandDataDirectory() won't process the path unless
                    // it begins with the macro.
                    //
                    string fullPath = System.Data.EntityClient.DbConnectionOptions.ExpandDataDirectory(
                        System.Data.EntityClient.EntityConnectionStringBuilder.MetadataParameterName,       // keyword ("Metadata")
                        path                                                                                // value
                        );

                    // ExpandDataDirectory() returns null if it doesn't find the macro in its
                    // argument.
                    //
                    if (fullPath != null)
                    {
                        path        = fullPath;
                        getFullPath = false;
                    }
                }
            }
            try
            {
                if (getFullPath)
                {
                    path = System.IO.Path.GetFullPath(path);
                }
            }
            catch (ArgumentException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (NotSupportedException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (PathTooLongException)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath);
            }

            return(path);
        }
コード例 #3
0
        [ResourceConsumption(ResourceScope.Machine)] //For Path.GetFullPath method call. But the path is not created in this method.
        static internal string NormalizeFilePaths(string path)
        {
            bool getFullPath = true;    // used to determine whether we need to invoke GetFullPath()

            if (!String.IsNullOrEmpty(path))
            {
                path = path.Trim();

                // If the path starts with a '~' character, try to resolve it as a Web/ASP.NET
                // application path.
                //
                if (path.StartsWith(EdmConstants.WebHomeSymbol, StringComparison.Ordinal))
                {
                    AspProxy aspProxy = new AspProxy();
                    path = aspProxy.MapWebPath(path);
                    getFullPath = false;
                }

                if (path.Length == 2 && path[1] == System.IO.Path.VolumeSeparatorChar)
                {
                    path = path + System.IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    // See if the path contains the |DataDirectory| macro that we need to
                    // expand. Note that ExpandDataDirectory() won't process the path unless
                    // it begins with the macro.
                    //
                    string fullPath = System.Data.EntityClient.DbConnectionOptions.ExpandDataDirectory(
                            System.Data.EntityClient.EntityConnectionStringBuilder.MetadataParameterName,   // keyword ("Metadata")
                            path                                                                            // value
                        );

                    // ExpandDataDirectory() returns null if it doesn't find the macro in its
                    // argument.
                    //
                    if (fullPath != null)
                    {
                        path = fullPath;
                        getFullPath = false;
                    }
                }
            }
            try
            {
                if (getFullPath)
                {
                    path = System.IO.Path.GetFullPath(path);
                }
            }
            catch (ArgumentException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (NotSupportedException e)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath, e);
            }
            catch (PathTooLongException)
            {
                throw EntityUtil.Metadata(System.Data.Entity.Strings.NotValidInputPath);
            }

            return path;
        }
コード例 #4
0
        [ResourceConsumption(ResourceScope.Machine)] //For Path.GetFullPath method call. But the path is not created in this method.
        internal static string NormalizeFilePaths(string path)
        {
            var getFullPath = true; // used to determine whether we need to invoke GetFullPath()

            if (!String.IsNullOrEmpty(path))
            {
                path = path.Trim();

                // If the path starts with a '~' character, try to resolve it as a Web/ASP.NET
                // application path.
                //
                if (path.StartsWith(EdmConstants.WebHomeSymbol, StringComparison.Ordinal))
                {
                    var aspProxy = new AspProxy();
                    path = aspProxy.MapWebPath(path);
                    getFullPath = false;
                }

                if (path.Length == 2
                    && path[1] == IO.Path.VolumeSeparatorChar)
                {
                    path = path + IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    // See if the path contains the |DataDirectory| macro that we need to expand.
                    var fullPath = DbProviderServices.ExpandDataDirectory(path);
                    if (!path.Equals(fullPath, StringComparison.Ordinal))
                    {
                        path = fullPath;
                        getFullPath = false;
                    }
                }
            }
            try
            {
                if (getFullPath)
                {
                    path = IO.Path.GetFullPath(path);
                }
            }
            catch (ArgumentException e)
            {
                throw new MetadataException(Strings.NotValidInputPath, e);
            }
            catch (NotSupportedException e)
            {
                throw new MetadataException(Strings.NotValidInputPath, e);
            }
            catch (PathTooLongException)
            {
                throw new MetadataException(Strings.NotValidInputPath);
            }

            return path;
        }