forked from microsoft/PSRule
/
Rule.cs
55 lines (44 loc) · 1.45 KB
/
Rule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Newtonsoft.Json;
using PSRule.Definitions.Expressions;
using PSRule.Host;
using PSRule.Pipeline;
using YamlDotNet.Serialization;
namespace PSRule.Definitions.Rules
{
public interface IRule
{
}
internal interface IRuleSpec
{
LanguageIf Condition { get; }
string[] Type { get; }
string[] With { get; }
}
[Spec(Specs.V1, Specs.Rule)]
internal sealed class RuleV1 : InternalResource<RuleV1Spec>, IResource
{
public RuleV1(string apiVersion, SourceFile source, ResourceMetadata metadata, ResourceHelpInfo info, RuleV1Spec spec)
: base(ResourceKind.Rule, apiVersion, source, metadata, info, spec) { }
/// <summary>
/// A human readable block of text, used to identify the purpose of the rule.
/// </summary>
[JsonIgnore]
[YamlIgnore]
public string Synopsis => Info.Synopsis;
string ILanguageBlock.Id => Name;
}
internal sealed class RuleV1Spec : Spec, IRuleSpec
{
public LanguageIf Condition { get; set; }
/// <summary>
/// An optional type precondition before the rule is evaluated.
/// </summary>
public string[] Type { get; set; }
/// <summary>
/// An optional selector precondition before the rule is evaluated.
/// </summary>
public string[] With { get; set; }
}
}