diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Ide')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs | 5 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs | 6 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TemplateConditionEvaluator.cs | 61 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj | 1 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32.png | bin | 635 -> 1011 bytes | |||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32@2x.png | bin | 1173 -> 2406 bytes |
6 files changed, 71 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs index d202a07abd..5b545d96da 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileDescriptionTemplate.cs @@ -112,5 +112,10 @@ namespace MonoDevelop.Ide.Templates { ProjectTagModel = tagModel; } + + internal bool EvaluateCreateCondition () + { + return TemplateConditionEvaluator.EvaluateCondition (ProjectTagModel, CreateCondition); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs index ed75d0bad3..4d53a8bc4c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/FileTemplateReference.cs @@ -78,8 +78,10 @@ namespace MonoDevelop.Ide.Templates string substName = StringParserService.Parse (this.name, customTags); foreach (FileDescriptionTemplate fdt in innerTemplate.Files) { - if (!fdt.AddToProject (policyParent, project, language, directory, substName)) - return false; + if (fdt.EvaluateCreateCondition ()) { + if (!fdt.AddToProject (policyParent, project, language, directory, substName)) + return false; + } } return true; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TemplateConditionEvaluator.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TemplateConditionEvaluator.cs new file mode 100644 index 0000000000..220cfd6e98 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TemplateConditionEvaluator.cs @@ -0,0 +1,61 @@ +// +// TemplateConditionEvaluator.cs +// +// Author: +// Michael Hutchinson <m.j.hutchinson@gmail.com> +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2014-2015 Xamarin Inc. (http://xamarin.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 MonoDevelop.Core.StringParsing; + +namespace MonoDevelop.Ide.Templates +{ + static class TemplateConditionEvaluator + { + public static bool EvaluateCondition (IStringTagModel model, string condition) + { + // This logic is duplicated in the ProjectCreateInformation.ShouldCreate method. + if (string.IsNullOrWhiteSpace (condition)) + return true; + + condition = condition.Trim (); + + string parameter = GetNotConditionParameterName (condition); + if (parameter != null) { + return !model.GetBoolValue (parameter); + } + + return model.GetBoolValue (condition); + } + + static string GetNotConditionParameterName (string createCondition) + { + if (createCondition.StartsWith ("!", StringComparison.Ordinal)) { + return createCondition.Substring (1).TrimStart (); + } + + return null; + } + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index b90aa6c5d4..20a2a4b437 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -3413,6 +3413,7 @@ <Compile Include="MonoDevelop.Components.AutoTest.Results\ObjectResult.cs" /> <Compile Include="MonoDevelop.Components.AutoTest\PropertyMetadata.cs" /> <Compile Include="MonoDevelop.Components.AutoTest\ObjectProperties.cs" /> + <Compile Include="MonoDevelop.Ide.Templates\TemplateConditionEvaluator.cs" /> <Compile Include="MonoDevelop.Components.AutoTest.Operations\SelectedOperation.cs" /> <Compile Include="MonoDevelop.Components\Windows\GtkWPFWidget.cs" /> <Compile Include="MonoDevelop.Components\Windows\GtkWin32Interop.cs" /> diff --git a/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32.png b/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32.png Binary files differindex f1b05134c5..2e6e5fadee 100644 --- a/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32.png +++ b/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32.png diff --git a/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32@2x.png b/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32@2x.png Binary files differindex 0522ca44e1..659e6e0010 100644 --- a/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/project-web-overlay-32@2x.png |