当前位置: 首页>>代码示例>>C#>>正文


C# Versioning.FrameworkName类代码示例

本文整理汇总了C#中System.Runtime.Versioning.FrameworkName的典型用法代码示例。如果您正苦于以下问题:C# System.Runtime.Versioning.FrameworkName类的具体用法?C# System.Runtime.Versioning.FrameworkName怎么用?C# System.Runtime.Versioning.FrameworkName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Runtime.Versioning.FrameworkName类属于命名空间,在下文中一共展示了System.Runtime.Versioning.FrameworkName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPaths

        /// <summary>
        /// Generate the set of chained reference assembly paths
        /// </summary>
        private IList<String> GetPaths(string rootPath, FrameworkNameVersioning frameworkmoniker)
        {
            IList<String> pathsToReturn = null;

            if (String.IsNullOrEmpty(rootPath))
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkmoniker);
            }
            else
            {
                pathsToReturn = ToolLocationHelper.GetPathToReferenceAssemblies(rootPath, frameworkmoniker);
            }

            // No reference assembly paths could be found, log a warning as there could be future errors which may be confusing because of this.
            if (pathsToReturn.Count == 0)
            {
                Log.LogWarningWithCodeFromResources("GetReferenceAssemblyPaths.NoReferenceAssemblyDirectoryFound", frameworkmoniker.ToString());
            }

            return pathsToReturn;
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:24,代码来源:GetReferenceAssemblyPaths.cs

示例2: LegacyFramework35Good

        public void LegacyFramework35Good()
        {
            FrameworkNameVersioning frameworkName = new FrameworkNameVersioning("Anything", new Version("3.5"));
            LegacyFrameworkTestHelper legacyHelper = new LegacyFrameworkTestHelper();
            legacyHelper.DotNetReferenceAssemblies35Installed = true;
            legacyHelper.DotNetReferenceAssemblies30Installed = true;
            legacyHelper.DotNet30Installed = true;
            legacyHelper.DotNet35Installed = true;
            legacyHelper.DotNet20Installed = true;

            IList<string> list = ToolLocationHelper.HandleLegacyDotNetFrameworkReferenceAssemblyPaths(legacyHelper.GetDotNetVersionToPathDelegate, legacyHelper.GetDotNetReferenceAssemblyDelegate, frameworkName);
            Assert.Equal(5, list.Count);
            Assert.Equal(LegacyFrameworkTestHelper.DotNet35ReferenceAssemblyPath, list[0]);
            Assert.Equal(LegacyFrameworkTestHelper.DotNet35FrameworkPath, list[1]);
            Assert.Equal(LegacyFrameworkTestHelper.DotNet30ReferenceAssemblyPath, list[2]);
            Assert.Equal(LegacyFrameworkTestHelper.DotNet30FrameworkPath, list[3]);
            Assert.Equal(LegacyFrameworkTestHelper.DotNet20FrameworkPath, list[4]);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:18,代码来源:ToolLocationHelper_Tests.cs

示例3: LegacyFramework40DotNetReferenceAssemblyDirectoryNotInstalled

        public void LegacyFramework40DotNetReferenceAssemblyDirectoryNotInstalled()
        {
            FrameworkNameVersioning frameworkName = new FrameworkNameVersioning("Anything", new Version("4.0"));
            LegacyFrameworkTestHelper legacyHelper = new LegacyFrameworkTestHelper();
            legacyHelper.DotNet40Installed = true;

            IList<string> list = ToolLocationHelper.HandleLegacyDotNetFrameworkReferenceAssemblyPaths(legacyHelper.GetDotNetVersionToPathDelegate, legacyHelper.GetDotNetReferenceAssemblyDelegate, frameworkName);
            Assert.Equal(0, list.Count);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:9,代码来源:ToolLocationHelper_Tests.cs

示例4: GetPathToReferenceAssembliesWithRootCircularReference

        public void GetPathToReferenceAssembliesWithRootCircularReference()
        {
            string redistString41 = "<FileList Redist='Random' IncludeFramework='v4.0'>" +
                                     "<File AssemblyName='System' Version='4.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='false' />" +
                                  "</FileList >";

            string redistString40 = "<FileList Redist='Random' IncludeFramework='v4.1'>" +
                                       "<File AssemblyName='System' Version='4.0.0.0' PublicKeyToken='b77a5c561934e089' Culture='neutral' ProcessorArchitecture='MSIL' FileVersion='4.0.0.0' InGAC='false' />" +
                                    "</FileList >";

            string tempDirectory = Path.Combine(Path.GetTempPath(), "GetPathToReferenceAssembliesWithRootGoodWithChain");

            string framework41Directory = Path.Combine(tempDirectory, "MyFramework\\v4.1\\");
            string framework41redistDirectory = Path.Combine(framework41Directory, "RedistList");
            string framework41RedistList = Path.Combine(framework41redistDirectory, "FrameworkList.xml");

            string framework40Directory = Path.Combine(tempDirectory, "MyFramework\\v4.0\\");
            string framework40redistDirectory = Path.Combine(framework40Directory, "RedistList");
            string framework40RedistList = Path.Combine(framework40redistDirectory, "FrameworkList.xml");

            try
            {
                Directory.CreateDirectory(framework41redistDirectory);
                Directory.CreateDirectory(framework40redistDirectory);

                File.WriteAllText(framework40RedistList, redistString40);
                File.WriteAllText(framework41RedistList, redistString41);


                FrameworkNameVersioning frameworkName = new FrameworkNameVersioning("MyFramework", new Version("4.1"));
                IList<string> directories = ToolLocationHelper.GetPathToReferenceAssemblies(tempDirectory, frameworkName);

                Assert.Equal(2, directories.Count); // "Expected the method to return two paths."
                Assert.True(String.Equals(directories[0], framework41Directory, StringComparison.OrdinalIgnoreCase), "Expected first entry to be first in chain but it was" + directories[0]);
                Assert.True(String.Equals(directories[1], framework40Directory, StringComparison.OrdinalIgnoreCase), "Expected first entry to be second in chain but it was" + directories[1]);
            }
            finally
            {
                if (Directory.Exists(framework41Directory))
                {
                    Directory.Delete(framework41Directory, true);
                }

                if (Directory.Exists(framework40Directory))
                {
                    Directory.Delete(framework40Directory, true);
                }
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:49,代码来源:ToolLocationHelper_Tests.cs

示例5: GetPathToReferenceAssembliesDefaultLocation45

        public void GetPathToReferenceAssembliesDefaultLocation45()
        {
            FrameworkNameVersioning frameworkName = null;
            IList<string> directories = null;
            if (ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version45) != null)
            {
                frameworkName = new FrameworkNameVersioning(".NETFramework", new Version("4.5"));
                directories = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkName);
                Assert.Equal(1, directories.Count); // "Expected the method to return one path."

                string referenceAssemblyPath = ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies(TargetDotNetFrameworkVersion.Version45);
                Assert.True(String.Equals(directories[0], referenceAssemblyPath, StringComparison.OrdinalIgnoreCase), "Expected referenceassembly directory to be " + referenceAssemblyPath + " but it was " + directories[0]);
            }
            // else
            // "Ignored because v4.5 did not seem to be installed"
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:16,代码来源:ToolLocationHelper_Tests.cs

示例6: LegacyFramework35ReferenceAssembliesNotInstalled

        public void LegacyFramework35ReferenceAssembliesNotInstalled()
        {
            FrameworkNameVersioning frameworkName = new FrameworkNameVersioning("Anything", new Version("3.5"));
            LegacyFrameworkTestHelper legacyHelper = new LegacyFrameworkTestHelper();
            legacyHelper.DotNet35Installed = true;

            IList<string> list = ToolLocationHelper.HandleLegacyDotNetFrameworkReferenceAssemblyPaths(legacyHelper.GetDotNetVersionToPathDelegate, legacyHelper.GetDotNetReferenceAssemblyDelegate, frameworkName);
            Assert.IsTrue(list.Count == 0);
        }
开发者ID:zlatanov,项目名称:msbuild,代码行数:9,代码来源:ToolLocationHelper_Tests.cs

示例7: GenerateReferencAssemblyPathTooLong

        public void GenerateReferencAssemblyPathTooLong()
        {
            Assert.Throws<InvalidOperationException>(() =>
            {
                string pathTooLong = new String('a', 500);

                string targetFrameworkRootPath = "c:\\Program Files\\Reference Assemblies\\Microsoft\\Framework";
                string targetFrameworkIdentifier = "Compact Framework" + pathTooLong;
                Version targetFrameworkVersion = new Version("1.0");
                string targetFrameworkProfile = "PocketPC";

                FrameworkNameVersioning frameworkName = new FrameworkNameVersioning(targetFrameworkIdentifier, targetFrameworkVersion, targetFrameworkProfile);

                string path = FrameworkLocationHelper.GenerateReferenceAssemblyPath(targetFrameworkRootPath, frameworkName);
            }
           );
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:17,代码来源:ToolLocationHelper_Tests.cs

示例8: IsSupportedVersion

 private static bool IsSupportedVersion(FrameworkName frameworkName) {
     // Look under the following registry to get the list of supported keys, and check for matching
     // identifier and version.
     // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\[TFM]
     try {
         var name = new FrameworkName(frameworkName.Identifier, frameworkName.Version);
         var runtime = Environment.Version;
         var runtimeVersion = runtime.Major + "." + runtime.Minor + "." + runtime.Build;
         string path = @"SOFTWARE\Microsoft\.NETFramework\v" + runtimeVersion + @"\SKUs";
         var baseKey = Registry.LocalMachine.OpenSubKey(path);
         foreach (string subKey in baseKey.GetSubKeyNames()) {
             try {
                 var subKeyName = CreateFrameworkName(subKey);
                 var supportedName = new FrameworkName(subKeyName.Identifier, subKeyName.Version);
                 if (String.Equals(name.FullName, supportedName.FullName, StringComparison.OrdinalIgnoreCase)) {
                     return true;
                 }
             }
             catch {
                 continue;
             }
         }
     }
     catch {
     }
     return false;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:MultiTargetingUtil.cs

示例9: InitializeTargetFrameworkNameFor20Or35

        /// <summary>
        /// Checks codedom settings to determine whether we are targeting 2.0 or 3.5.
        /// </summary>
        private static void InitializeTargetFrameworkNameFor20Or35() {
            string compilerVersion = GetCompilerVersionFor20Or35();

            // Make sure the compiler version is either 2.0 or 3.5
            if (CompilationUtil.IsCompilerVersion35(compilerVersion)) {
                s_targetFrameworkName = FrameworkNameV35;
            }
            else if (compilerVersion == "v2.0" || compilerVersion == null) {
                // If the compiler version is null, it means the user did not set it
                // in the codedom section.
                // We use 3.0 because it is not possible to distinguish between 2.0 and 3.0
                // by just looking at web.config.
                s_targetFrameworkName = FrameworkNameV30;
            }
            else {
                throw new ConfigurationErrorsException(SR.GetString(SR.Compiler_version_20_35_required, s_configTargetFrameworkAttributeName));
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:21,代码来源:MultiTargetingUtil.cs

示例10: InitializeTargetFrameworkName

        /// <summary>
        /// Checks what is the target framework version and initializes the targetFrameworkName
        /// </summary>
        private static void InitializeTargetFrameworkName() {
            string targetFrameworkMoniker = ConfigTargetFrameworkMoniker;

            // Check if web.config exists, and if not, assume 4.0
            if (!WebConfigExists) {
                s_targetFrameworkName = FrameworkNameV40;
                ValidateCompilerVersionFor40AndAbove();
            }
            else if (targetFrameworkMoniker == null) {
                if (BuildManagerHost.SupportsMultiTargeting) {
                    // We check for null because the user could have specified 
                    // an empty string.
                    // TargetFrameworkMoniker was not specified in config, 
                    // so we need to check codedom settings.
                    InitializeTargetFrameworkNameFor20Or35();
                } else {
                    // We are running in a 4.0 application pool or in the aspnet_compiler,
                    // but the target framework moniker is not specified.
                    // Assume it is 4.0 so that the application can run.
                    s_targetFrameworkName = FrameworkNameV40;
                }
            } else {
                // The targetFrameworkMonike is specified, so we need to validate it.
                InitializeTargetFrameworkNameFor40AndAbove(targetFrameworkMoniker);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:29,代码来源:MultiTargetingUtil.cs

示例11: ValidateTargetFrameworkMoniker

        /// <summary>
        /// Verifies that the moniker is valid, and that the version is 4.0 and above.
        /// </summary>
        private static void ValidateTargetFrameworkMoniker(string targetFrameworkMoniker) {
            CompilationSection compConfig = RuntimeConfig.GetAppConfig().Compilation;
            int lineNumber = compConfig.ElementInformation.LineNumber;
            string source = compConfig.ElementInformation.Source;
            try {
                string moniker = targetFrameworkMoniker;
                // Try treating it as a version, eg "4.0" first.
                Version v = GetVersion(targetFrameworkMoniker);
                if (v != null) {
                    // If it is of the form "4.0", construct the full moniker string,
                    // eg ".NETFramework,Version=v4.0"
                    moniker = ".NETFramework,Version=v" + moniker;
                }
                s_targetFrameworkName = CreateFrameworkName(moniker);
            }
            catch (ArgumentException e) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Invalid_target_framework_version, 
                    s_configTargetFrameworkAttributeName, targetFrameworkMoniker, e.Message), source, lineNumber);
            }
            Version ver = GetFrameworkNameVersion(s_targetFrameworkName);
            if (ver < Version40) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Invalid_lower_target_version, s_configTargetFrameworkAttributeName),
                    source, lineNumber);
            }

            // Check the specified version is no higher than the latest known framework for which we have
            // reference assemblies installed.
            Version latestVersion = GetFrameworkNameVersion(LatestFrameworkName);
            if (latestVersion != null && latestVersion >= ver) {
                // If the specified version is lower than the latest version installed,
                // we are fine.
                return;
            }

            // NOTE: This check is not entirely correct. See comments in GetInstalledTargetVersion().
            // It might be possible that the actual installed (runtime) version is of a higher version,
            // but the reference assemblies are not installed, so latestFrameworkName might be lower. 
            // In that case we also need to check the registry key.
            int majorVersion = ver.Major;
            Version installedTargetVersion = GetInstalledTargetVersion(majorVersion);
            if (installedTargetVersion != null && installedTargetVersion >= ver) {
                return;
            }

            if (IsSupportedVersion(s_targetFrameworkName)) {
                return;
            }

            // If the above checks failed, report that the version is invalid, higher than expected
            throw new ConfigurationErrorsException(SR.GetString(SR.Invalid_higher_target_version, s_configTargetFrameworkAttributeName), source, lineNumber);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:54,代码来源:MultiTargetingUtil.cs

示例12: GetXmlElement

        private static XmlElement GetXmlElement(string targetZone, FrameworkNameVersioning fn)
        {
            IList<string> paths = ToolLocationHelper.GetPathToReferenceAssemblies(fn);

            // Is the targeted CLR even installed?
            if (paths.Count > 0)
            {
                // first one is always framework requested.
                string path = Path.Combine(paths[0], PermissionSetsFolder);

                // PermissionSets folder doesn't exit
                if (Directory.Exists(path))
                {
                    string[] files = Directory.GetFiles(path, "*.xml");
                    FileInfo[] filesInfo = new FileInfo[files.Length];

                    int indexFound = -1;

                    // trim the extension.
                    for (int i = 0; i < files.Length; i++)
                    {
                        filesInfo[i] = new FileInfo(files[i]);

                        string fileInfoNoExt = Path.GetFileNameWithoutExtension(files[i]);

                        if (string.Equals(fileInfoNoExt, targetZone, StringComparison.OrdinalIgnoreCase))
                        {
                            indexFound = i;
                            break;
                        }
                    }

                    if (indexFound != -1)
                    {
                        string data = string.Empty;
                        FileInfo resultFile = filesInfo[indexFound];
                        using (FileStream fs = resultFile.OpenRead())
                        {
                            try
                            {
                                StreamReader sr = new StreamReader(fs);
                                data = sr.ReadToEnd(); // fs.Position value will be the length of the stream.
                                if (!string.IsNullOrEmpty(data))
                                {
                                    XmlDocument doc = new XmlDocument();
                                    XmlReaderSettings xrSettings = new XmlReaderSettings();
                                    xrSettings.DtdProcessing = DtdProcessing.Ignore;

                                    // http://msdn.microsoft.com/en-us/library/h2344bs2(v=vs.110).aspx
                                    // PermissionSets do not conform to document level, which is the default setting.
                                    xrSettings.ConformanceLevel = ConformanceLevel.Auto;
                                    try
                                    {
                                        fs.Position = 0; // Reset to 0 before using this stream in any other reader.
                                        using (XmlReader xr = XmlReader.Create(fs, xrSettings))
                                        {
                                            doc.Load(xr);
                                            return (XmlElement)doc.DocumentElement;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        //continue.
                                    }
                                }
                            }
                            catch (ArgumentException)
                            {
                                //continue.
                            }
                        }
                    }
                }
            }

            return GetCurrentCLRPermissions(targetZone);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:77,代码来源:SecurityUtil.cs

示例13: GetNamedPermissionSet

        private static PermissionSet GetNamedPermissionSet(string targetZone, ITaskItem[] dependencies, string targetFrameworkMoniker)
        {
            FrameworkNameVersioning fn = null;

            if (!string.IsNullOrEmpty(targetFrameworkMoniker))
            {
                fn = new FrameworkNameVersioning(targetFrameworkMoniker);
            }
            else
            {
                fn = new FrameworkNameVersioning(".NETFramework", s_dotNet40Version);
            }

            int majorVersion = fn.Version.Major;

            if (majorVersion == Fx2MajorVersion)
            {
                return SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, majorVersion)));
            }
            else if (majorVersion == Fx3MajorVersion)
            {
                return SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, majorVersion)));
            }
            else
            {
                return SecurityUtilities.XmlToPermissionSet((GetXmlElement(targetZone, fn)));
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:28,代码来源:SecurityUtil.cs

示例14: IsInFramework

        public bool IsInFramework(string frameworkIdentifier, string frameworkVersion)
        {
            Version version = null;
            if (!string.IsNullOrEmpty(frameworkVersion))
            {
                // CA1307:Specify StringComparison.  Suppressed since a valid string representation of a version would be parsed correctly even if the the first character is not "v".
                if (frameworkVersion.StartsWith("v"))
                {
                    System.Version.TryParse(frameworkVersion.Substring(1), out version);
                }
                else
                {
                    System.Version.TryParse(frameworkVersion, out version);
                }
            }

            if (string.IsNullOrEmpty(frameworkIdentifier) && version != null)
            {
                throw new ArgumentNullException("frameworkIdentifier");
            }

            Dictionary<string, RedistList> redistDictionary = new Dictionary<string, RedistList>();

            foreach (string moniker in ToolLocationHelper.GetSupportedTargetFrameworks())
            {
                FrameworkNameVersioning frameworkName = new FrameworkNameVersioning(moniker);
                if ((string.IsNullOrEmpty(frameworkIdentifier) || frameworkName.Identifier.Equals(frameworkIdentifier, StringComparison.OrdinalIgnoreCase)) &&
                    (version == null || frameworkName.Version == version))
                {
                    IList<string> paths = ToolLocationHelper.GetPathToReferenceAssemblies(frameworkName);

                    foreach (string path in paths)
                    {
                        if (!redistDictionary.ContainsKey(path))
                        {
                            redistDictionary.Add(path, RedistList.GetRedistListFromPath(path));
                        }
                    }
                }
            }

            string fullName = GetFullName(AssemblyIdentity.FullNameFlags.Default);
            foreach (RedistList list in redistDictionary.Values)
            {
                if (list != null && list.IsFrameworkAssembly(fullName))
                    return true;
            }

            return false;
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:50,代码来源:AssemblyIdentity.cs

示例15: GetPathToReferenceAssembliesNullArgumentGoodFrameworkNameNullRoot

 public void GetPathToReferenceAssembliesNullArgumentGoodFrameworkNameNullRoot()
 {
     FrameworkNameVersioning frameworkName = new FrameworkNameVersioning("Ident", new Version("2.0"));
     ToolLocationHelper.GetPathToReferenceAssemblies(null, frameworkName);
 }
开发者ID:zlatanov,项目名称:msbuild,代码行数:5,代码来源:ToolLocationHelper_Tests.cs


注:本文中的System.Runtime.Versioning.FrameworkName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。