|
|
|
@ -95,6 +95,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
@@ -95,6 +95,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class FileTemplateOptions |
|
|
|
|
{ |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets/Sets whether the file being created will be untitled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsUntitled { get; set; } |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The parent project to which this file is added.
|
|
|
|
|
/// Can be null when creating a file outside of a project.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IProject Project { get; set; } |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The name of the file
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FileName FileName { get; set; } |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The default namespace to use for the newly created file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Namespace { get; set; } |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The class name (generated from the file name).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string ClassName { get; set; } |
|
|
|
|
|
|
|
|
|
//IDictionary<string, string> properties;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This class defines and holds the new file templates.
|
|
|
|
|
/// </summary>
|
|
|
|
@ -120,6 +151,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
@@ -120,6 +151,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
|
|
|
|
|
List<ReferenceProjectItem> requiredAssemblyReferences = new List<ReferenceProjectItem>(); |
|
|
|
|
|
|
|
|
|
XmlElement fileoptions = null; |
|
|
|
|
Action<FileTemplateOptions> actions; |
|
|
|
|
|
|
|
|
|
int IComparable.CompareTo(object other) |
|
|
|
|
{ |
|
|
|
@ -165,6 +197,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
@@ -165,6 +197,7 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
|
|
|
|
|
return description; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
[Obsolete] |
|
|
|
|
public string WizardPath { |
|
|
|
|
get { |
|
|
|
|
return wizardpath; |
|
|
|
@ -275,6 +308,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
@@ -275,6 +308,14 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (doc.DocumentElement["Actions"] != null) { |
|
|
|
|
foreach (XmlElement el in doc.DocumentElement["Actions"]) { |
|
|
|
|
Action<FileTemplateOptions> action = ReadAction(el); |
|
|
|
|
if (action != null) |
|
|
|
|
actions += action; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileoptions = doc.DocumentElement["AdditionalOptions"]; |
|
|
|
|
|
|
|
|
|
doc.DocumentElement.SetAttribute("fileName", filename); // used for template loading warnings
|
|
|
|
@ -289,6 +330,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
@@ -289,6 +330,37 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Action<FileTemplateOptions> ReadAction(XmlElement el) |
|
|
|
|
{ |
|
|
|
|
switch (el.Name) { |
|
|
|
|
case "RunCommand": |
|
|
|
|
if (el.HasAttribute("path")) { |
|
|
|
|
try { |
|
|
|
|
ICommand command = (ICommand)AddInTree.BuildItem(el.GetAttribute("path"), null); |
|
|
|
|
return fileCreateInformation => { |
|
|
|
|
command.Owner = fileCreateInformation; |
|
|
|
|
command.Run(); |
|
|
|
|
}; |
|
|
|
|
} catch (TreePathNotFoundException ex) { |
|
|
|
|
MessageService.ShowWarning(ex.Message + " - in " + el.OwnerDocument.DocumentElement.GetAttribute("fileName")); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ProjectTemplate.WarnAttributeMissing(el, "path"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
ProjectTemplate.WarnObsoleteNode(el, "Unknown action element is ignored"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void RunActions(FileTemplateOptions options) |
|
|
|
|
{ |
|
|
|
|
if (actions != null) |
|
|
|
|
actions(options); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void UpdateTemplates() |
|
|
|
|
{ |
|
|
|
|
string dataTemplateDir = Path.Combine(PropertyService.DataDirectory, "templates", "file"); |
|
|
|
|