forked from pnp/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvokeWebActionParameter.cs
37 lines (31 loc) · 1.18 KB
/
InvokeWebActionParameter.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
using System;
namespace PnP.PowerShell.Commands.InvokeAction
{
internal class InvokeActionParameter<T>
{
public Action<T> Action { get; set; }
public Func<T, bool> ShouldProcessAction {get; set;}
public Action<T> PostAction { get; set; }
public Func<T, bool> ShouldProcessPostAction { get; set; }
public string[] Properties { get; set; }
public bool HasAction => Action != null;
public bool HasPostAction => PostAction != null;
public bool HasAnyAction => Action != null || PostAction != null;
public bool ShouldProcessAnyAction(T item) => ShouldProcess(item) || ShouldProcessPost(item);
public bool ShouldProcess(T item)
{
if (ShouldProcessAction == null)
return true;
else
return ShouldProcessAction(item);
}
public bool ShouldProcessPost(T item)
{
if (ShouldProcessPostAction == null)
return true;
else
return ShouldProcessPostAction(item);
}
public InvokeActionParameter<T> ShallowCopy() => (InvokeActionParameter<T>) MemberwiseClone();
}
}