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 BuildArchitecturesAttribute : TargetConditionAttribute
|
|
|
|
{
|
|
|
|
private IEnumerable<BuildArchitecture> _buildArchitectures;
|
|
|
|
|
|
|
|
public BuildArchitecturesAttribute(params BuildArchitecture[] architectures)
|
|
|
|
{
|
|
|
|
if (architectures == null)
|
|
|
|
{
|
2016-03-17 18:56:57 +00:00
|
|
|
throw new ArgumentNullException(nameof(architectures));
|
2016-02-20 01:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_buildArchitectures = architectures;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool EvaluateCondition()
|
|
|
|
{
|
|
|
|
var currentArchitecture = CurrentArchitecture.Current;
|
|
|
|
|
|
|
|
if (currentArchitecture == default(BuildArchitecture))
|
|
|
|
{
|
|
|
|
throw new Exception("Unrecognized Architecture");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var architecture in _buildArchitectures)
|
|
|
|
{
|
|
|
|
if (architecture == currentArchitecture)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|