Skip to content

Commit 76e814c

Browse files
authored
Complete transform session context API (#100)
1 parent 1227a98 commit 76e814c

2 files changed

Lines changed: 53 additions & 5 deletions

File tree

‎Handle/BNTransformContext.cs‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ public string TransformName
121121

122122
}
123123

124+
/// <summary>Overrides the transform selected for this context.</summary>
125+
public void SetTransformName(string transformName)
126+
{
127+
if (null == transformName)
128+
{
129+
throw new ArgumentNullException(nameof(transformName));
130+
}
131+
132+
NativeMethods.BNTransformContextSetTransformName(this.handle, transformName);
133+
}
134+
124135
public TransformParameter[] Parameters
125136
{
126137
set
@@ -178,9 +189,13 @@ public TransformResult ExtractionResult
178189
public TransformResult TransformResult
179190
{
180191
get
181-
{
182-
return NativeMethods.BNTransformContextGetTransformResult(this.handle);
183-
}
192+
{
193+
return NativeMethods.BNTransformContextGetTransformResult(this.handle);
194+
}
195+
set
196+
{
197+
NativeMethods.BNTransformContextSetTransformResult(this.handle, value);
198+
}
184199
}
185200

186201
public Metadata? Metadata
@@ -292,6 +307,12 @@ public bool IsDatabase
292307
}
293308
}
294309

310+
/// <summary>Gets whether the containing session is operating interactively.</summary>
311+
public bool IsInteractive
312+
{
313+
get { return NativeMethods.BNTransformContextIsInteractive(this.handle); }
314+
}
315+
295316
public string[] GetAvailableFiles()
296317
{
297318
IntPtr arrayPointer = NativeMethods.BNTransformContextGetAvailableFiles(
@@ -385,4 +406,4 @@ public bool HasRequestedFiles
385406
);
386407
}
387408
}
388-
}
409+
}

‎Handle/BNTransformSession.cs‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ protected override bool ReleaseHandle()
167167
return TransformSession.TakeHandle(result);
168168
}
169169

170+
/// <summary>Creates a transform session rooted at an existing context.</summary>
171+
public static TransformSession? CreateFromTransformContextWithMode(
172+
TransformContext context,
173+
TransformSessionMode mode,
174+
string options = ""
175+
)
176+
{
177+
if (null == context)
178+
{
179+
throw new ArgumentNullException(nameof(context));
180+
}
181+
182+
return TransformSession.TakeHandle(
183+
NativeMethods.BNCreateTransformSessionFromTransformContextWithMode(
184+
context.DangerousGetHandle(),
185+
mode,
186+
options ?? string.Empty
187+
)
188+
);
189+
}
190+
170191
// ===================================================================
171192
// Instance properties
172193
// ===================================================================
@@ -240,6 +261,12 @@ public bool HasSinglePath
240261
}
241262
}
242263

264+
/// <summary>Sets whether transforms should use interactive behavior.</summary>
265+
public void SetInteractive(bool interactive)
266+
{
267+
NativeMethods.BNTransformSessionSetInteractive(this.handle, interactive);
268+
}
269+
243270
/// <summary>
244271
/// Advances this session by one step, executing the current pipeline stage.
245272
/// </summary>
@@ -292,4 +319,4 @@ public bool ProcessFrom(TransformContext context)
292319
);
293320
}
294321
}
295-
}
322+
}

0 commit comments

Comments
 (0)