@@ -17,6 +17,9 @@ public interface IScriptFilter : IFilter
17
17
[ JsonProperty ( PropertyName = "script_id" ) ]
18
18
string ScriptId { get ; set ; }
19
19
20
+ [ JsonProperty ( "script_file" ) ]
21
+ string ScriptFile { get ; set ; }
22
+
20
23
[ JsonProperty ( PropertyName = "params" ) ]
21
24
[ JsonConverter ( typeof ( DictionaryKeysAreNotPropertyNamesJsonConverter ) ) ]
22
25
Dictionary < string , object > Params { get ; set ; }
@@ -34,6 +37,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
34
37
35
38
public string Script { get ; set ; }
36
39
public string ScriptId { get ; set ; }
40
+ public string ScriptFile { get ; set ; }
37
41
public Dictionary < string , object > Params { get ; set ; }
38
42
public string Lang { get ; set ; }
39
43
}
@@ -44,10 +48,14 @@ protected internal override void WrapInContainer(IFilterContainer container)
44
48
/// </summary>
45
49
public class ScriptFilterDescriptor : FilterBase , IScriptFilter
46
50
{
51
+ private IScriptFilter Self { get { return this ; } }
52
+
47
53
string IScriptFilter . Script { get ; set ; }
48
54
49
55
string IScriptFilter . ScriptId { get ; set ; }
50
56
57
+ string IScriptFilter . ScriptFile { get ; set ; }
58
+
51
59
string IScriptFilter . Lang { get ; set ; }
52
60
53
61
Dictionary < string , object > IScriptFilter . Params { get ; set ; }
@@ -56,33 +64,39 @@ bool IFilter.IsConditionless
56
64
{
57
65
get
58
66
{
59
- return ( ( IScriptFilter ) this ) . Script . IsNullOrEmpty ( ) ;
67
+ return this . Self . Script . IsNullOrEmpty ( ) ;
60
68
}
61
69
}
62
70
63
71
/// <summary>
64
- /// Filter script.
72
+ /// Inline script to execute
65
73
/// </summary>
66
- /// <param name="script">script</param>
67
- /// <returns>this</returns>
68
74
public ScriptFilterDescriptor Script ( string script )
69
75
{
70
- ( ( IScriptFilter ) this ) . Script = script ;
76
+ this . Self . Script = script ;
71
77
return this ;
72
78
}
73
79
74
80
/// <summary>
75
- /// Indexed script can be referenced by script id
76
- /// </summary>
77
- /// <param name="scriptId">Indexed script id</param>
78
- /// <returns>this</returns>
81
+ /// Id of an indexed script to execute
82
+ /// </summary
79
83
public ScriptFilterDescriptor ScriptId ( string scriptId )
80
84
{
81
85
scriptId . ThrowIfNull ( "scriptId" ) ;
82
- ( ( IScriptFilter ) this ) . ScriptId = scriptId ;
86
+ this . Self . ScriptId = scriptId ;
83
87
return this ;
84
88
}
85
89
90
+ /// <summary>
91
+ /// File name of a script to execute
92
+ /// </summary>
93
+ public ScriptFilterDescriptor ScriptFile ( string scriptFile )
94
+ {
95
+ scriptFile . ThrowIfNull ( "scriptFile" ) ;
96
+ this . Self . ScriptFile = scriptFile ;
97
+ return this ;
98
+ }
99
+
86
100
/// <summary>
87
101
/// Scripts are compiled and cached for faster execution.
88
102
/// If the same script can be used, just with different parameters provider,
@@ -96,7 +110,7 @@ public ScriptFilterDescriptor ScriptId(string scriptId)
96
110
public ScriptFilterDescriptor Params ( Func < FluentDictionary < string , object > , FluentDictionary < string , object > > paramDictionary )
97
111
{
98
112
paramDictionary . ThrowIfNull ( "paramDictionary" ) ;
99
- ( ( IScriptFilter ) this ) . Params = paramDictionary ( new FluentDictionary < string , object > ( ) ) ;
113
+ this . Self . Params = paramDictionary ( new FluentDictionary < string , object > ( ) ) ;
100
114
return this ;
101
115
}
102
116
@@ -108,7 +122,7 @@ public ScriptFilterDescriptor Params(Func<FluentDictionary<string, object>, Flue
108
122
public ScriptFilterDescriptor Lang ( string lang )
109
123
{
110
124
lang . ThrowIfNull ( "lang" ) ;
111
- ( ( IScriptFilter ) this ) . Lang = lang ;
125
+ this . Self . Lang = lang ;
112
126
return this ;
113
127
}
114
128
@@ -120,7 +134,7 @@ public ScriptFilterDescriptor Lang(string lang)
120
134
public ScriptFilterDescriptor Lang ( ScriptLang lang )
121
135
{
122
136
lang . ThrowIfNull ( "lang" ) ;
123
- ( ( IScriptFilter ) this ) . Lang = lang . GetStringValue ( ) ;
137
+ this . Self . Lang = lang . GetStringValue ( ) ;
124
138
return this ;
125
139
}
126
140
}
0 commit comments