-
Notifications
You must be signed in to change notification settings - Fork 1
/
Configuration.cs
102 lines (86 loc) · 3.36 KB
/
Configuration.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace vscmd {
partial class VisualStudio {
partial class Project {
public Configuration ActiveConfiguration {
get { return this.CreateConfiguration(this.Object.ConfigurationManager.ActiveConfiguration); }
}
protected virtual Configuration CreateConfiguration(object configuration) {
return new Configuration(configuration, this);
}
}
public class Configuration : ComChildObject<Project> {
internal Configuration(object configuration, Project parent)
: base(configuration, parent) { }
public Project Project { get { return this.Parent; } }
public string Name { get { return this.Object.ConfigurationName; } }
public virtual string DebugStartArguments {
get { throw this.Project.KindNotSupportedException(); }
set { throw this.Project.KindNotSupportedException(); }
}
public virtual string DebugStartProgram {
get { throw this.Project.KindNotSupportedException(); }
set { throw this.Project.KindNotSupportedException(); }
}
}
partial class CPlusPlusProject {
protected override Configuration CreateConfiguration(object configuration) {
return new CPlusPlusConfiguration(configuration, this);
}
}
// https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vcproject.vcprojectconfigurationproperties.aspx
class CPlusPlusConfiguration : Configuration {
public CPlusPlusConfiguration(object configuration, Project project)
: base(configuration, project) {
var vcconfig = project.Configuration(this.Name);
this._VCDebugSettings = vcconfig.DebugSettings;
}
public override string DebugStartArguments {
get { return this._VCDebugSettings.CommandArguments; }
set { this._VCDebugSettings.CommandArguments = value; }
}
public override string DebugStartProgram {
get { return this._VCDebugSettings.Command; }
set { this._VCDebugSettings.Command = value; }
}
private dynamic _VCDebugSettings;
}
partial class CSharpProject {
protected override Configuration CreateConfiguration(object configuration) {
return new CSharpConfiguration(configuration, this);
}
}
class CSharpConfiguration : Configuration {
public CSharpConfiguration(object configuration, Project parent)
: base(configuration, parent) { }
public override string DebugStartArguments {
get { return this.PropertyValue<string>("StartArguments"); }
set { this.SetPropertyValue<string>("StartArguments", value); }
}
public override string DebugStartProgram {
get {
int action = PropertyValue<int>("StartAction");
return action == 0 ? null : PropertyValue<string>("StartProgram");
}
set {
if (string.IsNullOrEmpty(value)) {
SetPropertyValue("StartAction", 0);
return;
}
if (File.Exists(value)) {
SetPropertyValue("StartAction", 1);
SetPropertyValue("StartProgram", Path.GetFullPath(value));
return;
}
SetPropertyValue("StartAction", 1);
SetPropertyValue("StartProgram", value);
}
}
}
}
}