forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsScriptEngine.cs
More file actions
808 lines (684 loc) · 28.1 KB
/
WindowsScriptEngine.cs
File metadata and controls
808 lines (684 loc) · 28.1 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using Microsoft.ClearScript.Util;
using EXCEPINFO = System.Runtime.InteropServices.ComTypes.EXCEPINFO;
namespace Microsoft.ClearScript.Windows
{
/// <summary>
/// Provides the base implementation for all Windows Script engines.
/// </summary>
/// <remarks>
/// Each Windows Script engine instance has thread affinity and is bound to a
/// <see cref="Dispatcher"/> during instantiation. Attempting to execute script code on a
/// different thread results in an exception. Script delegates and event handlers are marshaled
/// synchronously onto the correct thread.
/// </remarks>
public abstract partial class WindowsScriptEngine : ScriptEngine
{
#region data
private static readonly object nullDispatch = new DispatchWrapper(null);
private ActiveScriptWrapper activeScript;
private WindowsScriptEngineFlags engineFlags;
private readonly HostItemMap hostItemMap = new HostItemMap();
private readonly HostItemCollateral hostItemCollateral = new HostItemCollateral();
private readonly object script;
private ProcessDebugManagerWrapper processDebugManager;
private DebugApplicationWrapper debugApplication;
private uint debugApplicationCookie;
private readonly IUniqueNameManager debugDocumentNameManager = new UniqueFileNameManager();
private bool sourceManagement;
private readonly DebugDocumentMap debugDocumentMap = new DebugDocumentMap();
private uint nextSourceContext = 1;
private readonly Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
private readonly InterlockedOneWayFlag disposedFlag = new InterlockedOneWayFlag();
#endregion
#region constructors
/// <summary>
/// Initializes a new Windows Script engine instance.
/// </summary>
/// <param name="progID">The programmatic identifier (ProgID) of the Windows Script engine class.</param>
/// <param name="name">A name to associate with the instance. Currently this name is used only as a label in presentation contexts such as debugger user interfaces.</param>
/// <param name="flags">A value that selects options for the operation.</param>
/// <remarks>
/// The <paramref name="progID"/> argument can be a class identifier (CLSID) in standard
/// GUID format with braces (e.g., "{F414C260-6AC0-11CF-B6D1-00AA00BBBB58}").
/// </remarks>
protected WindowsScriptEngine(string progID, string name, WindowsScriptEngineFlags flags)
: base(name)
{
AccessContext = typeof(ScriptEngine);
script = base.ScriptInvoke(() =>
{
activeScript = ActiveScriptWrapper.Create(progID, flags);
engineFlags = flags;
if (flags.HasFlag(WindowsScriptEngineFlags.EnableDebugging) && ProcessDebugManagerWrapper.TryCreate(out processDebugManager))
{
processDebugManager.CreateApplication(out debugApplication);
debugApplication.SetName(Name);
if (processDebugManager.TryAddApplication(debugApplication, out debugApplicationCookie))
{
sourceManagement = !flags.HasFlag(WindowsScriptEngineFlags.DisableSourceManagement);
}
else
{
debugApplication.Close();
debugApplication = null;
processDebugManager = null;
}
}
activeScript.SetScriptSite(new ScriptSite(this));
activeScript.InitNew();
activeScript.SetScriptState(ScriptState.Started);
return WindowsScriptItem.Wrap(this, GetScriptDispatch());
});
}
#endregion
#region public members
/// <summary>
/// Gets the <see cref="Dispatcher"/> associated with the current script engine.
/// </summary>
public Dispatcher Dispatcher
{
get
{
VerifyNotDisposed();
return dispatcher;
}
}
/// <summary>
/// Determines whether the calling thread has access to the current script engine.
/// </summary>
/// <returns><c>True</c> if the calling thread has access to the current script engine, <c>false</c> otherwise.</returns>
public bool CheckAccess()
{
VerifyNotDisposed();
return dispatcher.CheckAccess();
}
/// <summary>
/// Enforces that the calling thread has access to the current script engine.
/// </summary>
public void VerifyAccess()
{
VerifyNotDisposed();
dispatcher.VerifyAccess();
}
/// <summary>
/// Gets or sets an interface that supports the display of dialogs on behalf of script code.
/// </summary>
public IHostWindow HostWindow { get; set; }
#endregion
#region internal members
internal abstract IDictionary<int, string> RuntimeErrorMap { get; }
internal abstract IDictionary<int, string> SyntaxErrorMap { get; }
private object GetScriptDispatch()
{
object scriptDispatch;
activeScript.GetScriptDispatch(null, out scriptDispatch);
return scriptDispatch;
}
private void Parse(string documentName, string code, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo, bool discard)
{
var formattedCode = FormatCode ? MiscHelpers.FormatCode(code) : code;
DebugDocument debugDocument;
var sourceContext = CreateDebugDocument(documentName, formattedCode, discard, out debugDocument);
if (sourceContext != UIntPtr.Zero)
{
flags |= ScriptTextFlags.HostManagesSource;
}
try
{
activeScript.ParseScriptText(formattedCode, null, null, null, sourceContext, 0, flags, pVarResult, out excepInfo);
}
finally
{
if (discard && (sourceContext != UIntPtr.Zero))
{
debugDocumentMap.Remove(sourceContext);
debugDocument.Close();
}
}
}
private UIntPtr CreateDebugDocument(string name, string code, bool transient, out DebugDocument document)
{
UIntPtr sourceContext;
if (!sourceManagement)
{
sourceContext = UIntPtr.Zero;
document = null;
}
else
{
sourceContext = new UIntPtr(nextSourceContext++);
var uniqueName = debugDocumentNameManager.GetUniqueName(name, "Script Document");
document = new DebugDocument(this, sourceContext, uniqueName, code, transient);
debugDocumentMap[sourceContext] = document;
}
return sourceContext;
}
private string GetStackTraceInternal()
{
Debug.Assert(processDebugManager != null);
var stackTrace = string.Empty;
IEnumDebugStackFrames enumFrames;
activeScript.EnumStackFrames(out enumFrames);
while (true)
{
DebugStackFrameDescriptor descriptor;
uint countFetched;
enumFrames.Next(1, out descriptor, out countFetched);
if (countFetched < 1)
{
break;
}
try
{
string description;
descriptor.Frame.GetDescriptionString(true, out description);
IDebugCodeContext codeContext;
descriptor.Frame.GetCodeContext(out codeContext);
IDebugDocumentContext documentContext;
codeContext.GetDocumentContext(out documentContext);
if (documentContext == null)
{
stackTrace += MiscHelpers.FormatInvariant(" at {0}\n", description);
}
else
{
IDebugDocument document;
documentContext.GetDocument(out document);
var documentText = (IDebugDocumentText)document;
string documentName;
document.GetName(DocumentNameType.Title, out documentName);
uint position;
uint length;
documentText.GetPositionOfContext(documentContext, out position, out length);
using (var bufferBlock = new CoTaskMemArrayBlock(sizeof(char), (int)length))
{
uint lengthReturned = 0;
documentText.GetText(position, bufferBlock.Addr, IntPtr.Zero, ref lengthReturned, length);
var codeLine = Marshal.PtrToStringUni(bufferBlock.Addr, (int)lengthReturned);
uint lineNumber;
uint offsetInLine;
documentText.GetLineOfPosition(position, out lineNumber, out offsetInLine);
stackTrace += MiscHelpers.FormatInvariant(" at {0} ({1}:{2}:{3}) -> {4}\n", description, documentName, lineNumber, offsetInLine, codeLine);
}
}
}
finally
{
if (descriptor.pFinalObject != IntPtr.Zero)
{
Marshal.Release(descriptor.pFinalObject);
}
}
}
return stackTrace.TrimEnd('\n');
}
private void VerifyNotDisposed()
{
if (disposedFlag.IsSet)
{
throw new ObjectDisposedException(ToString());
}
}
#endregion
#region ScriptEngine overrides (public members)
/// <summary>
/// Allows the host to access script resources directly.
/// </summary>
/// <remarks>
/// The value of this property is an object that is bound to the script engine's root
/// namespace. It dynamically supports properties and methods that correspond to global
/// script objects and functions.
/// </remarks>
public override dynamic Script
{
get
{
VerifyNotDisposed();
return script;
}
}
/// <summary>
/// Gets a string representation of the script call stack.
/// </summary>
/// <returns>The script call stack formatted as a string.</returns>
/// <remarks>
/// <para>
/// This method returns an empty string if the script engine is not executing script code.
/// The stack trace text format is defined by the script engine.
/// </para>
/// <para>
/// The <see cref="WindowsScriptEngine"/> version of this method returns the empty string
/// if script debugging features have not been enabled for the instance.
/// </para>
/// </remarks>
public override string GetStackTrace()
{
VerifyNotDisposed();
return (processDebugManager != null) ? ScriptInvoke(() => GetStackTraceInternal()) : string.Empty;
}
/// <summary>
/// Interrupts script execution and causes the script engine to throw an exception.
/// </summary>
/// <remarks>
/// This method can be called safely from any thread.
/// </remarks>
public override void Interrupt()
{
VerifyNotDisposed();
var excepInfo = new EXCEPINFO { scode = RawCOMHelpers.HResult.E_ABORT };
activeScript.InterruptScriptThread(ScriptThreadID.Base, ref excepInfo, ScriptInterruptFlags.None);
}
/// <summary>
/// Performs garbage collection.
/// </summary>
/// <param name="exhaustive"><c>True</c> to perform exhaustive garbage collection, <c>false</c> to favor speed over completeness.</param>
public override void CollectGarbage(bool exhaustive)
{
VerifyNotDisposed();
ScriptInvoke(() => activeScript.CollectGarbage(exhaustive ? ScriptGCType.Exhaustive : ScriptGCType.Normal));
}
#endregion
#region ScriptEngine overrides (internal members)
internal override void AddHostItem(string itemName, HostItemFlags flags, object item)
{
VerifyNotDisposed();
MiscHelpers.VerifyNonNullArgument(itemName, "itemName");
Debug.Assert(item != null);
ScriptInvoke(() =>
{
object marshaledItem;
if (!flags.HasFlag(HostItemFlags.DirectAccess) || !GetDirectAccessItem(item, out marshaledItem))
{
marshaledItem = MarshalToScript(item, flags);
if (!(marshaledItem is HostItem))
{
throw new InvalidOperationException("Invalid host item");
}
}
var oldItem = ((IDictionary)hostItemMap)[itemName];
hostItemMap[itemName] = marshaledItem;
var nativeFlags = ScriptItemFlags.IsVisible;
if (flags.HasFlag(HostItemFlags.GlobalMembers))
{
nativeFlags |= ScriptItemFlags.GlobalMembers;
}
try
{
activeScript.AddNamedItem(itemName, nativeFlags);
}
catch (Exception)
{
if (oldItem != null)
{
hostItemMap[itemName] = oldItem;
}
else
{
hostItemMap.Remove(itemName);
}
throw;
}
});
}
private static bool GetDirectAccessItem(object item, out object directAccessItem)
{
while (true)
{
var scriptMarshalWrapper = item as IScriptMarshalWrapper;
if (scriptMarshalWrapper != null)
{
item = scriptMarshalWrapper.Unwrap();
continue;
}
var hostTarget = item as HostTarget;
if (hostTarget != null)
{
item = hostTarget.Target;
continue;
}
if ((item != null) && item.GetType().IsCOMObject)
{
directAccessItem = item;
return true;
}
directAccessItem = null;
return false;
}
}
internal override object PrepareResult(object result, Type type, ScriptMemberFlags flags, bool isListIndexResult)
{
var tempResult = base.PrepareResult(result, type, flags, isListIndexResult);
if ((tempResult != null) || !engineFlags.HasFlag(WindowsScriptEngineFlags.MarshalNullAsDispatch))
{
return tempResult;
}
if ((type == typeof(object)) || (type == typeof(string)) || type == typeof(bool?) || type.IsNullableNumeric())
{
return DBNull.Value;
}
return null;
}
internal override object MarshalToScript(object obj, HostItemFlags flags)
{
return MarshalToScriptInternal(obj, flags, null);
}
private object MarshalToScriptInternal(object obj, HostItemFlags flags, HashSet<Array> marshaledArraySet)
{
if (obj == null)
{
if (engineFlags.HasFlag(WindowsScriptEngineFlags.MarshalNullAsDispatch))
{
return nullDispatch;
}
return DBNull.Value;
}
if (obj is Undefined)
{
return null;
}
if (obj is Nonexistent)
{
return null;
}
if (engineFlags.HasFlag(WindowsScriptEngineFlags.MarshalDecimalAsCurrency) && (obj is decimal))
{
return new CurrencyWrapper(obj);
}
var hostItem = obj as HostItem;
if (hostItem != null)
{
if ((hostItem.Engine == this) && (hostItem.Flags == flags))
{
return obj;
}
obj = hostItem.Target;
}
var hostTarget = obj as HostTarget;
if ((hostTarget != null) && !(hostTarget is IHostVariable))
{
obj = hostTarget.Target;
}
var scriptItem = obj as ScriptItem;
if (scriptItem != null)
{
if (scriptItem.Engine == this)
{
return scriptItem.Unwrap();
}
}
if (engineFlags.HasFlag(WindowsScriptEngineFlags.MarshalArraysByValue))
{
var array = obj as Array;
if ((array != null) && ((hostTarget == null) || (typeof(Array).IsAssignableFrom(hostTarget.Type))))
{
bool alreadyMarshaled;
if (marshaledArraySet != null)
{
alreadyMarshaled = marshaledArraySet.Contains(array);
}
else
{
marshaledArraySet = new HashSet<Array>();
alreadyMarshaled = false;
}
if (!alreadyMarshaled)
{
marshaledArraySet.Add(array);
var dimensions = Enumerable.Range(0, array.Rank).ToArray();
var marshaledArray = Array.CreateInstance(typeof(object), dimensions.Select(array.GetLength).ToArray(), dimensions.Select(array.GetLowerBound).ToArray());
array.Iterate(indices => marshaledArray.SetValue(MarshalToScriptInternal(array.GetValue(indices), flags, marshaledArraySet), indices));
return marshaledArray;
}
// COM interop can't handle circularly referenced arrays
return MarshalToScriptInternal(null, flags, marshaledArraySet);
}
}
return HostItem.Wrap(this, hostTarget ?? obj, flags);
}
internal override object MarshalToHost(object obj, bool preserveHostTarget)
{
return MarshalToHostInternal(obj, preserveHostTarget, null);
}
private object MarshalToHostInternal(object obj, bool preserveHostTarget, HashSet<Array> marshaledArraySet)
{
if (obj == null)
{
return Undefined.Value;
}
if (obj is DBNull)
{
return null;
}
object result;
if (MiscHelpers.TryMarshalPrimitiveToHost(obj, out result))
{
return result;
}
var array = obj as Array;
if (array != null)
{
// COM interop converts VBScript arrays to managed arrays
bool alreadyMarshaled;
if (marshaledArraySet != null)
{
alreadyMarshaled = marshaledArraySet.Contains(array);
}
else
{
marshaledArraySet = new HashSet<Array>();
alreadyMarshaled = false;
}
if (!alreadyMarshaled)
{
marshaledArraySet.Add(array);
array.Iterate(indices => array.SetValue(MarshalToHostInternal(array.GetValue(indices), preserveHostTarget, marshaledArraySet), indices));
}
return array;
}
var hostTarget = obj as HostTarget;
if (hostTarget != null)
{
return preserveHostTarget ? hostTarget : hostTarget.Target;
}
var hostItem = obj as HostItem;
if (hostItem != null)
{
return preserveHostTarget ? hostItem.Target : hostItem.Unwrap();
}
if (obj is ScriptItem)
{
return obj;
}
return WindowsScriptItem.Wrap(this, obj);
}
internal override object Execute(string documentName, string code, bool evaluate, bool discard)
{
VerifyNotDisposed();
return ScriptInvoke(() =>
{
EXCEPINFO excepInfo;
if (!evaluate)
{
const ScriptTextFlags flags = ScriptTextFlags.IsVisible;
Parse(documentName, code, flags, IntPtr.Zero, out excepInfo, discard);
return null;
}
using (var resultVariantBlock = new CoTaskMemVariantBlock())
{
const ScriptTextFlags flags = ScriptTextFlags.IsExpression;
Parse(documentName, code, flags, resultVariantBlock.Addr, out excepInfo, discard);
return Marshal.GetObjectForNativeVariant(resultVariantBlock.Addr);
}
});
}
internal override HostItemCollateral HostItemCollateral
{
get { return hostItemCollateral; }
}
#endregion
#region ScriptEngine overrides (host-side invocation)
internal override void HostInvoke(Action action)
{
try
{
base.HostInvoke(action);
}
catch (Exception exception)
{
ThrowHostException(exception);
throw;
}
}
internal override T HostInvoke<T>(Func<T> func)
{
try
{
return base.HostInvoke(func);
}
catch (Exception exception)
{
ThrowHostException(exception);
throw;
}
}
private void ThrowHostException(Exception exception)
{
if (CurrentScriptFrame != null)
{
// Record the host exception in the script frame and throw an easily recognizable
// surrogate across the COM boundary. Recording the host exception enables
// downstream chaining. The surrogate exception indicates to the site that the
// reported script error actually corresponds to the host exception in the frame.
CurrentScriptFrame.HostException = exception;
throw new COMException(exception.Message, RawCOMHelpers.HResult.CLEARSCRIPT_E_HOSTEXCEPTION);
}
}
#endregion
#region ScriptEngine overrides (script-side invocation)
internal override void ScriptInvoke(Action action)
{
VerifyAccess();
base.ScriptInvoke(() =>
{
try
{
action();
}
catch (Exception exception)
{
ThrowScriptError(exception);
throw;
}
});
}
internal override T ScriptInvoke<T>(Func<T> func)
{
VerifyAccess();
return base.ScriptInvoke(() =>
{
try
{
return func();
}
catch (Exception exception)
{
ThrowScriptError(exception);
throw;
}
});
}
private void ThrowScriptError(Exception exception)
{
var comException = exception as COMException;
if (comException != null)
{
if (comException.ErrorCode == RawCOMHelpers.HResult.SCRIPT_E_REPORTED)
{
// a script error was reported; the corresponding exception should be in the script frame
ThrowScriptError(CurrentScriptFrame.ScriptError ?? CurrentScriptFrame.PendingScriptError);
}
else if (comException.ErrorCode == RawCOMHelpers.HResult.CLEARSCRIPT_E_HOSTEXCEPTION)
{
// A host exception surrogate passed through the COM boundary; this happens
// when some script engines are invoked via script item access rather than
// script execution. Chain the host exception to a new script exception.
var hostException = CurrentScriptFrame.HostException;
if (hostException != null)
{
throw new ScriptEngineException(Name, hostException.Message, null, RawCOMHelpers.HResult.CLEARSCRIPT_E_HOSTEXCEPTION, false, true, hostException);
}
}
}
}
#endregion
#region ScriptEngine overrides (synchronized invocation)
internal override void SyncInvoke(Action action)
{
dispatcher.Invoke(DispatcherPriority.Send, action);
}
internal override T SyncInvoke<T>(Func<T> func)
{
return (T)dispatcher.Invoke(DispatcherPriority.Send, func);
}
#endregion
#region ScriptEngine overrides (disposal / finalization)
/// <summary>
/// Releases the unmanaged resources used by the script engine and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><c>True</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
/// <remarks>
/// This method is called by the public <see cref="ScriptEngine.Dispose()"/> method and the
/// <see cref="ScriptEngine.Finalize">Finalize</see> method.
/// <see cref="ScriptEngine.Dispose()"/> invokes the protected <c>Dispose(Boolean)</c>
/// method with the <paramref name="disposing"/> parameter set to <c>true</c>.
/// <see cref="ScriptEngine.Finalize">Finalize</see> invokes <c>Dispose(Boolean)</c> with
/// <paramref name="disposing"/> set to <c>false</c>.
/// </remarks>
protected override void Dispose(bool disposing)
{
if (disposedFlag.Set())
{
if (disposing)
{
if (sourceManagement)
{
debugDocumentMap.Values.ForEach(debugDocument => debugDocument.Close());
}
if (processDebugManager != null)
{
processDebugManager.RemoveApplication(debugApplicationCookie);
debugApplication.Close();
}
((IDisposable)script).Dispose();
activeScript.Close();
}
}
}
#endregion
#region unit test support
internal IEnumerable<string> GetDebugDocumentNames()
{
return debugDocumentMap.Values.Select(debugDocument =>
{
string name;
debugDocument.GetName(DocumentNameType.Title, out name);
return name;
});
}
#endregion
#region Nested type: HostItemMap
private class HostItemMap : Dictionary<string, object>
{
}
#endregion
}
}