Ejemplo n.º 1
0
        static IEnumerable <string> GetAssemblies(GacDirInfo gacInfo, PublicKeyToken pkt, IAssembly assembly)
        {
            string pktString     = pkt.ToString();
            string verString     = assembly.Version.ToString();
            var    cultureString = UTF8String.ToSystemStringOrEmpty(assembly.Culture);

            if (cultureString.Equals("neutral", StringComparison.OrdinalIgnoreCase))
            {
                cultureString = string.Empty;
            }
            var asmSimpleName = UTF8String.ToSystemStringOrEmpty(assembly.Name);

            foreach (var subDir in gacInfo.SubDirs)
            {
                var    baseDir = Path.Combine(gacInfo.Path, subDir);
                string pathName;
                try {
                    baseDir  = Path.Combine(baseDir, asmSimpleName);
                    baseDir  = Path.Combine(baseDir, $"{gacInfo.Prefix}{verString}_{cultureString}_{pktString}");
                    pathName = Path.Combine(baseDir, asmSimpleName + ".dll");
                }
                catch (ArgumentException) {
                    // Invalid char(s) in asmSimpleName, cultureString
                    yield break;
                }
                if (File.Exists(pathName))
                {
                    yield return(pathName);
                }
            }
        }
Ejemplo n.º 2
0
        static IEnumerable <string> GetAssemblies(GacDirInfo gacInfo, PublicKeyToken pkt, IAssembly assembly)
        {
            string pktString     = pkt.ToString();
            string verString     = assembly.Version.ToString();
            var    cultureString = UTF8String.ToSystemStringOrEmpty(assembly.Culture);

            if (cultureString.Equals("neutral", StringComparison.OrdinalIgnoreCase))
            {
                cultureString = string.Empty;
            }
            var asmSimpleName = UTF8String.ToSystemStringOrEmpty(assembly.Name);

            foreach (var subDir in gacInfo.SubDirs)
            {
                var baseDir = Path.Combine(gacInfo.Path, subDir);
                baseDir = Path.Combine(baseDir, asmSimpleName);
                baseDir = Path.Combine(baseDir, string.Format("{0}{1}_{2}_{3}", gacInfo.Prefix, verString, cultureString, pktString));
                var pathName = Path.Combine(baseDir, asmSimpleName + ".dll");
                if (File.Exists(pathName))
                {
                    yield return(pathName);
                }
            }
        }