54
55
this.typeName = type;
57
public ICombineEntryDescriptor[] EntryDescriptors {
58
get { return (ICombineEntryDescriptor[]) entryDescriptors.ToArray (typeof(ICombineEntryDescriptor)); }
58
public ISolutionItemDescriptor[] EntryDescriptors {
59
get { return (ISolutionItemDescriptor[]) entryDescriptors.ToArray (typeof(ISolutionItemDescriptor)); }
61
public string CreateEntry (ProjectCreateInformation projectCreateInformation, string defaultLanguage)
62
public WorkspaceItem CreateEntry (ProjectCreateInformation projectCreateInformation, string defaultLanguage)
65
66
if (typeName != null && typeName.Length > 0) {
66
67
Type type = Type.GetType (typeName);
68
Services.MessageService.ShowError (GettextCatalog.GetString ("Can't create solution with type: {0}", typeName));
68
if (type == null || !typeof(WorkspaceItem).IsAssignableFrom (type)) {
69
MessageService.ShowError (GettextCatalog.GetString ("Can't create solution with type: {0}", typeName));
71
newCombine = (Combine) Activator.CreateInstance (type);
72
item = (WorkspaceItem) Activator.CreateInstance (type);
73
newCombine = new Combine();
74
item = new Solution ();
75
76
string newCombineName = StringParserService.Parse(name, new string[,] {
76
77
{"ProjectName", projectCreateInformation.CombineName}
79
newCombine.Name = newCombineName;
80
item.Name = newCombineName;
81
82
string oldCombinePath = projectCreateInformation.CombinePath;
82
83
string oldProjectPath = projectCreateInformation.ProjectBasePath;
94
// Create sub projects
95
foreach (ICombineEntryDescriptor entryDescriptor in entryDescriptors) {
96
newCombine.AddEntry (entryDescriptor.CreateEntry (projectCreateInformation, defaultLanguage), null);
95
Solution sol = item as Solution;
97
List<string> configs = new List<string> ();
99
// Create sub projects
100
foreach (ISolutionItemDescriptor entryDescriptor in entryDescriptors) {
101
SolutionEntityItem sit = entryDescriptor.CreateItem (projectCreateInformation, defaultLanguage);
102
entryDescriptor.InitializeItem (sol.RootFolder, projectCreateInformation, defaultLanguage, sit);
103
sol.RootFolder.Items.Add (sit);
104
if (sit is IConfigurationTarget) {
105
foreach (ItemConfiguration c in ((IConfigurationTarget)sit).Configurations) {
106
if (!configs.Contains (c.Id))
112
// Create configurations
113
foreach (string conf in configs)
114
sol.AddConfiguration (conf, true);
99
117
projectCreateInformation.CombinePath = oldCombinePath;
100
118
projectCreateInformation.ProjectBasePath = oldProjectPath;
103
using (IProgressMonitor monitor = new NullProgressMonitor ()) {
104
string combineLocation = Path.Combine (projectCreateInformation.CombinePath, newCombineName + ".mds");
105
if (File.Exists(combineLocation)) {
106
if (Services.MessageService.AskQuestion (GettextCatalog.GetString ("Solution file {0} already exists, do you want to overwrite\nthe existing file?", combineLocation))) {
107
newCombine.Save (combineLocation, monitor);
110
newCombine.Save (combineLocation, monitor);
113
newCombine.Dispose();
114
return combineLocation;
119
item.SetLocation (projectCreateInformation.CombinePath, newCombineName);
118
124
public static CombineDescriptor CreateCombineDescriptor(XmlElement element)
134
140
combineDescriptor.entryDescriptors.Add (ProjectDescriptor.CreateProjectDescriptor((XmlElement)node));
137
144
combineDescriptor.entryDescriptors.Add (CreateCombineDescriptor((XmlElement)node));
139
146
case "CombineEntry":
140
combineDescriptor.entryDescriptors.Add (CombineEntryDescriptor.CreateDescriptor((XmlElement)node));
148
combineDescriptor.entryDescriptors.Add (SolutionItemDescriptor.CreateDescriptor((XmlElement)node));