Ejemplo n.º 1
0
        /// <summary>
        /// Resolves namespace into array of global assembly (GAC) locations.
        /// </summary>
        /// <param name="namespaceStr">'namespace' name</param>
        /// <returns>collection of assembly file names where namespace is implemented</returns>
        public static string[] FindGlobalAssembly(String namespaceStr)
        {
            var retval = new List <string>();

            if (Utils.IsMono)
            {
                if (Utils.MonoGAC.Contains(namespaceStr))
                {
                    retval.Add(namespaceStr);
                }
            }

            if (!retval.Any() && Utils.IsWin)
            {
                try
                {
                    AssemblyEnum asmEnum = new csscript.AssemblyEnum(namespaceStr);

                    string highestVersion = "";
                    string asmName        = "";
                    do
                    {
                        asmName = asmEnum.GetNextAssembly();
                        if (string.Compare(asmName, highestVersion) > 0)
                        {
                            highestVersion = asmName;
                        }

                        if (namespaceStr.Contains(", Version=")) //the assembly was specified by its full name
                        {
                            break;                               //stop searching for the higher version
                        }
                    }while (asmName != null);

                    if (highestVersion != "")
                    {
                        string asmLocation = AssemblyCache.QueryAssemblyInfo(highestVersion);
                        retval.Add(asmLocation);
                    }
                }
                catch (Exception)
                {
                    // fuslion.dll cannot be found under Mono even if it is running on Windows
                    //If exception is thrown it is very likely it is because where fusion.dll does not exist/unavailable/broken.
                    //We might be running under the MONO run-time.
                }
            }

            if (retval.Count == 0 && namespaceStr.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
            {
                retval.Add(namespaceStr); //in case of if the namespaceStr is a dll name
            }
            return(retval.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Resolves namespace into array of global assembly (GAC) locations.
        /// </summary>
        /// <param name="namespaceStr">'namespace' name</param>
        /// <returns>collection of assembly file names where namespace is implemented</returns>
        public static string[] FindGlobalAssembly(String namespaceStr)
        {
#if net1
            ArrayList retval = new ArrayList();
#else
            List <string> retval = new List <string>();
#endif
            try
            {
                AssemblyEnum asmEnum = new csscript.AssemblyEnum(namespaceStr);

                string highestVersion = "";
                string asmName        = "";
                do
                {
                    asmName = asmEnum.GetNextAssembly();
                    if (string.Compare(asmName, highestVersion) > 0)
                    {
                        highestVersion = asmName;
                    }

                    if (namespaceStr.Contains(", Version=")) //the assembly was specified by its full name
                    {
                        break;                               //stop searching for the higher version
                    }
                }while (asmName != null);

                if (highestVersion != "")
                {
                    string asmLocation = AssemblyCache.QueryAssemblyInfo(highestVersion);
                    retval.Add(asmLocation);
                }
            }
            catch
            {
                //If exception is thrown it is very likely it is because where fusion.dll does not exist/unavailable/broken.
                //We might be running under the MONO run-time.
            }

#if net1
            if (retval.Count == 0 && namespaceStr.ToLower().EndsWith(".dll"))
            {
                retval.Add(namespaceStr); //in case of if the namespaceStr is a dll name
            }
            return((string[])retval.ToArray(typeof(string)));
#else
            if (retval.Count == 0 && namespaceStr.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
            {
                retval.Add(namespaceStr); //in case of if the namespaceStr is a dll name
            }
            return(retval.ToArray());
#endif
        }
Ejemplo n.º 3
0
 static void TestWithFusion(string asm)
 {
     var e = new csscript.AssemblyEnum(asm);
     var name = e.GetNextAssembly();
     var file = csscript.AssemblyCache.QueryAssemblyInfo(name);
 }
Ejemplo n.º 4
0
      /// <summary>
      /// Resolves namespace into array of global assembly (GAC) locations.
      /// </summary>
      /// <param name="namespaceStr">'namespace' name</param>
      /// <returns>collection of assembly file names wher namespace is impelemented</returns>
      public static string[] FindGlobalAssembly(String namespaceStr)
      {
#if net1
			ArrayList retval = new ArrayList();
#else
        List<string> retval = new List<string>();
#endif
        try
        {
          AssemblyEnum asmEnum = new AssemblyEnum(namespaceStr);
          String asmName;
          while ((asmName = asmEnum.GetNextAssembly()) != null)
          {
            string asmLocation = AssemblyCache.QueryAssemblyInfo(asmName);
            retval.Add(asmLocation);
          }
        }
        catch
        {
          //If exception is thrown it is very likely it is because where fusion.dll does not exist/unavailable/broken.
          //We might be running under the MONO run-time. 
        }

        if (retval.Count == 0 && namespaceStr.ToLowerInvariant().EndsWith(".dll"))
          retval.Add(namespaceStr); //in case of if the namespaceStr is a dll name
#if net1
			return (string[])retval.ToArray(typeof(string));
#else
        return retval.ToArray();
#endif
      }
Ejemplo n.º 5
0
 static void TestWithFusion(string asm)
 {
     var e    = new csscript.AssemblyEnum(asm);
     var name = e.GetNextAssembly();
     var file = csscript.AssemblyCache.QueryAssemblyInfo(name);
 }