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
|
// IWorkspaceObject.cs
//
// Author:
// Lluis Sanchez Gual <lluis@novell.com>
//
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
using System;
using System.Collections.Generic;
using MonoDevelop.Core;
using MonoDevelop.Core.Serialization;
using System.Collections;
using MonoDevelop.Projects.Extensions;
using Mono.Addins;
using System.Linq;
using System.Threading.Tasks;
using System.Runtime.Remoting.Messaging;
using MonoDevelop.Core.StringParsing;
using System.Threading;
using MonoDevelop.Core.AddIns;
namespace MonoDevelop.Projects
{
public abstract class WorkspaceObject: IExtendedDataItem, IFolderItem, IDisposable
{
Hashtable extendedProperties;
bool initializeCalled;
bool isShared;
object localLock = new object ();
ExtensionContext extensionContext;
CancellationTokenSource disposeCancellation = new CancellationTokenSource ();
HashSet<Task> activeTasks = new HashSet<Task> ();
internal protected void Initialize<T> (T instance)
{
if (instance.GetType () != typeof(T))
return;
var delayedInitialize = CallContext.LogicalGetData ("MonoDevelop.DelayItemInitialization");
if (delayedInitialize != null && (bool)delayedInitialize)
return;
EnsureInitialized ();
}
internal void EnsureInitialized ()
{
if (!initializeCalled) {
initializeCalled = true;
extensionContext = CreateExtensionContext (this);
OnInitialize ();
InitializeExtensionChain ();
OnExtensionChainInitialized ();
}
}
protected void AssertMainThread ()
{
if (isShared)
Runtime.AssertMainThread ();
}
/// <summary>
/// This CancellationTokenSource is used to cancel all async operations when the object is disposed.
/// </summary>
protected CancellationToken InstanceCancellationToken {
get { return disposeCancellation.Token; }
}
/// <summary>
/// Binds a task to this object. The object will track the task execution and if the object is disposed,
/// it will try to cancel the task and will wait for the task to end.
/// </summary>
/// <returns>The task returned by the provided lambda.</returns>
/// <param name="f">A lambda that takes a CancellationToken token as argument and returns the task
/// to be tracked. The provided CancellationToken will be signalled when the object is disposed.</param>
/// <typeparam name="T">Task return type</typeparam>
public Task<T> BindTask<T> (Func<CancellationToken, Task<T>> f)
{
var taskCompletionSource = new TaskCompletionSource<bool> ();
lock (activeTasks) {
// Need to register a task before the Func is called otherwise the Dispose could be called whilst the
// Func's Task is being run and before the Func's task is registered.
if (disposeCancellation.IsCancellationRequested)
return Task.FromCanceled<T> (disposeCancellation.Token);
activeTasks.Add (taskCompletionSource.Task);
}
Task<T> t;
try {
t = f (disposeCancellation.Token);
} catch (Exception ex) {
// Do not prevent Project.OnDispose being called by leaving the task on the activeTasks list.
lock (activeTasks) {
taskCompletionSource.SetResult (true);
activeTasks.Remove (taskCompletionSource.Task);
}
return Task.FromException<T> (ex);
}
t.ContinueWith (tr => {
lock (activeTasks) {
taskCompletionSource.SetResult (true);
activeTasks.Remove (taskCompletionSource.Task);
}
});
return t;
}
/// <summary>
/// Binds a task to this object. The object will track the task execution and if the object is disposed,
/// it will try to cancel the task and will wait for the task to end.
/// </summary>
/// <returns>The task returned by the provided lambda.</returns>
/// <param name="f">A lambda that takes a CancellationToken token as argument and returns the task
/// to be tracked. The provided CancellationToken will be signalled when the object is disposed.</param>
public Task BindTask (Func<CancellationToken, Task> f)
{
var taskCompletionSource = new TaskCompletionSource<bool> ();
lock (activeTasks) {
// Need to register a task before the Func is called otherwise the Dispose could be called whilst the
// Func's Task is being run and before the Func's task is registered.
if (disposeCancellation.IsCancellationRequested)
return Task.FromCanceled (disposeCancellation.Token);
activeTasks.Add (taskCompletionSource.Task);
}
Task t;
try {
t = f (disposeCancellation.Token);
} catch (Exception ex) {
// Do not prevent Project.OnDispose being called by leaving the task on the activeTasks list.
lock (activeTasks) {
taskCompletionSource.SetResult (true);
activeTasks.Remove (taskCompletionSource.Task);
}
return Task.FromException (ex);
}
t.ContinueWith (tr => {
lock (activeTasks) {
taskCompletionSource.SetResult (true);
activeTasks.Remove (taskCompletionSource.Task);
}
});
return t;
}
/// <summary>
/// Gathers all the tasks for this WorkspaceObject and all children that need to finish before
/// this object can be disposed.
/// </summary>
internal void GetAllActiveTasksForDispose (List<Task> tasks)
{
lock (activeTasks) {
disposeCancellation.Cancel ();
tasks.AddRange (activeTasks);
}
foreach (var child in GetChildren ()) {
child.GetAllActiveTasksForDispose (tasks);
}
}
/// <summary>
/// Gets a value indicating whether this instance is shared.
/// </summary>
/// <remarks>Shared objects can only be modified in the main thread</remarks>
public bool IsShared {
get { return isShared; }
}
/// <summary>
/// Sets this object as shared, which means that it is accessible from several threads for reading,
/// but it can only be modified in the main thread
/// </summary>
public void SetShared ()
{
OnSetShared ();
}
protected virtual void OnSetShared ()
{
isShared = true;
ItemExtension.NotifyShared ();
}
public string Name {
get { return OnGetName (); }
}
public FilePath ItemDirectory {
get { return OnGetItemDirectory (); }
}
public FilePath BaseDirectory {
get { return OnGetBaseDirectory (); }
}
public WorkspaceObject ParentObject { get; protected set; }
public IEnumerable<WorkspaceObject> GetChildren ()
{
return OnGetChildren ();
}
public IEnumerable<T> GetAllItems<T> () where T: WorkspaceObject
{
if (this is T)
yield return (T)this;
foreach (var c in OnGetChildren ()) {
foreach (var r in c.GetAllItems<T> ())
yield return r;
}
}
/// <summary>
/// Gets extended properties.
/// </summary>
/// <remarks>
/// This dictionary can be used by add-ins to store arbitrary information about this solution item.
/// Keys and values can be of any type.
/// If a value implements IDisposable, the value will be disposed when this item is disposed.
/// </remarks>
public IDictionary ExtendedProperties {
get {
return OnGetExtendedProperties ();
}
}
/// <summary>
/// Gets a value indicating whether this <see cref="MonoDevelop.Projects.SolutionItem"/> has been disposed.
/// </summary>
/// <value>
/// <c>true</c> if disposed; otherwise, <c>false</c>.
/// </value>
internal protected bool Disposed { get; private set; }
public void Dispose ()
{
AssertMainThread ();
if (Disposed)
return;
Disposed = true;
var allTasks = new List<Task> ();
GetAllActiveTasksForDispose (allTasks);
if (allTasks.Count > 0)
Task.WhenAll (allTasks).ContinueWith (t => OnDispose (), TaskScheduler.FromCurrentSynchronizationContext ());
else
OnDispose ();
}
protected virtual void OnDispose ()
{
if (extensionChain != null) {
extensionChain.Dispose ();
extensionChain = null;
}
if (extendedProperties != null) {
foreach (object ob in extendedProperties.Values) {
IDisposable disp = ob as IDisposable;
if (disp != null)
disp.Dispose ();
}
extendedProperties = null;
}
}
/// <summary>
/// Gets a service instance of a given type
/// </summary>
/// <returns>
/// The service.
/// </returns>
/// <typeparam name='T'>
/// Type of the service
/// </typeparam>
/// <remarks>
/// This method looks for an imlpementation of a service of the given type.
/// </remarks>
public T GetService<T> ()
{
return (T) GetService (typeof(T));
}
/// <summary>
/// Gets a service instance of a given type
/// </summary>
/// <returns>
/// The service.
/// </returns>
/// <param name='t'>
/// Type of the service
/// </param>
/// <remarks>
/// This method looks for an imlpementation of a service of the given type.
/// </remarks>
public object GetService (Type t)
{
return ItemExtension.GetService (t);
}
public StringTagModelDescription GetStringTagModelDescription (ConfigurationSelector conf)
{
return ItemExtension.OnGetStringTagModelDescription (conf);
}
protected virtual StringTagModelDescription OnGetStringTagModelDescription (ConfigurationSelector conf)
{
var m = new StringTagModelDescription ();
m.Add (GetType ());
return m;
}
/// <summary>
/// Gets the string tag model for this solution item
/// </summary>
/// <returns>
/// The string tag model
/// </returns>
/// <param name='conf'>
/// Configuration for which to get the string tag model
/// </param>
public StringTagModel GetStringTagModel (ConfigurationSelector conf)
{
return ItemExtension.OnGetStringTagModel (conf);
}
protected virtual StringTagModel OnGetStringTagModel (ConfigurationSelector conf)
{
var m = new StringTagModel ();
m.Add (this);
return m;
}
/// <summary>
/// Gets a value indicating whether the extension chain for this object has already been created and initialized
/// </summary>
protected bool IsExtensionChainCreated {
get { return extensionChain != null; }
}
ExtensionChain extensionChain;
protected ExtensionChain ExtensionChain {
get {
AssertExtensionChainCreated ();
return extensionChain;
}
}
protected void AssertExtensionChainCreated ()
{
if (extensionChain == null) {
if (!initializeCalled)
throw new InvalidOperationException ("The constructor of type " + GetType () + " must call Initialize(this)");
else
throw new InvalidOperationException ("The extension chain can't be used before OnExtensionChainInitialized() method is called");
}
}
public ExtensionContext ExtensionContext {
get {
return this.extensionContext;
}
}
WorkspaceObjectExtension itemExtension;
WorkspaceObjectExtension ItemExtension {
get {
if (itemExtension == null)
AssertExtensionChainCreated ();
return itemExtension;
}
}
public void AttachExtension (WorkspaceObjectExtension ext)
{
AssertMainThread ();
ExtensionChain.AddExtension (ext);
ext.Init (this);
}
public void DetachExtension (WorkspaceObjectExtension ext)
{
AssertMainThread ();
ExtensionChain.RemoveExtension (ext);
}
void InitializeExtensionChain ()
{
// Create an initial empty extension chain. This avoid crashes in case a call to SupportsObject ends
// calling methods from the extension
var tempExtensions = new List<WorkspaceObjectExtension> ();
tempExtensions.AddRange (CreateDefaultExtensions ().Reverse ());
extensionChain = ExtensionChain.Create (tempExtensions.ToArray ());
foreach (var e in tempExtensions)
e.Init (this);
// Collect extensions that support this object
var extensions = new List<WorkspaceObjectExtension> ();
foreach (ProjectModelExtensionNode node in GetModelExtensions (extensionContext)) {
if (node.CanHandleObject (this)) {
var ext = node.CreateExtension ();
if (ext.SupportsObject (this)) {
ext.SourceExtensionNode = node;
extensions.Add (ext);
}
}
}
extensionChain.Dispose ();
// Now create the final extension chain
extensions.Reverse ();
var defaultExts = CreateDefaultExtensions ().ToList ();
defaultExts.Reverse ();
extensions.AddRange (defaultExts);
extensionChain = ExtensionChain.Create (extensions.ToArray ());
extensionChain.SetDefaultInsertionPosition (defaultExts.FirstOrDefault ());
foreach (var e in extensions)
e.Init (this);
itemExtension = ExtensionChain.GetExtension<WorkspaceObjectExtension> ();
foreach (var e in extensions)
e.OnExtensionChainCreated ();
}
static ProjectModelExtensionNode[] modelExtensions;
internal static IEnumerable<ProjectModelExtensionNode> GetModelExtensions (ExtensionContext ctx)
{
if (ctx != null) {
return Runtime.RunInMainThread (() => ctx.GetExtensionNodes (ProjectService.ProjectModelExtensionsPath)).Result.Cast<ProjectModelExtensionNode> ().Concat (customNodes).ToArray ();
}
else {
if (modelExtensions == null)
Runtime.RunInMainThread ((Action)InitExtensions).Wait ();
return modelExtensions;
}
}
static void InitExtensions ()
{
AddinManager.ExtensionChanged += OnExtensionsChanged;
LoadExtensions ();
}
static void OnExtensionsChanged (object sender, ExtensionEventArgs args)
{
if (args.Path == ProjectService.ProjectModelExtensionsPath)
LoadExtensions ();
}
static void LoadExtensions ()
{
// Create a context for loading the default extensions. The context is necessary because
// the conditions declared in the extension point must always be present.
var extensionContext = CreateExtensionContext (null);
modelExtensions = extensionContext.GetExtensionNodes<ProjectModelExtensionNode> (ProjectService.ProjectModelExtensionsPath).Concat (customNodes).ToArray ();
}
static ExtensionContext CreateExtensionContext (WorkspaceObject targetObject)
{
var extensionContext = AddinManager.CreateExtensionContext ();
if (targetObject == null) {
extensionContext.RegisterCondition ("ItemType", FalseCondition.Instance);
extensionContext.RegisterCondition ("AppliesTo", FalseCondition.Instance);
} else {
extensionContext.RegisterCondition ("ItemType", new ItemTypeCondition (targetObject.GetType ()));
extensionContext.RegisterCondition ("AppliesTo", new AppliesToCondition (targetObject));
}
return extensionContext;
}
/// <summary>
/// Ensures that this project has the extensions it requires according to its current state
/// </summary>
/// <remarks>
/// This method will load new extensions that this project supports and will unload extensions that are not supported anymore.
/// The set of extensions that a project supports may change over time, depending on the status of the project.
/// </remarks>
public void RefreshExtensions ()
{
// First of all look for new extensions that should be attached
// Get the list of nodes for which an extension has been created
var allExtensions = extensionChain.GetAllExtensions ().OfType<WorkspaceObjectExtension> ().ToList ();
var loadedNodes = allExtensions.Where (ex => ex.SourceExtensionNode != null)
.Select (ex => ex.SourceExtensionNode.Id).ToList ();
var newExtensions = new List <WorkspaceObjectExtension> ();
ProjectModelExtensionNode lastAddedNode = null;
// Ensure conditions are re-evaluated.
extensionContext = CreateExtensionContext (this);
using (extensionChain.BatchModify ()) {
foreach (ProjectModelExtensionNode node in GetModelExtensions (extensionContext)) {
// If the node already generated an extension, skip it
if (loadedNodes.Contains (node.Id)) {
lastAddedNode = node;
loadedNodes.Remove (node.Id);
continue;
}
// Maybe the node can now generate an extension for this project
if (node.CanHandleObject (this)) {
var ext = node.CreateExtension ();
if (ext.SupportsObject (this)) {
ext.SourceExtensionNode = node;
newExtensions.Add (ext);
if (lastAddedNode != null) {
// There is an extension before this one. Find it and add the new extension after it.
var prevExtension = allExtensions.FirstOrDefault (ex => ex.SourceExtensionNode?.Id == lastAddedNode.Id);
extensionChain.AddExtension (ext, prevExtension);
} else
extensionChain.AddExtension (ext);
ext.Init (this);
}
}
}
// Now dispose extensions that are not supported anymore
foreach (var ext in allExtensions) {
if (!ext.SupportsObject (this))
ext.Dispose ();
}
if (loadedNodes.Any ()) {
foreach (var ext in allExtensions.Where (ex => ex.SourceExtensionNode != null)) {
if (loadedNodes.Contains (ext.SourceExtensionNode.Id)) {
ext.Dispose ();
loadedNodes.Remove (ext.SourceExtensionNode.Id);
}
}
}
}
foreach (var e in newExtensions)
e.OnExtensionChainCreated ();
foreach (var e in newExtensions)
OnExtensionActivated (e);
}
static List<ProjectModelExtensionNode> customNodes = new List<ProjectModelExtensionNode> ();
internal static void RegisterCustomExtension (ProjectModelExtensionNode node)
{
customNodes.Add (node);
LoadExtensions ();
}
internal static void UnregisterCustomExtension (ProjectModelExtensionNode node)
{
customNodes.Remove (node);
LoadExtensions ();
}
protected virtual IEnumerable<WorkspaceObjectExtension> CreateDefaultExtensions ()
{
yield return new DefaultWorkspaceObjectExtension ();
}
/// <summary>
/// Called after the object is created, but before the extension chain has been created.
/// </summary>
protected virtual void OnInitialize ()
{
}
/// <summary>
/// Called when the extension chain for this object has been created. This method can be overriden
/// to do initializations on the object that require access to the extension chain
/// </summary>
protected virtual void OnExtensionChainInitialized ()
{
}
/// <summary>
/// Called when an extension is dynamically loaded after object initialization
/// </summary>
/// <param name="extension">The extension.</param>
/// <remarks>
/// This method is called when an extension is loaded after the object initialization process.
/// This may happen for example when calling RefreshExtensions.
/// </remarks>
protected virtual void OnExtensionActivated (WorkspaceObjectExtension extension)
{
}
internal virtual IDictionary OnGetExtendedProperties ()
{
lock (localLock) {
if (extendedProperties == null)
extendedProperties = new Hashtable ();
return extendedProperties;
}
}
protected virtual IEnumerable<WorkspaceObject> OnGetChildren ()
{
yield break;
}
protected virtual object OnGetService (Type t)
{
return t.IsInstanceOfType (this) ? this : null;
}
protected abstract string OnGetName ();
protected abstract string OnGetItemDirectory ();
protected abstract string OnGetBaseDirectory ();
internal class DefaultWorkspaceObjectExtension: WorkspaceObjectExtension
{
internal protected override object GetService (Type t)
{
return Owner.OnGetService (t);
}
internal protected override StringTagModelDescription OnGetStringTagModelDescription (ConfigurationSelector conf)
{
return Owner.OnGetStringTagModelDescription (conf);
}
internal protected override StringTagModel OnGetStringTagModel (ConfigurationSelector conf)
{
return Owner.OnGetStringTagModel (conf);
}
}
protected Task<IDisposable> ReadLock ()
{
lock (lockLock) {
var ts = new TaskCompletionSource<IDisposable> ();
var ol = new ObjectLock { Object = this, IsWriteLock = false, TaskSource = ts };
if (writeLockTaken) {
if (lockRequests == null)
lockRequests = new Queue<ObjectLock> ();
lockRequests.Enqueue (ol);
} else {
readLocksTaken++;
ts.SetResult (ol);
}
return ts.Task;
}
}
protected Task<IDisposable> WriteLock ()
{
lock (lockLock) {
var ts = new TaskCompletionSource<IDisposable> ();
var ol = new ObjectLock { Object = this, IsWriteLock = true, TaskSource = ts };
if (writeLockTaken || readLocksTaken > 0) {
if (lockRequests == null)
lockRequests = new Queue<ObjectLock> ();
lockRequests.Enqueue (ol);
} else {
writeLockTaken = true;
ts.SetResult (ol);
}
return ts.Task;
}
}
void ReleaseLock (bool isWriteLock)
{
lock (lockLock) {
if (!isWriteLock) {
// If there are readers still running, we can't release the lock
if (--readLocksTaken > 0)
return;
}
while (lockRequests != null && lockRequests.Count > 0) {
// If readers have been awakened, we can't awaken a writer
if (readLocksTaken > 0 && lockRequests.Peek ().IsWriteLock)
return;
var next = lockRequests.Dequeue ();
if (next.IsWriteLock) {
// Only one writer at a time
next.TaskSource.SetResult (next);
return;
} else {
// All readers can be awakened at once
writeLockTaken = false;
readLocksTaken++;
next.TaskSource.SetResult (next);
}
}
writeLockTaken = false;
}
}
class ObjectLock: IDisposable
{
public WorkspaceObject Object;
public bool IsWriteLock;
public TaskCompletionSource<IDisposable> TaskSource;
public void Dispose ()
{
Object.ReleaseLock (IsWriteLock);
}
}
Queue<ObjectLock> lockRequests;
int readLocksTaken;
bool writeLockTaken;
object lockLock = new object ();
}
public static class WorkspaceObjectExtensions
{
public static T As<T> (this WorkspaceObject ob) where T:class
{
return ob != null ? ob.GetService<T> () : null;
}
}
public interface IWorkspaceFileObject: IFileItem, IDisposable
{
IEnumerable<FilePath> GetItemFiles (bool includeReferencedFiles);
new FilePath FileName { get; set; }
bool NeedsReload { get; set; }
bool ItemFilesChanged { get; }
Task SaveAsync (ProgressMonitor monitor);
string Name { get; set; }
FilePath BaseDirectory { get; }
FilePath ItemDirectory { get; }
}
}
|