示例#1
0
 public bool TryInitializeWebAssembly()
 {
     if (this._webAssembly != (Assembly)null)
     {
         return(true);
     }
     if (this._triedLoadingWebAssembly)
     {
         return(false);
     }
     this._triedLoadingWebAssembly = true;
     if (!AspProxy.IsSystemWebLoaded())
     {
         return(false);
     }
     try
     {
         this._webAssembly = Assembly.Load("System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
         return(this._webAssembly != (Assembly)null);
     }
     catch (Exception ex)
     {
         if (!ex.IsCatchableExceptionType())
         {
             throw;
         }
     }
     return(false);
 }
示例#2
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);
        }
示例#3
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()
        {
            var assembly     = Assembly.GetEntryAssembly();
            var assemblyList = new HashSet <Assembly>(
                AssemblyComparer.Instance);

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

            var aspProxy = new AspProxy();

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

                assemblyList.Add(assembly);

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

                return(assemblyList);
            }

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

                        assemblyList.Add(referencedAssembly);
                    }
                }
            }

            return(assemblyList.Where(a => a != null));
        }
        internal static string NormalizeFilePaths(string path)
        {
            bool flag = true;

            if (!string.IsNullOrEmpty(path))
            {
                path = path.Trim();
                if (path.StartsWith("~", StringComparison.Ordinal))
                {
                    path = new AspProxy().MapWebPath(path);
                    flag = false;
                }
                if (path.Length == 2 && (int)path[1] == (int)System.IO.Path.VolumeSeparatorChar)
                {
                    path += (string)(object)System.IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    string str = DbProviderServices.ExpandDataDirectory(path);
                    if (!path.Equals(str, StringComparison.Ordinal))
                    {
                        path = str;
                        flag = false;
                    }
                }
            }
            try
            {
                if (flag)
                {
                    path = System.IO.Path.GetFullPath(path);
                }
            }
            catch (ArgumentException ex)
            {
                throw new MetadataException(Strings.NotValidInputPath, (Exception)ex);
            }
            catch (NotSupportedException ex)
            {
                throw new MetadataException(Strings.NotValidInputPath, (Exception)ex);
            }
            catch (PathTooLongException ex)
            {
                throw new MetadataException(Strings.NotValidInputPath);
            }
            return(path);
        }
示例#5
0
        private static IEnumerable <Assembly> GetAllDiscoverableAssemblies()
        {
            Assembly           entryAssembly = Assembly.GetEntryAssembly();
            HashSet <Assembly> source        = new HashSet <Assembly>((IEqualityComparer <Assembly>)DefaultAssemblyResolver.AssemblyComparer.Instance);

            foreach (Assembly nonSystemAssembly in DefaultAssemblyResolver.GetAlreadyLoadedNonSystemAssemblies())
            {
                source.Add(nonSystemAssembly);
            }
            AspProxy aspProxy = new AspProxy();

            if (!aspProxy.IsAspNetEnvironment())
            {
                if (entryAssembly == (Assembly)null)
                {
                    return((IEnumerable <Assembly>)source);
                }
                source.Add(entryAssembly);
                foreach (Assembly referencedAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(entryAssembly))
                {
                    source.Add(referencedAssembly);
                }
                return((IEnumerable <Assembly>)source);
            }
            if (aspProxy.HasBuildManagerType())
            {
                IEnumerable <Assembly> referencedAssemblies = aspProxy.GetBuildManagerReferencedAssemblies();
                if (referencedAssemblies != null)
                {
                    foreach (Assembly assembly in referencedAssemblies)
                    {
                        if (!MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
                        {
                            source.Add(assembly);
                        }
                    }
                }
            }
            return(source.Where <Assembly>((Func <Assembly, bool>)(a => a != (Assembly)null)));
        }
        [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;
        }