Throw exception when a not multiple instance template has been renamed

This commit is contained in:
javitosanchez 2017-03-21 16:37:10 +01:00
Родитель 1897fce569
Коммит 2636e00095
9 изменённых файлов: 79 добавлений и 10 удалений

Просмотреть файл

@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature
{
SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
Validate(value);
OnPropertyChanged(nameof(OkCommand));
}
@ -126,6 +124,19 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature
}
}
private void Validate(string value)
{
//TODO: CREATE VALIDATION ERROR CLASS
if (!TemplateSelected.MultipleInstances)
{
throw new Exception(Strings.ValidationError_RenameNotAllowed);
}
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid;
}
}

Просмотреть файл

@ -159,6 +159,15 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures {
}
}
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>

Просмотреть файл

@ -150,6 +150,9 @@
<data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value>
</data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>

Просмотреть файл

@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature
{
SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
Validate(value);
OnPropertyChanged(nameof(OkCommand));
}
@ -125,6 +123,19 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature
}
}
private void Validate(string value)
{
//TODO: CREATE VALIDATION ERROR CLASS
if (!TemplateSelected.MultipleInstances)
{
throw new Exception(Strings.ValidationError_RenameNotAllowed);
}
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid;
}
}

Просмотреть файл

@ -159,6 +159,15 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures {
}
}
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>

Просмотреть файл

@ -150,6 +150,9 @@
<data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value>
</data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>

Просмотреть файл

@ -56,15 +56,13 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage
{
SetProperty(ref _itemName, value);
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
Validate(value);
OnPropertyChanged(nameof(OkCommand));
}
}
//TODO: MAKE THIS METHOD TRULY ASYNC
//TODO: MAKE THIS METHOD TRULY ASYNC
public async Task InitializeAsync()
{
Templates.Clear();
@ -114,6 +112,19 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage
}
}
private void Validate(string value)
{
//TODO: CREATE VALIDATION ERROR CLASS
if (!TemplateSelected.MultipleInstances)
{
throw new Exception(Strings.ValidationError_RenameNotAllowed);
}
var validationResult = Naming.Validate(_selectedNames, value);
HandleValidation(validationResult);
}
private bool IsValid() => _isValid;
}
}

9
code/src/Wizard/Steps/Pages/Strings.Designer.cs сгенерированный
Просмотреть файл

@ -150,6 +150,15 @@ namespace Microsoft.Templates.Wizard.Steps.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Cannot set a custom name.
/// </summary>
public static string ValidationError_RenameNotAllowed {
get {
return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name is reserved.
/// </summary>

Просмотреть файл

@ -147,6 +147,9 @@
<data name="ValidationError_Empty" xml:space="preserve">
<value>Name cannot be empty</value>
</data>
<data name="ValidationError_RenameNotAllowed" xml:space="preserve">
<value>Cannot set a custom name</value>
</data>
<data name="ValidationError_ReservedName" xml:space="preserve">
<value>Name is reserved</value>
</data>