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


C# Runtime.GetTargetFrameworks方法代码示例

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


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

示例1: SelectFrameworks

        public static IEnumerable<FrameworkName> SelectFrameworks(Runtime.Project project,
                                                                  IEnumerable<string> userSelection,
                                                                  FrameworkName fallbackFramework,
                                                                  out string errorMessage)
        {
            var specifiedFrameworks = userSelection.ToDictionary(f => f, FrameworkNameHelper.ParseFrameworkName);

            var projectFrameworks = new HashSet<FrameworkName>(
                project.GetTargetFrameworks()
                       .Select(c => c.FrameworkName));

            IEnumerable<FrameworkName> frameworks = null;

            if (projectFrameworks.Count > 0)
            {
                // Specified target frameworks have to be a subset of the project frameworks
                if (!ValidateFrameworks(projectFrameworks, specifiedFrameworks, out errorMessage))
                {
                    return null;
                }

                frameworks = specifiedFrameworks.Count > 0 ? specifiedFrameworks.Values : (IEnumerable<FrameworkName>)projectFrameworks;
            }
            else
            {
                frameworks = new[] { fallbackFramework };
            }

            errorMessage = string.Empty;
            return frameworks;
        }
开发者ID:elanwu123,项目名称:dnx,代码行数:31,代码来源:FrameworkSelectionHelper.cs

示例2: ApplyTargetFramework

        private void ApplyTargetFramework(XDocument xDoc, Runtime.Project project)
        {
            // Get the system.web element
            var systemWeb = GetOrAddElement(xDoc.Root, "system.web");

            var httpRuntime = systemWeb.Element("httpRuntime");

            // No httpRuntime element, so create it
            if (httpRuntime == null)
            {
                httpRuntime = new XElement("httpRuntime");
                systemWeb.Add(httpRuntime);
            }
            // There is an httpRuntime element. The user may have already set this attribute...
            else if (httpRuntime.Attribute("targetFramework") != null)
            {
                // User already had a target framework, leave it alone
                return;
            }
            // Ok, now we have an httpRuntime element and we know we need to set thet targetFramework on it.

            var bestDnxVersion = project.GetTargetFrameworks()
                .Where(f => f.FrameworkName.Identifier.Equals(FrameworkNames.LongNames.Dnx))
                .OrderByDescending(f => f.FrameworkName.Version)
                .Select(f => f.FrameworkName.Version)
                .FirstOrDefault();
            if (bestDnxVersion != null)
            {
                httpRuntime.SetAttributeValue("targetFramework", bestDnxVersion.ToString());
            }
        }
开发者ID:noahfalk,项目名称:dnx,代码行数:31,代码来源:PublishProject.cs


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