Ejemplo n.º 1
0
        internal static int GetCompatibilityBetweenPortableLibraryAndPortableLibrary(FrameworkName projectFrameworkName, FrameworkName packageTargetFrameworkName, NetPortableProfileTable portableProfileTable)
        {
            NetPortableProfile profile  = NetPortableProfile.Parse(projectFrameworkName.get_Profile(), false, portableProfileTable);
            NetPortableProfile profile2 = NetPortableProfile.Parse(packageTargetFrameworkName.get_Profile(), true, portableProfileTable);
            int num  = 0;
            int num2 = 0;

            foreach (FrameworkName supportedPackageTargetFramework in profile2.SupportedFrameworks)
            {
                FrameworkName name = Enumerable.FirstOrDefault <FrameworkName>(profile.SupportedFrameworks, (Func <FrameworkName, bool>)(f => IsCompatible(f, supportedPackageTargetFramework, portableProfileTable)));
                if ((name != null) && (name.get_Version() > supportedPackageTargetFramework.get_Version()))
                {
                    num++;
                }
            }
            foreach (FrameworkName optionalProjectFramework in profile.OptionalFrameworks)
            {
                FrameworkName name2 = Enumerable.FirstOrDefault <FrameworkName>(profile2.SupportedFrameworks, (Func <FrameworkName, bool>)(f => IsCompatible(f, optionalProjectFramework, portableProfileTable)));
                if ((name2 == null) || (name2.get_Version() > optionalProjectFramework.get_Version()))
                {
                    num2++;
                    continue;
                }
                if ((name2 != null) && (name2.get_Version() < optionalProjectFramework.get_Version()))
                {
                    num++;
                }
            }
            return(-((((((1 + profile.SupportedFrameworks.Count) + profile.OptionalFrameworks.Count) * num2) + num) * 50) + profile2.SupportedFrameworks.Count));
        }
Ejemplo n.º 2
0
        internal static bool IsCompatible(FrameworkName projectFrameworkName, FrameworkName packageTargetFrameworkName, NetPortableProfileTable portableProfileTable)
        {
            Dictionary <string, string[]> dictionary;

            string[] strArray;
            if (projectFrameworkName == null)
            {
                return(true);
            }
            if (packageTargetFrameworkName.IsPortableFramework())
            {
                return(IsPortableLibraryCompatible(projectFrameworkName, packageTargetFrameworkName, portableProfileTable));
            }
            packageTargetFrameworkName = NormalizeFrameworkName(packageTargetFrameworkName);
            projectFrameworkName       = NormalizeFrameworkName(projectFrameworkName);
            if (!projectFrameworkName.get_Identifier().Equals(packageTargetFrameworkName.get_Identifier(), StringComparison.OrdinalIgnoreCase))
            {
                FrameworkName name;
                if (!_equivalentProjectFrameworks.TryGetValue(projectFrameworkName.get_Identifier(), out name) || !name.get_Identifier().Equals(packageTargetFrameworkName.get_Identifier(), StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
                projectFrameworkName = name;
            }
            return((NormalizeVersion(projectFrameworkName.get_Version()) >= NormalizeVersion(packageTargetFrameworkName.get_Version())) ? (!string.Equals(projectFrameworkName.get_Profile(), packageTargetFrameworkName.get_Profile(), StringComparison.OrdinalIgnoreCase) ? (_compatibiltyMapping.TryGetValue(projectFrameworkName.get_Identifier(), out dictionary) && (dictionary.TryGetValue(packageTargetFrameworkName.get_Profile(), out strArray) && strArray.Contains <string>(projectFrameworkName.get_Profile(), StringComparer.OrdinalIgnoreCase))) : true) : false);
        }
Ejemplo n.º 3
0
        public static string GetShortFrameworkName(FrameworkName frameworkName, NetPortableProfileTable portableProfileTable)
        {
            string str;
            string str2;

            if (frameworkName == null)
            {
                throw new ArgumentNullException("frameworkName");
            }
            foreach (KeyValuePair <FrameworkName, FrameworkName> pair in _frameworkNameAlias)
            {
                if (FrameworkNameEqualityComparer.Default.Equals(pair.Value, frameworkName))
                {
                    frameworkName = pair.Key;
                    break;
                }
            }
            if (!_identifierToFrameworkFolder.TryGetValue(frameworkName.get_Identifier(), out str))
            {
                str = frameworkName.get_Identifier();
            }
            if (str.Equals("portable", StringComparison.OrdinalIgnoreCase))
            {
                if (portableProfileTable == null)
                {
                    throw new ArgumentException(NuGetResources.PortableProfileTableMustBeSpecified, "portableProfileTable");
                }
                NetPortableProfile profile = NetPortableProfile.Parse(frameworkName.get_Profile(), false, portableProfileTable);
                str2 = (profile == null) ? frameworkName.get_Profile() : profile.CustomProfileString;
            }
            else
            {
                if (frameworkName.get_Version() > new Version())
                {
                    str = str + frameworkName.get_Version().ToString().Replace(".", string.Empty);
                }
                if (string.IsNullOrEmpty(frameworkName.get_Profile()))
                {
                    return(str);
                }
                if (!_identifierToProfileFolder.TryGetValue(frameworkName.get_Profile(), out str2))
                {
                    str2 = frameworkName.get_Profile();
                }
            }
            return(str + "-" + str2);
        }
Ejemplo n.º 4
0
 private static Version GetEffectiveFrameworkVersion(FrameworkName projectFramework, FrameworkName targetFrameworkVersion, NetPortableProfileTable portableProfileTable)
 {
     if (targetFrameworkVersion.IsPortableFramework())
     {
         NetPortableProfile profile = NetPortableProfile.Parse(targetFrameworkVersion.get_Profile(), false, portableProfileTable);
         if (profile != null)
         {
             FrameworkName name = Enumerable.FirstOrDefault <FrameworkName>(profile.SupportedFrameworks, (Func <FrameworkName, bool>)(f => IsCompatible(projectFramework, f, portableProfileTable)));
             if (name != null)
             {
                 return(name.get_Version());
             }
         }
     }
     return(targetFrameworkVersion.get_Version());
 }
Ejemplo n.º 5
0
        private static long GetProfileCompatibility(FrameworkName projectFrameworkName, FrameworkName packageTargetFrameworkName, NetPortableProfileTable portableProfileTable)
        {
            projectFrameworkName       = NormalizeFrameworkName(projectFrameworkName);
            packageTargetFrameworkName = NormalizeFrameworkName(packageTargetFrameworkName);
            if (packageTargetFrameworkName.IsPortableFramework())
            {
                return(!projectFrameworkName.IsPortableFramework() ? (GetCompatibilityBetweenPortableLibraryAndNonPortableLibrary(projectFrameworkName, packageTargetFrameworkName, portableProfileTable) / 2L) : ((long)GetCompatibilityBetweenPortableLibraryAndPortableLibrary(projectFrameworkName, packageTargetFrameworkName, portableProfileTable)));
            }
            long num = 0L + CalculateVersionDistance(projectFrameworkName.get_Version(), GetEffectiveFrameworkVersion(projectFrameworkName, packageTargetFrameworkName, portableProfileTable));

            if (packageTargetFrameworkName.get_Profile().Equals(projectFrameworkName.get_Profile(), StringComparison.OrdinalIgnoreCase))
            {
                num += 1L;
            }
            if (packageTargetFrameworkName.get_Identifier().Equals(projectFrameworkName.get_Identifier(), StringComparison.OrdinalIgnoreCase))
            {
                num += 0xa00000000L;
            }
            return(num);
        }
Ejemplo n.º 6
0
        internal bool HasCompatibleProfileWith(NetPortableProfile packageFramework, FrameworkName projectOptionalFrameworkName, NetPortableProfileTable portableProfileTable)
        {
            List <Tuple <Version, ISet <string> > > list = null;

            if ((this._portableProfilesSetByOptionalFrameworks != null) && this._portableProfilesSetByOptionalFrameworks.TryGetValue(projectOptionalFrameworkName.get_Identifier(), out list))
            {
                using (List <Tuple <Version, ISet <string> > > .Enumerator enumerator = list.GetEnumerator())
                {
                    while (true)
                    {
                        if (!enumerator.MoveNext())
                        {
                            break;
                        }
                        Tuple <Version, ISet <string> > current = enumerator.Current;
                        if (projectOptionalFrameworkName.get_Version() >= current.Item1)
                        {
                            using (IEnumerator <string> enumerator2 = current.Item2.GetEnumerator())
                            {
                                while (true)
                                {
                                    if (!enumerator2.MoveNext())
                                    {
                                        break;
                                    }
                                    string             profileName             = enumerator2.Current;
                                    NetPortableProfile projectFrameworkProfile = this.GetProfile(profileName);
                                    if ((projectFrameworkProfile != null) && packageFramework.IsCompatibleWith(projectFrameworkProfile, portableProfileTable))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
        public static string GetFrameworkString(FrameworkName frameworkName)
        {
            string str = frameworkName.get_Identifier() + frameworkName.get_Version();

            return(!string.IsNullOrEmpty(frameworkName.get_Profile()) ? (str + "-" + frameworkName.get_Profile()) : str);
        }