2016-02-20 01:00:41 +00:00
|
|
|
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;
|
2016-05-26 19:48:16 +00:00
|
|
|
private string _version;
|
2016-02-20 01:00:41 +00:00
|
|
|
|
|
|
|
public BuildPlatformsAttribute(params BuildPlatform[] platforms)
|
|
|
|
{
|
|
|
|
if (platforms == null)
|
|
|
|
{
|
2016-03-17 18:56:57 +00:00
|
|
|
throw new ArgumentNullException(nameof(platforms));
|
2016-02-20 01:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_buildPlatforms = platforms;
|
|
|
|
}
|
|
|
|
|
2016-05-26 19:48:16 +00:00
|
|
|
public BuildPlatformsAttribute(BuildPlatform platform, string version)
|
|
|
|
{
|
|
|
|
_buildPlatforms = new BuildPlatform[] { platform };
|
|
|
|
_version = version;
|
|
|
|
}
|
|
|
|
|
2016-02-20 01:00:41 +00:00
|
|
|
public override bool EvaluateCondition()
|
|
|
|
{
|
|
|
|
foreach (var platform in _buildPlatforms)
|
|
|
|
{
|
2016-05-26 19:48:16 +00:00
|
|
|
if (CurrentPlatform.IsPlatform(platform, _version))
|
2016-02-20 01:00:41 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|