Ejemplo n.º 1
0
        private static void ReadTargetFrameworkId()
        {
            string targetFrameworkName = string.Empty;

            AssemblyName[] assNames = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            foreach (AssemblyName name in assNames)
            {
                if (name.Name == "mscorlib")
                {
                    targetFrameworkName = name.Version.ToString();
                }
            }
            int num = 0;
            TargetFrameworkId targetFrameworkId;

            if (targetFrameworkName == null)
            {
                targetFrameworkId = TargetFrameworkId.Unspecified;
            }
            else
            {
                if (!BinaryCompatibility.ParseTargetFrameworkMonikerIntoEnum(targetFrameworkName, out targetFrameworkId, out num))
                {
                    targetFrameworkId = TargetFrameworkId.Unrecognized;
                }
            }
            BinaryCompatibility.s_AppWasBuiltForFramework = targetFrameworkId;
            BinaryCompatibility.s_AppWasBuiltForVersion   = num;
        }
Ejemplo n.º 2
0
        private static bool ParseTargetFrameworkMonikerIntoEnum(string targetFrameworkMoniker, out TargetFrameworkId targetFramework, out int targetFrameworkVersion)
        {
            targetFramework        = TargetFrameworkId.NotYetChecked;
            targetFrameworkVersion = 0;
            string text  = null;
            string text2 = null;

            BinaryCompatibility.ParseFrameworkName(targetFrameworkMoniker, out text, out targetFrameworkVersion, out text2);
            string a;

            if ((a = text) != null)
            {
                if (a == ".NETFramework")
                {
                    targetFramework = TargetFrameworkId.NetFramework;
                    return(true);
                }
                if (a == ".NETPortable")
                {
                    targetFramework = TargetFrameworkId.Portable;
                    return(true);
                }
                if (a == ".NETCore")
                {
                    targetFramework = TargetFrameworkId.NetCore;
                    return(true);
                }
                if (a == "Silverlight")
                {
                    targetFramework = TargetFrameworkId.Silverlight;
                    if (string.IsNullOrEmpty(text2))
                    {
                        return(true);
                    }
                    if (text2 == "WindowsPhone")
                    {
                        targetFramework        = TargetFrameworkId.Phone;
                        targetFrameworkVersion = 70000;
                        return(true);
                    }
                    if (text2 == "WindowsPhone71")
                    {
                        targetFramework        = TargetFrameworkId.Phone;
                        targetFrameworkVersion = 70100;
                        return(true);
                    }
                    if (text2 == "WindowsPhone8")
                    {
                        targetFramework        = TargetFrameworkId.Phone;
                        targetFrameworkVersion = 80000;
                        return(true);
                    }
                    if (text2.StartsWith("WindowsPhone", StringComparison.Ordinal))
                    {
                        targetFramework        = TargetFrameworkId.Unrecognized;
                        targetFrameworkVersion = 70100;
                        return(true);
                    }
                    targetFramework = TargetFrameworkId.Unrecognized;
                    return(true);
                }
            }
            targetFramework = TargetFrameworkId.Unrecognized;
            return(true);
        }