Repository navigation
Expand file tree
/
Copy pathParameterScript.cs
More file actions
64 lines (57 loc) · 1.9 KB
/
Copy pathParameterScript.cs
File metadata and controls
64 lines (57 loc) · 1.9 KB
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
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;
namespace PSModuleDevelopment.Template
{
/// <summary>
/// A script used to calculate content to be inserted
/// </summary>
[Serializable]
public class ParameterScript
{
/// <summary>
/// Name of the scriptblock (auto-assigned or specified)
/// </summary>
public string Name;
/// <summary>
/// The scriptblock to invoke
/// </summary>
public ScriptBlock ScriptBlock;
/// <summary>
/// Direct string representation of the scriptblock.
/// </summary>
public string StringScript
{
get { return ScriptBlock.ToString(); }
set { }
}
/// <summary>
/// Creates an empty parameter script. Usually used in serialization.
/// </summary>
public ParameterScript()
{
}
/// <summary>
/// Creates a prefilled paramter script. Usually used when creating templates
/// </summary>
/// <param name="Name">The name of the parameter. This is used to insert it into individual files or file names.</param>
/// <param name="ScriptBlock"></param>
public ParameterScript(string Name, ScriptBlock ScriptBlock)
{
this.Name = Name;
this.ScriptBlock = ScriptBlock;
}
/// <summary>
/// Creates a prefilled parameter script. Usually used in fixing serialization the hard way.
/// </summary>
/// <param name="Item">The deserialized ParameterScript item</param>
public ParameterScript(PSObject Item)
{
Name = (string)Item.Properties["Name"].Value;
ScriptBlock = ScriptBlock.Create((string)Item.Properties["ScriptBlock"].Value);
}
}
}