~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects/SolutionItem.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
using MonoDevelop.Core.Collections;
38
38
using MonoDevelop.Core.StringParsing;
39
39
using MonoDevelop.Core.Instrumentation;
 
40
using MonoDevelop.Projects.Policies;
40
41
 
41
42
namespace MonoDevelop.Projects
42
43
{
43
 
        public abstract class SolutionItem: IExtendedDataItem, IBuildTarget, ILoadController
 
44
        public abstract class SolutionItem: IExtendedDataItem, IBuildTarget, ILoadController, IPolicyProvider
44
45
        {
45
46
                SolutionFolder parentFolder;
46
47
                Solution parentSolution;
58
59
                
59
60
                PropertyBag userProperties;
60
61
                
 
62
                /// <summary>
 
63
                /// Initializes a new instance of the <see cref="MonoDevelop.Projects.SolutionItem"/> class.
 
64
                /// </summary>
61
65
                public SolutionItem()
62
66
                {
63
67
                        ProjectExtensionUtil.LoadControl (this);
64
68
                }
65
69
                
 
70
                /// <summary>
 
71
                /// Initializes a new instance of this item, using an xml element as template
 
72
                /// </summary>
 
73
                /// <param name='template'>
 
74
                /// The template
 
75
                /// </param>
66
76
                public virtual void InitializeFromTemplate (XmlElement template)
67
77
                {
68
78
                }
69
79
                
 
80
                /// <summary>
 
81
                /// Gets the handler for this solution item
 
82
                /// </summary>
 
83
                /// <value>
 
84
                /// The solution item handler.
 
85
                /// </value>
 
86
                /// <exception cref='InvalidOperationException'>
 
87
                /// Is thrown if there isn't a ISolutionItemHandler for this solution item
 
88
                /// </exception>
70
89
                protected internal ISolutionItemHandler ItemHandler {
71
90
                        get {
72
91
                                if (handler == null) {
78
97
                        }
79
98
                }
80
99
                
 
100
                /// <summary>
 
101
                /// Sets the handler for this solution item
 
102
                /// </summary>
 
103
                /// <param name='handler'>
 
104
                /// A handler.
 
105
                /// </param>
81
106
                internal virtual void SetItemHandler (ISolutionItemHandler handler)
82
107
                {
83
108
                        if (this.handler != null)
91
116
                        return this.handler;
92
117
                }
93
118
                
 
119
                /// <summary>
 
120
                /// Gets the author information for this solution item, inherited from the solution and global settings.
 
121
                /// </summary>
 
122
                public AuthorInformation AuthorInformation {
 
123
                        get {
 
124
                                if (ParentSolution != null)
 
125
                                        return ParentSolution.AuthorInformation;
 
126
                                else
 
127
                                        return AuthorInformation.Default;
 
128
                        }
 
129
                }
 
130
                
 
131
                /// <summary>
 
132
                /// Gets a service instance of a given type
 
133
                /// </summary>
 
134
                /// <returns>
 
135
                /// The service.
 
136
                /// </returns>
 
137
                /// <typeparam name='T'>
 
138
                /// Type of the service
 
139
                /// </typeparam>
 
140
                /// <remarks>
 
141
                /// This method looks for an imlpementation of a service of the given type.
 
142
                /// </remarks>
94
143
                public T GetService<T> () where T: class
95
144
                {
96
145
                        return (T) GetService (typeof(T));
97
146
                }
98
 
                
 
147
 
 
148
                /// <summary>
 
149
                /// Gets a service instance of a given type
 
150
                /// </summary>
 
151
                /// <returns>
 
152
                /// The service.
 
153
                /// </returns>
 
154
                /// <param name='t'>
 
155
                /// Type of the service
 
156
                /// </param>
 
157
                /// <remarks>
 
158
                /// This method looks for an imlpementation of a service of the given type.
 
159
                /// The default implementation this instance if the type is an interface
 
160
                /// implemented by this instance. Otherwise, it looks for a service in
 
161
                /// the project extension chain.
 
162
                /// </remarks>
99
163
                public virtual object GetService (Type t)
100
164
                {
101
165
                        if (t.IsInstanceOfType (this))
103
167
                        return Services.ProjectService.GetExtensionChain (this).GetService (this, t);
104
168
                }
105
169
                
 
170
                /// <summary>
 
171
                /// Gets the solution to which this item belongs
 
172
                /// </summary>
106
173
                public Solution ParentSolution {
107
174
                        get {
108
175
                                if (parentFolder != null)
113
180
                                parentSolution = value;
114
181
                        }
115
182
                }
116
 
                
 
183
 
 
184
                /// <summary>
 
185
                /// Gets a value indicating whether this item is currently being loaded from a file
 
186
                /// </summary>
 
187
                /// <remarks>
 
188
                /// While an item is loading, some events such as project file change events may be fired.
 
189
                /// This flag can be used to check if change events are caused by data being loaded.
 
190
                /// </remarks>
117
191
                public bool Loading {
118
192
                        get { return loading > 0; }
119
193
                }
120
194
                
 
195
                /// <summary>
 
196
                /// Saves the solution item
 
197
                /// </summary>
 
198
                /// <param name='monitor'>
 
199
                /// A progress monitor.
 
200
                /// </param>
121
201
                public abstract void Save (IProgressMonitor monitor);
122
202
                
 
203
                /// <summary>
 
204
                /// Name of the solution item
 
205
                /// </summary>
123
206
                public abstract string Name { get; set; }
124
207
                
 
208
                /// <summary>
 
209
                /// Gets or sets the base directory of this solution item
 
210
                /// </summary>
 
211
                /// <value>
 
212
                /// The base directory.
 
213
                /// </value>
 
214
                /// <remarks>
 
215
                /// The base directory is the directory where files belonging to this project
 
216
                /// are placed. Notice that this directory may be different than the directory
 
217
                /// where the project file is placed.
 
218
                /// </remarks>
125
219
                public FilePath BaseDirectory {
126
220
                        get {
127
221
                                if (baseDirectory == null) {
145
239
                        }
146
240
                }
147
241
                
 
242
                /// <summary>
 
243
                /// Gets the directory where this solution item is placed
 
244
                /// </summary>
148
245
                public FilePath ItemDirectory {
149
246
                        get {
150
247
                                FilePath dir = GetDefaultBaseDirectory ();
157
254
                internal bool HasCustomBaseDirectory {
158
255
                        get { return baseDirectory != null; }
159
256
                }
160
 
 
 
257
                
 
258
                /// <summary>
 
259
                /// Gets the default base directory.
 
260
                /// </summary>
 
261
                /// <remarks>
 
262
                /// The base directory is the directory where files belonging to this project
 
263
                /// are placed. Notice that this directory may be different than the directory
 
264
                /// where the project file is placed.
 
265
                /// </remarks>
161
266
                protected virtual FilePath GetDefaultBaseDirectory ( )
162
267
                {
163
268
                        return ParentSolution.BaseDirectory;
164
269
                }
165
 
                
 
270
 
 
271
                /// <summary>
 
272
                /// Gets the identifier of this solution item
 
273
                /// </summary>
 
274
                /// <remarks>
 
275
                /// The identifier is unique inside the solution
 
276
                /// </remarks>
166
277
                public string ItemId {
167
278
                        get { return ItemHandler.ItemId; }
168
279
                }
169
280
                
 
281
                /// <summary>
 
282
                /// Gets extended properties.
 
283
                /// </summary>
 
284
                /// <remarks>
 
285
                /// This dictionary can be used by add-ins to store arbitrary information about this solution item.
 
286
                /// Keys and values can be of any type.
 
287
                /// If a value implements IDisposable, the value will be disposed when this solution item is disposed.
 
288
                /// Values in this dictionary won't be serialized, unless they are registered as serializable using
 
289
                /// the /MonoDevelop/ProjectModel/ExtendedProperties extension point.
 
290
                /// </remarks>
170
291
                public IDictionary ExtendedProperties {
171
292
                        get { return InternalGetExtendedProperties; }
172
293
                }
173
294
                
 
295
                /// <summary>
 
296
                /// Gets policies.
 
297
                /// </summary>
 
298
                /// <remarks>
 
299
                /// Returns a policy container which can be used to query policies specific for this
 
300
                /// solution item. If a policy is not defined for this item, the inherited value will be returned.
 
301
                /// </remarks>
174
302
                public MonoDevelop.Projects.Policies.PolicyBag Policies {
175
303
                        get {
176
304
                                //newly created (i.e. not deserialised) SolutionItems may have a null PolicyBag
186
314
                        }
187
315
                }
188
316
                
189
 
                // User properties are only loaded when the project is loaded in the IDE.
 
317
                PolicyContainer IPolicyProvider.Policies {
 
318
                        get {
 
319
                                return Policies;
 
320
                        }
 
321
                }
 
322
                
 
323
                /// <summary>
 
324
                /// Gets solution item properties specific to the current user
 
325
                /// </summary>
 
326
                /// <remarks>
 
327
                /// These properties are not stored in the project file, but in a separate file which is not to be shared
 
328
                /// with other users.
 
329
                /// User properties are only loaded when the project is loaded inside the IDE.
 
330
                /// </remarks>
190
331
                public PropertyBag UserProperties {
191
332
                        get {
192
333
                                if (userProperties == null)
195
336
                        }
196
337
                }
197
338
                
198
 
                // Initializes the user properties of the item
 
339
                /// <summary>
 
340
                /// Initializes the user properties of the item
 
341
                /// </summary>
 
342
                /// <param name='properties'>
 
343
                /// Properties to be set
 
344
                /// </param>
 
345
                /// <exception cref='InvalidOperationException'>
 
346
                /// The user properties have already been set
 
347
                /// </exception>
 
348
                /// <remarks>
 
349
                /// This method is used by the IDE to initialize the user properties when a project is loaded.
 
350
                /// </remarks>
199
351
                public void LoadUserProperties (PropertyBag properties)
200
352
                {
201
353
                        if (userProperties != null)
203
355
                        userProperties = properties;
204
356
                }
205
357
                
 
358
                /// <summary>
 
359
                /// Gets the parent solution folder.
 
360
                /// </summary>
206
361
                public SolutionFolder ParentFolder {
207
362
                        get {
208
363
                                return parentFolder;
213
368
                                        internalChildren.ParentFolder = value;
214
369
                        }
215
370
                }
216
 
                
 
371
 
 
372
                /// <summary>
 
373
                /// Gets a value indicating whether this <see cref="MonoDevelop.Projects.SolutionItem"/> has been disposed.
 
374
                /// </summary>
 
375
                /// <value>
 
376
                /// <c>true</c> if disposed; otherwise, <c>false</c>.
 
377
                /// </value>
 
378
                internal protected bool Disposed { get; private set; }
 
379
 
 
380
                /// <summary>
 
381
                /// Releases all resource used by the <see cref="MonoDevelop.Projects.SolutionItem"/> object.
 
382
                /// </summary>
 
383
                /// <remarks>
 
384
                /// Call <see cref="Dispose"/> when you are finished using the <see cref="MonoDevelop.Projects.SolutionItem"/>. The
 
385
                /// <see cref="Dispose"/> method leaves the <see cref="MonoDevelop.Projects.SolutionItem"/> in an unusable state.
 
386
                /// After calling <see cref="Dispose"/>, you must release all references to the
 
387
                /// <see cref="MonoDevelop.Projects.SolutionItem"/> so the garbage collector can reclaim the memory that the
 
388
                /// <see cref="MonoDevelop.Projects.SolutionItem"/> was occupying.
 
389
                /// </remarks>
217
390
                public virtual void Dispose ()
218
391
                {
 
392
                        Disposed = true;
 
393
                        
219
394
                        if (extendedProperties != null) {
220
395
                                foreach (object ob in extendedProperties.Values) {
221
396
                                        IDisposable disp = ob as IDisposable;
222
397
                                        if (disp != null)
223
398
                                                disp.Dispose ();
224
399
                                }
 
400
                                extendedProperties = null;
225
401
                        }
226
 
                        if (handler != null)
 
402
                        if (handler != null) {
227
403
                                handler.Dispose ();
228
 
                        if (userProperties != null)
 
404
                                // handler = null;
 
405
                        }
 
406
                        if (userProperties != null) {
229
407
                                ((IDisposable)userProperties).Dispose ();
 
408
                                userProperties = null;
 
409
                        }
 
410
                        
 
411
                        // parentFolder = null;
 
412
                        // parentSolution = null;
 
413
                        // internalChildren = null;
 
414
                        // policies = null;
230
415
                }
231
416
                
 
417
                /// <summary>
 
418
                /// Gets solution items referenced by this instance (items on which this item depends)
 
419
                /// </summary>
 
420
                /// <returns>
 
421
                /// The referenced items.
 
422
                /// </returns>
 
423
                /// <param name='configuration'>
 
424
                /// Configuration for which to get the referenced items
 
425
                /// </param>
232
426
                public virtual IEnumerable<SolutionItem> GetReferencedItems (ConfigurationSelector configuration)
233
427
                {
234
428
                        return new SolutionItem [0];
235
429
                }
236
430
                
 
431
                /// <summary>
 
432
                /// Runs a build or execution target.
 
433
                /// </summary>
 
434
                /// <returns>
 
435
                /// The result of the operation
 
436
                /// </returns>
 
437
                /// <param name='monitor'>
 
438
                /// A progress monitor
 
439
                /// </param>
 
440
                /// <param name='target'>
 
441
                /// Name of the target
 
442
                /// </param>
 
443
                /// <param name='configuration'>
 
444
                /// Configuration to use to run the target
 
445
                /// </param>
237
446
                public BuildResult RunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration)
238
447
                {
239
448
                        return Services.ProjectService.GetExtensionChain (this).RunTarget (monitor, this, target, configuration);
240
449
                }
241
450
                
 
451
                /// <summary>
 
452
                /// Cleans the files produced by this solution item
 
453
                /// </summary>
 
454
                /// <param name='monitor'>
 
455
                /// A progress monitor
 
456
                /// </param>
 
457
                /// <param name='configuration'>
 
458
                /// Configuration to use to clean the project
 
459
                /// </param>
242
460
                public void Clean (IProgressMonitor monitor, ConfigurationSelector configuration)
243
461
                {
244
462
                        RunTarget (monitor, ProjectService.CleanTarget, configuration);
245
463
                }
246
464
                
 
465
                /// <summary>
 
466
                /// Builds the solution item
 
467
                /// </summary>
 
468
                /// <param name='monitor'>
 
469
                /// A progress monitor
 
470
                /// </param>
 
471
                /// <param name='configuration'>
 
472
                /// Configuration to use to build the project
 
473
                /// </param>
247
474
                public BuildResult Build (IProgressMonitor monitor, ConfigurationSelector configuration)
248
475
                {
249
476
                        return Build (monitor, configuration, false);
250
477
                }
251
478
                
 
479
                /// <summary>
 
480
                /// Builds the solution item
 
481
                /// </summary>
 
482
                /// <param name='monitor'>
 
483
                /// A progress monitor
 
484
                /// </param>
 
485
                /// <param name='configuration'>
 
486
                /// Configuration to use to build the project
 
487
                /// </param>
 
488
                /// <param name='buildReferences'>
 
489
                /// When set to <c>true</c>, the referenced items will be built before building this item
 
490
                /// </param>
252
491
                public BuildResult Build (IProgressMonitor monitor, ConfigurationSelector solutionConfiguration, bool buildReferences)
253
492
                {
254
493
                        ITimeTracker tt = Counters.BuildProjectTimer.BeginTiming ("Building " + Name);
312
551
                        return false;
313
552
                }
314
553
                
 
554
                /// <summary>
 
555
                /// Gets the time of the last build
 
556
                /// </summary>
 
557
                /// <returns>
 
558
                /// The last build time.
 
559
                /// </returns>
 
560
                /// <param name='configuration'>
 
561
                /// Configuration for which to get the last build time.
 
562
                /// </param>
315
563
                public DateTime GetLastBuildTime (ConfigurationSelector configuration)
316
564
                {
317
565
                        return OnGetLastBuildTime (configuration);
329
577
                                GetBuildableReferencedItems (visited, referenced, ritem, configuration);
330
578
                }
331
579
                
 
580
                /// <summary>
 
581
                /// Executes this solution item
 
582
                /// </summary>
 
583
                /// <param name='monitor'>
 
584
                /// A progress monitor
 
585
                /// </param>
 
586
                /// <param name='context'>
 
587
                /// An execution context
 
588
                /// </param>
 
589
                /// <param name='configuration'>
 
590
                /// Configuration to use to execute the item
 
591
                /// </param>
332
592
                public void Execute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
333
593
                {
334
594
                        Services.ProjectService.GetExtensionChain (this).Execute (monitor, this, context, configuration);
335
595
                }
336
596
                
 
597
                /// <summary>
 
598
                /// Determines whether this solution item can be executed using the specified context and configuration.
 
599
                /// </summary>
 
600
                /// <returns>
 
601
                /// <c>true</c> if this instance can be executed; otherwise, <c>false</c>.
 
602
                /// </returns>
 
603
                /// <param name='context'>
 
604
                /// An execution context
 
605
                /// </param>
 
606
                /// <param name='configuration'>
 
607
                /// Configuration to use to execute the item
 
608
                /// </param>
337
609
                public bool CanExecute (ExecutionContext context, ConfigurationSelector configuration)
338
610
                {
339
611
                        return Services.ProjectService.GetExtensionChain (this).CanExecute (this, context, configuration);
340
612
                }
341
613
                
 
614
                /// <summary>
 
615
                /// Checks if this solution item has modified files and has to be built
 
616
                /// </summary>
 
617
                /// <returns>
 
618
                /// <c>true</c> if the solution item has to be built
 
619
                /// </returns>
 
620
                /// <param name='configuration'>
 
621
                /// Configuration for which to do the check
 
622
                /// </param>
342
623
                public bool NeedsBuilding (ConfigurationSelector configuration)
343
624
                {
344
625
                        using (Counters.NeedsBuildingTimer.BeginTiming ("NeedsBuilding check for " + Name)) {
351
632
                        }
352
633
                }
353
634
                
 
635
                /// <summary>
 
636
                /// States whether this solution item needs to be built or not
 
637
                /// </summary>
 
638
                /// <param name='value'>
 
639
                /// Whether this solution item needs to be built or not
 
640
                /// </param>
 
641
                /// <param name='configuration'>
 
642
                /// Configuration for which to set the flag
 
643
                /// </param>
354
644
                public void SetNeedsBuilding (bool value, ConfigurationSelector configuration)
355
645
                {
356
646
                        Services.ProjectService.GetExtensionChain (this).SetNeedsBuilding (this, value, configuration);
357
647
                }
358
648
                
 
649
                /// <summary>
 
650
                /// Gets or sets a value indicating whether this <see cref="MonoDevelop.Projects.SolutionItem"/> needs to be reload due to changes in project or solution file
 
651
                /// </summary>
 
652
                /// <value>
 
653
                /// <c>true</c> if needs reload; otherwise, <c>false</c>.
 
654
                /// </value>
359
655
                public virtual bool NeedsReload {
360
656
                        get {
361
657
                                if (ParentSolution != null)
367
663
                        }
368
664
                }
369
665
                
 
666
                /// <summary>
 
667
                /// Registers an internal child item.
 
668
                /// </summary>
 
669
                /// <param name='item'>
 
670
                /// An item
 
671
                /// </param>
 
672
                /// <remarks>
 
673
                /// Some kind of projects may be composed of several child projects.
 
674
                /// By registering those child projects using this method, the child
 
675
                /// projects will be plugged into the parent solution infrastructure
 
676
                /// (so for example, the ParentSolution property for those projects
 
677
                /// will return the correct value)
 
678
                /// </remarks>
370
679
                protected void RegisterInternalChild (SolutionItem item)
371
680
                {
372
681
                        if (internalChildren == null) {
376
685
                        internalChildren.Items.Add (item);
377
686
                }
378
687
                
 
688
                /// <summary>
 
689
                /// Unregisters an internal child item.
 
690
                /// </summary>
 
691
                /// <param name='item'>
 
692
                /// The item
 
693
                /// </param>
379
694
                protected void UnregisterInternalChild (SolutionItem item)
380
695
                {
381
696
                        if (internalChildren != null)
382
697
                                internalChildren.Items.Remove (item);
383
698
                }
384
699
                
 
700
                /// <summary>
 
701
                /// Gets the string tag model description for this solution item
 
702
                /// </summary>
 
703
                /// <returns>
 
704
                /// The string tag model description
 
705
                /// </returns>
 
706
                /// <param name='conf'>
 
707
                /// Configuration for which to get the string tag model description
 
708
                /// </param>
385
709
                public virtual StringTagModelDescription GetStringTagModelDescription (ConfigurationSelector conf)
386
710
                {
387
711
                        StringTagModelDescription model = new StringTagModelDescription ();
390
714
                        return model;
391
715
                }
392
716
                
 
717
                /// <summary>
 
718
                /// Gets the string tag model for this solution item
 
719
                /// </summary>
 
720
                /// <returns>
 
721
                /// The string tag model
 
722
                /// </returns>
 
723
                /// <param name='conf'>
 
724
                /// Configuration for which to get the string tag model
 
725
                /// </param>
393
726
                public virtual StringTagModel GetStringTagModel (ConfigurationSelector conf)
394
727
                {
395
728
                        StringTagModel source = new StringTagModel ();
399
732
                        return source;
400
733
                }
401
734
                
 
735
                /// <summary>
 
736
                /// Sorts a collection of solution items, taking into account the dependencies between them
 
737
                /// </summary>
 
738
                /// <returns>
 
739
                /// The sorted collection of items
 
740
                /// </returns>
 
741
                /// <param name='items'>
 
742
                /// Items to sort
 
743
                /// </param>
 
744
                /// <param name='configuration'>
 
745
                /// A configuration
 
746
                /// </param>
 
747
                /// <remarks>
 
748
                /// This methods sorts a collection of items, ensuring that every item is placed after all the items
 
749
                /// on which it depends.
 
750
                /// </remarks>
402
751
                public static ReadOnlyCollection<T> TopologicalSort<T> (IEnumerable<T> items, ConfigurationSelector configuration) where T: SolutionItem
403
752
                {
404
753
                        IList<T> allItems;
458
807
                        OnEndLoad ();
459
808
                }
460
809
                
 
810
                /// <summary>
 
811
                /// Called when a load operation for this solution item has started
 
812
                /// </summary>
461
813
                protected virtual void OnBeginLoad ()
462
814
                {
463
815
                }
464
816
                
 
817
                /// <summary>
 
818
                /// Called when a load operation for this solution item has finished
 
819
                /// </summary>
465
820
                protected virtual void OnEndLoad ()
466
821
                {
467
822
                }
468
823
                
 
824
                /// <summary>
 
825
                /// Notifies that this solution item has been modified
 
826
                /// </summary>
 
827
                /// <param name='hint'>
 
828
                /// Hint about which part of the solution item has been modified. This will typically be the property name.
 
829
                /// </param>
469
830
                protected void NotifyModified (string hint)
470
831
                {
471
832
                        OnModified (new SolutionItemModifiedEventArgs (this, hint));
472
833
                }
473
834
                
 
835
                /// <summary>
 
836
                /// Raises the modified event.
 
837
                /// </summary>
 
838
                /// <param name='args'>
 
839
                /// Arguments.
 
840
                /// </param>
474
841
                protected virtual void OnModified (SolutionItemModifiedEventArgs args)
475
842
                {
476
 
                        if (Modified != null)
 
843
                        if (Modified != null && !Disposed)
477
844
                                Modified (this, args);
478
845
                }
479
846
                
 
847
                /// <summary>
 
848
                /// Raises the name changed event.
 
849
                /// </summary>
 
850
                /// <param name='e'>
 
851
                /// Arguments.
 
852
                /// </param>
480
853
                protected virtual void OnNameChanged (SolutionItemRenamedEventArgs e)
481
854
                {
482
855
                        NotifyModified ("Name");
483
 
                        if (NameChanged != null)
 
856
                        if (NameChanged != null && !Disposed)
484
857
                                NameChanged (this, e);
485
858
                }
486
859
                
 
860
                /// <summary>
 
861
                /// Initializes the item handler.
 
862
                /// </summary>
 
863
                /// <remarks>
 
864
                /// This method is called the first time an item handler is requested.
 
865
                /// Subclasses should override this method use SetItemHandler to
 
866
                /// assign a handler to this item.
 
867
                /// </remarks>
487
868
                protected virtual void InitializeItemHandler ()
488
869
                {
489
870
                }
490
871
                
 
872
                /// <summary>
 
873
                /// Runs a build or execution target.
 
874
                /// </summary>
 
875
                /// <returns>
 
876
                /// The result of the operation
 
877
                /// </returns>
 
878
                /// <param name='monitor'>
 
879
                /// A progress monitor
 
880
                /// </param>
 
881
                /// <param name='target'>
 
882
                /// Name of the target
 
883
                /// </param>
 
884
                /// <param name='configuration'>
 
885
                /// Configuration to use to run the target
 
886
                /// </param>
 
887
                /// <remarks>
 
888
                /// Subclasses can override this method to provide a custom implementation of project operations such as
 
889
                /// build or clean. The default implementation delegates the execution to the more specific OnBuild
 
890
                /// and OnClean methods, or to the item handler for other targets.
 
891
                /// </remarks>
491
892
                internal protected virtual BuildResult OnRunTarget (IProgressMonitor monitor, string target, ConfigurationSelector configuration)
492
893
                {
493
894
                        if (target == ProjectService.BuildTarget)
499
900
                        return ItemHandler.RunTarget (monitor, target, configuration) ?? new BuildResult ();
500
901
                }
501
902
                
 
903
                /// <summary>
 
904
                /// Cleans the files produced by this solution item
 
905
                /// </summary>
 
906
                /// <param name='monitor'>
 
907
                /// A progress monitor
 
908
                /// </param>
 
909
                /// <param name='configuration'>
 
910
                /// Configuration to use to clean the project
 
911
                /// </param>
502
912
                protected abstract void OnClean (IProgressMonitor monitor, ConfigurationSelector configuration);
 
913
                
 
914
                /// <summary>
 
915
                /// Builds the solution item
 
916
                /// </summary>
 
917
                /// <param name='monitor'>
 
918
                /// A progress monitor
 
919
                /// </param>
 
920
                /// <param name='configuration'>
 
921
                /// Configuration to use to build the project
 
922
                /// </param>
503
923
                protected abstract BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration);
 
924
                
 
925
                /// <summary>
 
926
                /// Executes this solution item
 
927
                /// </summary>
 
928
                /// <param name='monitor'>
 
929
                /// A progress monitor
 
930
                /// </param>
 
931
                /// <param name='context'>
 
932
                /// An execution context
 
933
                /// </param>
 
934
                /// <param name='configuration'>
 
935
                /// Configuration to use to execute the item
 
936
                /// </param>
504
937
                internal protected abstract void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration);
 
938
                
 
939
                /// <summary>
 
940
                /// Checks if this solution item has modified files and has to be built
 
941
                /// </summary>
 
942
                /// <returns>
 
943
                /// <c>true</c> if the solution item has to be built
 
944
                /// </returns>
 
945
                /// <param name='configuration'>
 
946
                /// Configuration for which to do the check
 
947
                /// </param>
505
948
                internal protected abstract bool OnGetNeedsBuilding (ConfigurationSelector configuration);
 
949
                
 
950
                /// <summary>
 
951
                /// States whether this solution item needs to be built or not
 
952
                /// </summary>
 
953
                /// <param name='val'>
 
954
                /// Whether this solution item needs to be built or not
 
955
                /// </param>
 
956
                /// <param name='configuration'>
 
957
                /// Configuration for which to set the flag
 
958
                /// </param>
506
959
                internal protected abstract void OnSetNeedsBuilding (bool val, ConfigurationSelector configuration);
507
960
                
 
961
                /// <summary>
 
962
                /// Gets the time of the last build
 
963
                /// </summary>
 
964
                /// <returns>
 
965
                /// The last build time.
 
966
                /// </returns>
 
967
                /// <param name='configuration'>
 
968
                /// Configuration for which to get the last build time.
 
969
                /// </param>
508
970
                internal protected virtual DateTime OnGetLastBuildTime (ConfigurationSelector configuration)
509
971
                {
510
972
                        return DateTime.MinValue;
511
973
                }
512
974
                
 
975
                /// <summary>
 
976
                /// Determines whether this solution item can be executed using the specified context and configuration.
 
977
                /// </summary>
 
978
                /// <returns>
 
979
                /// <c>true</c> if this instance can be executed; otherwise, <c>false</c>.
 
980
                /// </returns>
 
981
                /// <param name='context'>
 
982
                /// An execution context
 
983
                /// </param>
 
984
                /// <param name='configuration'>
 
985
                /// Configuration to use to execute the item
 
986
                /// </param>
513
987
                internal protected virtual bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration)
514
988
                {
515
989
                        return false;
516
990
                }
517
991
                
 
992
                /// <summary>
 
993
                /// Occurs when the name of the item changes
 
994
                /// </summary>
518
995
                public event SolutionItemRenamedEventHandler NameChanged;
 
996
                
 
997
                /// <summary>
 
998
                /// Occurs when the item is modified.
 
999
                /// </summary>
519
1000
                public event SolutionItemModifiedEventHandler Modified;
520
1001
        }
521
1002
        
526
1007
                {
527
1008
                        yield return new StringTagDescription ("ProjectName", "Project Name");
528
1009
                        yield return new StringTagDescription ("ProjectDir", "Project Directory");
 
1010
                        yield return new StringTagDescription ("AuthorName", "Project Author Name");
 
1011
                        yield return new StringTagDescription ("AuthorEmail", "Project Author Email");
 
1012
                        yield return new StringTagDescription ("AuthorCopyright", "Project Author Copyright");
 
1013
                        yield return new StringTagDescription ("AuthorCompany", "Project Author Company");
 
1014
                        yield return new StringTagDescription ("AuthorTrademark", "Project Trademark");
529
1015
                }
530
1016
                
531
1017
                public override object GetTagValue (SolutionItem item, string tag)
534
1020
                                case "ITEMNAME":
535
1021
                                case "PROJECTNAME":
536
1022
                                        return item.Name;
 
1023
                                case "AUTHORCOPYRIGHT":
 
1024
                                        AuthorInformation authorInfo = item.AuthorInformation ?? AuthorInformation.Default;
 
1025
                                        return authorInfo.Copyright;
 
1026
                                case "AUTHORCOMPANY":
 
1027
                                        authorInfo = item.AuthorInformation ?? AuthorInformation.Default;
 
1028
                                        return authorInfo.Company;
 
1029
                                case "AUTHORTRADEMARK":
 
1030
                                        authorInfo = item.AuthorInformation ?? AuthorInformation.Default;
 
1031
                                        return authorInfo.Trademark;
 
1032
                                case "AUTHOREMAIL":
 
1033
                                        authorInfo = item.AuthorInformation ?? AuthorInformation.Default;
 
1034
                                        return authorInfo.Email;
 
1035
                                case "AUTHORNAME":
 
1036
                                        authorInfo = item.AuthorInformation ?? AuthorInformation.Default;
 
1037
                                        return authorInfo.Name;
537
1038
                                case "ITEMDIR":
538
1039
                                case "PROJECTDIR":
539
1040
                                        return item.BaseDirectory;