dotnet-installer/scripts/Microsoft.DotNet.Cli.Build.Framework/TargetConditions/BuildPlatformsAttribute.cs
Andrew Stanton-Nurse 43512b8973 add support for type: platform
also some refactoring of DependencyContext to properly handle
placeholders in 'runtimeTargets'.
2016-03-23 21:53:14 -07:00

34 lines
No EOL
900 B
C#

using System;
using System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Build.Framework
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class BuildPlatformsAttribute : TargetConditionAttribute
{
private IEnumerable<BuildPlatform> _buildPlatforms;
public BuildPlatformsAttribute(params BuildPlatform[] platforms)
{
if (platforms == null)
{
throw new ArgumentNullException(nameof(platforms));
}
_buildPlatforms = platforms;
}
public override bool EvaluateCondition()
{
foreach (var platform in _buildPlatforms)
{
if (CurrentPlatform.IsPlatform(platform))
{
return true;
}
}
return false;
}
}
}