@@ -103,7 +103,7 @@ public int ResourceId
103103 set => mResourceId = value ;
104104 }
105105
106- private Dictionary < string , string > Errors { get ; } = new Dictionary < string , string > ( ) ;
106+ private Dictionary < string , List < string > > Errors { get ; } = new Dictionary < string , List < string > > ( ) ;
107107
108108 private bool HasError => Errors . Any ( ) ;
109109
@@ -114,8 +114,6 @@ public int ResourceId
114114 public EditStringResourceDialog ( IServiceProvider aServiceProvider , List < RcFile > aRcFiles , RcFile aSelectedRcFile ,
115115 string aSelectedText , bool aReplaceCode , string aReplaceWithCodeFormated , StringLine aStringResource = null )
116116 {
117- if ( aRcFiles . Count == 0 )
118- throw new Exception ( "No RC files detected" ) ;
119117 InitializeComponent ( ) ;
120118 DataContext = this ;
121119 mRcFilesContexts = new Dictionary < RcFile , StringResourceContext > ( ) ;
@@ -165,7 +163,7 @@ private void btnAdd_Click(object sender, RoutedEventArgs e)
165163 }
166164 if ( HasError )
167165 {
168- VsShellUtilities . ShowMessageBox ( mServiceProvider , Errors . First ( ) . Value , "Invalid input" ,
166+ VsShellUtilities . ShowMessageBox ( mServiceProvider , Errors . First ( ) . Value . First ( ) , "Invalid input" ,
169167 OLEMSGICON . OLEMSGICON_CRITICAL , OLEMSGBUTTON . OLEMSGBUTTON_OK , OLEMSGDEFBUTTON . OLEMSGDEFBUTTON_FIRST ) ;
170168 return ;
171169 }
@@ -215,7 +213,8 @@ public string this[string PropertyName]
215213 get
216214 {
217215 CollectErrors ( ) ;
218- return Errors . ContainsKey ( PropertyName ) ? Errors [ PropertyName ] : string . Empty ;
216+ return Errors . ContainsKey ( PropertyName ) ?
217+ String . Join ( "\n " , Errors [ PropertyName ] ) : string . Empty ;
219218 }
220219 }
221220
@@ -224,33 +223,43 @@ private void CollectErrors()
224223 Errors . Clear ( ) ;
225224
226225 if ( string . IsNullOrEmpty ( ResourceName ) ||
227- ResourceName . Length > ParseConstants . kMaximumResourceNameLength ||
228- ! ResourceName . StartsWith ( TagConstants . kStringPreffix ) )
226+ ResourceName . Length > ParseConstants . kMaximumResourceNameLength ||
227+ ! ResourceName . StartsWith ( TagConstants . kStringPreffix ) )
229228 {
230- Errors . Add ( nameof ( ResourceName ) ,
231- string . Format ( "Name with the IDS_ prefix and maximum length of {0} is required!" ,
232- ParseConstants . kMaximumResourceNameLength ) ) ;
229+ if ( ! Errors . ContainsKey ( nameof ( ResourceName ) ) )
230+ Errors [ nameof ( ResourceName ) ] = new List < string > ( ) ;
231+
232+ Errors [ nameof ( ResourceName ) ] . Add ( string . Format (
233+ $ "Name with the IDS_ prefix and maximum length of { ParseConstants . kMaximumResourceNameLength } is required!") ) ;
233234 }
234235
235236 if ( AddMode && ( string . IsNullOrEmpty ( ResourceName ) ||
236237 ResourceContext . ResourceNameExists ( ResourceName ) ) )
237238 {
238- Errors . Add ( nameof ( ResourceName ) , string . Format ( "Name \" {0}\" already exists!" , ResourceName ) ) ;
239+ if ( ! Errors . ContainsKey ( nameof ( ResourceName ) ) )
240+ Errors [ nameof ( ResourceName ) ] = new List < string > ( ) ;
241+
242+ Errors [ nameof ( ResourceName ) ] . Add ( string . Format ( $ "Name \" { ResourceName } \" already exists!") ) ;
239243 }
240244
241245 if ( string . IsNullOrEmpty ( ResourceIdTemp ) ||
242- ! ParseUtility . TransformToDecimal ( ResourceIdTemp , out mResourceId ) ||
243- mResourceId < 0 || mResourceId > IdGenerator . kMaximumId )
246+ ! ParseUtility . TransformToDecimal ( ResourceIdTemp , out mResourceId ) ||
247+ mResourceId < 0 || mResourceId > IdGenerator . kMaximumId )
244248 {
245- Errors . Add ( nameof ( ResourceIdTemp ) ,
246- string . Format ( "Positive id less then {0} is required!" , IdGenerator . kMaximumId ) ) ;
249+ if ( ! Errors . ContainsKey ( nameof ( ResourceIdTemp ) ) )
250+ Errors [ nameof ( ResourceIdTemp ) ] = new List < string > ( ) ;
251+
252+ Errors [ nameof ( ResourceIdTemp ) ] . Add ( string . Format ( $ "Positive id less then { IdGenerator . kMaximumId } is required!") ) ;
247253 }
254+
248255 if ( string . IsNullOrEmpty ( ResourceValue ) ||
249256 ResourceValue . Length > ParseConstants . kMaximumResourceValueLength )
250257 {
251- Errors . Add ( nameof ( ResourceValue ) ,
252- string . Format ( "Value with maximum length of {0} characters is required!" ,
253- ParseConstants . kMaximumResourceValueLength ) ) ;
258+ if ( ! Errors . ContainsKey ( nameof ( ResourceValue ) ) )
259+ Errors [ nameof ( ResourceValue ) ] = new List < string > ( ) ;
260+
261+ Errors [ nameof ( ResourceValue ) ] . Add (
262+ string . Format ( $ "Value with maximum length of { ParseConstants . kMaximumResourceValueLength } characters is required!") ) ;
254263 }
255264 }
256265 #endregion
0 commit comments