Browse Source

ResourceToolkit: Applied some fixes from FxCop. Especially reduced nesting of generics by using a custom ResourceItem class instead of KeyValuePair<string,string>.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1891 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Christian Hornung 20 years ago
parent
commit
409a1a13d9
  1. 1
      src/AddIns/Misc/ResourceToolkit/Project/ResourceToolkit.csproj
  2. 2
      src/AddIns/Misc/ResourceToolkit/Project/Src/Commands/RefactoringCommands.cs
  3. 1
      src/AddIns/Misc/ResourceToolkit/Project/Src/Commands/TextEditorContextMenuBuilder.cs
  4. 1
      src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/EditStringResourceDialog.cs
  5. 8
      src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysCommands.cs
  6. 39
      src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysViewContent.cs
  7. 13
      src/AddIns/Misc/ResourceToolkit/Project/Src/Refactoring/ResourceRefactoringService.cs
  8. 3
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryAstCacheService.cs
  9. 1
      src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/PropertyFieldAssociationVisitor.cs
  10. 2
      src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceFileContent/DefaultFileLocalizedResourcesFinder.cs
  11. 4
      src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceFileContent/MergedResourceFileContent.cs
  12. 53
      src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceItem.cs

1
src/AddIns/Misc/ResourceToolkit/Project/ResourceToolkit.csproj

@ -89,6 +89,7 @@
<Compile Include="Src\Gui\UnusedResourceKeysCommands.cs" /> <Compile Include="Src\Gui\UnusedResourceKeysCommands.cs" />
<Compile Include="Src\Gui\IFilter.cs" /> <Compile Include="Src\Gui\IFilter.cs" />
<Compile Include="Src\Gui\IFilterHost.cs" /> <Compile Include="Src\Gui\IFilterHost.cs" />
<Compile Include="Src\ResourceItem.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> <ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">

2
src/AddIns/Misc/ResourceToolkit/Project/Src/Commands/RefactoringCommands.cs

@ -36,7 +36,7 @@ namespace Hornung.ResourceToolkit.Commands
{ {
public override void Run() public override void Run()
{ {
ICollection<KeyValuePair<string, string>> unusedKeys = ResourceRefactoringService.FindUnusedKeys(); ICollection<ResourceItem> unusedKeys = ResourceRefactoringService.FindUnusedKeys();
if (unusedKeys == null) { if (unusedKeys == null) {
return; return;

1
src/AddIns/Misc/ResourceToolkit/Project/Src/Commands/TextEditorContextMenuBuilder.cs

@ -74,6 +74,7 @@ namespace Hornung.ResourceToolkit.Commands
// ******************************************************************************************************************************** // ********************************************************************************************************************************
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "ICSharpCode.Core.MessageService.ShowWarning(System.String)")]
void EditResource(object sender, EventArgs e) void EditResource(object sender, EventArgs e)
{ {
MenuCommand cmd = sender as MenuCommand; MenuCommand cmd = sender as MenuCommand;

1
src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/EditStringResourceDialog.cs

@ -55,6 +55,7 @@ namespace Hornung.ResourceToolkit.Gui
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Hornung.ResourceToolkit.Resources.EditStringResourceDialog.xfrm")); SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Hornung.ResourceToolkit.Resources.EditStringResourceDialog.xfrm"));
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "ICSharpCode.Core.MessageService.ShowWarning(System.String)")]
void KeyValidating(object sender, CancelEventArgs e) void KeyValidating(object sender, CancelEventArgs e)
{ {
TextBox textBox = (TextBox)sender; TextBox textBox = (TextBox)sender;

8
src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysCommands.cs

@ -17,7 +17,7 @@ namespace Hornung.ResourceToolkit.Gui
/// <summary> /// <summary>
/// Hides or shows the ICSharpCode.Core host resources in an UnusedResourceKeysViewContent. /// Hides or shows the ICSharpCode.Core host resources in an UnusedResourceKeysViewContent.
/// </summary> /// </summary>
public class UnusedResourceKeysHideICSharpCodeCoreHostResourcesCommand : AbstractCheckableMenuCommand, IFilter<KeyValuePair<string, string>> public class UnusedResourceKeysHideICSharpCodeCoreHostResourcesCommand : AbstractCheckableMenuCommand, IFilter<ResourceItem>
{ {
string icSharpCodeCoreHostResourceFileName; string icSharpCodeCoreHostResourceFileName;
@ -25,7 +25,7 @@ namespace Hornung.ResourceToolkit.Gui
{ {
base.Run(); base.Run();
IFilterHost<KeyValuePair<string, string>> host = ((ToolBarCheckBox)this.Owner).Caller as IFilterHost<KeyValuePair<string, string>>; IFilterHost<ResourceItem> host = ((ToolBarCheckBox)this.Owner).Caller as IFilterHost<ResourceItem>;
if (host != null) { if (host != null) {
if (this.IsChecked) { if (this.IsChecked) {
this.icSharpCodeCoreHostResourceFileName = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceFileName(null); this.icSharpCodeCoreHostResourceFileName = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceFileName(null);
@ -41,9 +41,9 @@ namespace Hornung.ResourceToolkit.Gui
/// </summary> /// </summary>
/// <param name="item">The item to test.</param> /// <param name="item">The item to test.</param>
/// <returns><c>true</c>, if the specified item matches the current filter criteria, otherwise <c>false</c>.</returns> /// <returns><c>true</c>, if the specified item matches the current filter criteria, otherwise <c>false</c>.</returns>
public bool IsMatch(KeyValuePair<string, string> item) public bool IsMatch(ResourceItem item)
{ {
return !FileUtility.IsEqualFileName(item.Value, this.icSharpCodeCoreHostResourceFileName); return !FileUtility.IsEqualFileName(item.FileName, this.icSharpCodeCoreHostResourceFileName);
} }
} }
} }

39
src/AddIns/Misc/ResourceToolkit/Project/Src/Gui/UnusedResourceKeysViewContent.cs

@ -22,9 +22,9 @@ namespace Hornung.ResourceToolkit.Gui
/// <summary> /// <summary>
/// Displays unused resource keys in a list and allows the user to delete them. /// Displays unused resource keys in a list and allows the user to delete them.
/// </summary> /// </summary>
public class UnusedResourceKeysViewContent : AbstractViewContent, IClipboardHandler, IFilterHost<KeyValuePair<string, string>> public class UnusedResourceKeysViewContent : AbstractViewContent, IClipboardHandler, IFilterHost<ResourceItem>
{ {
readonly ICollection<KeyValuePair<string, string>> unusedKeys; readonly ICollection<ResourceItem> unusedKeys;
Panel panel; Panel panel;
ListView listView; ListView listView;
ToolStrip toolStrip; ToolStrip toolStrip;
@ -47,7 +47,7 @@ namespace Hornung.ResourceToolkit.Gui
/// <summary> /// <summary>
/// Gets a collection of key/value pairs where the values are the resource file names and the keys are the unused resource keys. /// Gets a collection of key/value pairs where the values are the resource file names and the keys are the unused resource keys.
/// </summary> /// </summary>
public ICollection<KeyValuePair<string, string>> UnusedKeys { public ICollection<ResourceItem> UnusedKeys {
get { get {
return this.unusedKeys; return this.unusedKeys;
} }
@ -56,8 +56,8 @@ namespace Hornung.ResourceToolkit.Gui
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UnusedResourceKeysViewContent"/> class. /// Initializes a new instance of the <see cref="UnusedResourceKeysViewContent"/> class.
/// </summary> /// </summary>
/// <param name="unusedKeys">A collection of key/value pairs where the values are the resource file names and the keys are the unused resource keys.</param> /// <param name="unusedKeys">A collection of <see cref="ResourceItem"/> classes that represent the unused resource keys to display.</param>
public UnusedResourceKeysViewContent(ICollection<KeyValuePair<string, string>> unusedKeys) public UnusedResourceKeysViewContent(ICollection<ResourceItem> unusedKeys)
: base(StringParser.Parse("${res:Hornung.ResourceToolkit.UnusedResourceKeys.Title}")) : base(StringParser.Parse("${res:Hornung.ResourceToolkit.UnusedResourceKeys.Title}"))
{ {
LoggingService.Debug("ResourceToolkit: Creating new UnusedResourceKeysViewContent"); LoggingService.Debug("ResourceToolkit: Creating new UnusedResourceKeysViewContent");
@ -144,7 +144,7 @@ namespace Hornung.ResourceToolkit.Gui
} }
} }
bool fillListViewQueued = false; bool fillListViewQueued;
/// <summary> /// <summary>
/// Fills the list view with all unused resource keys that match the current filter after processing the message queue. /// Fills the list view with all unused resource keys that match the current filter after processing the message queue.
@ -178,32 +178,32 @@ namespace Hornung.ResourceToolkit.Gui
Dictionary<string, ListViewGroup> fileGroups = new Dictionary<string, ListViewGroup>(); Dictionary<string, ListViewGroup> fileGroups = new Dictionary<string, ListViewGroup>();
// Create the ListViewItems. // Create the ListViewItems.
foreach (KeyValuePair<string, string> entry in this.UnusedKeys) { foreach (ResourceItem entry in this.UnusedKeys) {
// Skip if any filter rejects this item. // Skip if any filter rejects this item.
if (!this.ItemMatchesCurrentFilter(entry)) { if (!this.ItemMatchesCurrentFilter(entry)) {
continue; continue;
} }
IResourceFileContent c = ResourceFileContentRegistry.GetResourceFileContent(entry.Value); IResourceFileContent c = ResourceFileContentRegistry.GetResourceFileContent(entry.FileName);
object o; object o;
// only add the file name to save space // only add the file name to save space
// and show the full path as tooltip // and show the full path as tooltip
ListViewItem item = new ListViewItem(Path.GetFileName(entry.Value)); ListViewItem item = new ListViewItem(Path.GetFileName(entry.FileName));
item.ToolTipText = entry.Value; item.ToolTipText = entry.FileName;
item.SubItems.Add(entry.Key); item.SubItems.Add(entry.Key);
if (c.TryGetValue(entry.Key, out o)) { if (c.TryGetValue(entry.Key, out o)) {
item.SubItems.Add((o ?? (object)"<<null>>").ToString()); item.SubItems.Add((o ?? (object)"<<null>>").ToString());
} else { } else {
throw new InvalidOperationException("The key '"+entry.Key+"' in file '"+entry.Value+"' does not exist although it was reported as unused."); throw new InvalidOperationException("The key '"+entry.Key+"' in file '"+entry.FileName+"' does not exist although it was reported as unused.");
} }
// Use ListViewGroups to group by file names // Use ListViewGroups to group by file names
ListViewGroup grp; ListViewGroup grp;
if (!fileGroups.TryGetValue(entry.Value, out grp)) { if (!fileGroups.TryGetValue(entry.FileName, out grp)) {
grp = new ListViewGroup(entry.Value); grp = new ListViewGroup(entry.FileName);
fileGroups.Add(entry.Value, grp); fileGroups.Add(entry.FileName, grp);
this.ListView.Groups.Add(grp); this.ListView.Groups.Add(grp);
} }
grp.Items.Add(item); grp.Items.Add(item);
@ -222,7 +222,7 @@ namespace Hornung.ResourceToolkit.Gui
#region Filter #region Filter
readonly List<IFilter<KeyValuePair<string, string>>> filters = new List<IFilter<KeyValuePair<string, string>>>(); readonly List<IFilter<ResourceItem>> filters = new List<IFilter<ResourceItem>>();
/// <summary> /// <summary>
/// Registers a new filter with the filter host, if the filter is not already registered, /// Registers a new filter with the filter host, if the filter is not already registered,
@ -230,7 +230,7 @@ namespace Hornung.ResourceToolkit.Gui
/// </summary> /// </summary>
/// <param name="filter">The filter to be registered.</param> /// <param name="filter">The filter to be registered.</param>
/// <exception cref="ArgumentNullException">The <paramref name="filter"/> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="filter"/> parameter is <c>null</c>.</exception>
public void RegisterFilter(IFilter<KeyValuePair<string, string>> filter) public void RegisterFilter(IFilter<ResourceItem> filter)
{ {
if (filter == null) { if (filter == null) {
throw new ArgumentNullException("filter"); throw new ArgumentNullException("filter");
@ -248,7 +248,7 @@ namespace Hornung.ResourceToolkit.Gui
/// </summary> /// </summary>
/// <param name="filter">The filter to be removed.</param> /// <param name="filter">The filter to be removed.</param>
/// <exception cref="ArgumentNullException">The <paramref name="filter"/> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="filter"/> parameter is <c>null</c>.</exception>
public void UnregisterFilter(IFilter<KeyValuePair<string, string>> filter) public void UnregisterFilter(IFilter<ResourceItem> filter)
{ {
if (filter == null) { if (filter == null) {
throw new ArgumentNullException("filter"); throw new ArgumentNullException("filter");
@ -264,9 +264,9 @@ namespace Hornung.ResourceToolkit.Gui
/// according to the current filter. /// according to the current filter.
/// </summary> /// </summary>
/// <returns><c>true</c>, if the resource should be included in the list view, otherwise <c>false</c>.</returns> /// <returns><c>true</c>, if the resource should be included in the list view, otherwise <c>false</c>.</returns>
bool ItemMatchesCurrentFilter(KeyValuePair<string, string> item) bool ItemMatchesCurrentFilter(ResourceItem item)
{ {
foreach (IFilter<KeyValuePair<string, string>> filter in this.filters) { foreach (IFilter<ResourceItem> filter in this.filters) {
if (!filter.IsMatch(item)) { if (!filter.IsMatch(item)) {
return false; return false;
} }
@ -325,6 +325,7 @@ namespace Hornung.ResourceToolkit.Gui
throw new NotImplementedException(); throw new NotImplementedException();
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1814:PreferJaggedArraysOverMultidimensional", MessageId = "Body")]
public void Delete() public void Delete()
{ {
if (this.ListView.SelectedItems.Count > 0) { if (this.ListView.SelectedItems.Count > 0) {

13
src/AddIns/Misc/ResourceToolkit/Project/Src/Refactoring/ResourceRefactoringService.cs

@ -170,8 +170,8 @@ namespace Hornung.ResourceToolkit.Refactoring
/// Finds all unused resource keys in all resource files that are referenced /// Finds all unused resource keys in all resource files that are referenced
/// in code at least once in the whole solution. /// in code at least once in the whole solution.
/// </summary> /// </summary>
/// <returns>A collection of key/value pairs where the values are the resource file names and the keys are the unused resource keys.</returns> /// <returns>A collection of <see cref="ResourceItem"/> classes that represent the unused resource keys.</returns>
public static ICollection<KeyValuePair<string, string>> FindUnusedKeys() public static ICollection<ResourceItem> FindUnusedKeys()
{ {
List<Reference> references = FindAllReferences(); List<Reference> references = FindAllReferences();
if (references == null) { if (references == null) {
@ -179,7 +179,7 @@ namespace Hornung.ResourceToolkit.Refactoring
} }
DateTime startTime = DateTime.UtcNow; DateTime startTime = DateTime.UtcNow;
List<KeyValuePair<string, string>> unused = new List<KeyValuePair<string, string>>(); List<ResourceItem> unused = new List<ResourceItem>();
// Get a list of all referenced resource files. // Get a list of all referenced resource files.
// Generate a dictonary of resource file names and the // Generate a dictonary of resource file names and the
@ -207,7 +207,7 @@ namespace Hornung.ResourceToolkit.Refactoring
#endif #endif
foreach (KeyValuePair<string, object> entry in ResourceFileContentRegistry.GetResourceFileContent(fileName).Data) { foreach (KeyValuePair<string, object> entry in ResourceFileContentRegistry.GetResourceFileContent(fileName).Data) {
if (!referencedKeys[fileName].Contains(entry.Key)) { if (!referencedKeys[fileName].Contains(entry.Key)) {
unused.Add(new KeyValuePair<string, string>(entry.Key, fileName)); unused.Add(new ResourceItem(fileName, entry.Key));
} }
} }
} }
@ -224,6 +224,7 @@ namespace Hornung.ResourceToolkit.Refactoring
/// Asks the user for a new name. /// Asks the user for a new name.
/// </summary> /// </summary>
/// <param name="rrr">The resource to be renamed.</param> /// <param name="rrr">The resource to be renamed.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "ICSharpCode.Core.MessageService.ShowInputBox(System.String,System.String,System.String)")]
public static void Rename(ResourceResolveResult rrr) public static void Rename(ResourceResolveResult rrr)
{ {
string newKey = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:Hornung.ResourceToolkit.RenameResourceText}", rrr.Key); string newKey = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:Hornung.ResourceToolkit.RenameResourceText}", rrr.Key);
@ -275,7 +276,7 @@ namespace Hornung.ResourceToolkit.Refactoring
/// Gets a list of names of files which can possibly contain resource references. /// Gets a list of names of files which can possibly contain resource references.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public static List<string> GetPossibleFiles() public static ICollection<string> GetPossibleFiles()
{ {
List<string> files = new List<string>(); List<string> files = new List<string>();
@ -307,7 +308,7 @@ namespace Hornung.ResourceToolkit.Refactoring
} }
return files; return files.AsReadOnly();
} }
/// <summary> /// <summary>

3
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/NRefactoryAstCacheService.cs

@ -22,7 +22,7 @@ namespace Hornung.ResourceToolkit.Resolver
/// </summary> /// </summary>
public static class NRefactoryAstCacheService public static class NRefactoryAstCacheService
{ {
static bool cacheEnabled = false; static bool cacheEnabled;
static Dictionary<string, CompilationUnit> cachedAstInfo = new Dictionary<string, CompilationUnit>(); static Dictionary<string, CompilationUnit> cachedAstInfo = new Dictionary<string, CompilationUnit>();
/// <summary> /// <summary>
@ -38,6 +38,7 @@ namespace Hornung.ResourceToolkit.Resolver
/// Enables the AST cache. /// Enables the AST cache.
/// </summary> /// </summary>
/// <exception cref="InvalidOperationException">The AST cache is already enabled.</exception> /// <exception cref="InvalidOperationException">The AST cache is already enabled.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.InvalidOperationException.#ctor(System.String)")]
public static void EnableCache() public static void EnableCache()
{ {
if (CacheEnabled) { if (CacheEnabled) {

1
src/AddIns/Misc/ResourceToolkit/Project/Src/Resolver/PropertyFieldAssociationVisitor.cs

@ -228,6 +228,7 @@ namespace Hornung.ResourceToolkit.Resolver
/// Initializes a new instance of the <see cref="PropertyFieldAssociationVisitor"/> class. /// Initializes a new instance of the <see cref="PropertyFieldAssociationVisitor"/> class.
/// </summary> /// </summary>
/// <param name="field">The field to find the associated property for.</param> /// <param name="field">The field to find the associated property for.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String,System.String)")]
public PropertyFieldAssociationVisitor(IField field) : base() public PropertyFieldAssociationVisitor(IField field) : base()
{ {
if (field == null) { if (field == null) {

2
src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceFileContent/DefaultFileLocalizedResourcesFinder.cs

@ -35,7 +35,7 @@ namespace Hornung.ResourceToolkit.ResourceFileContent
string culture = Path.GetExtension(fileNameWithoutExtension); string culture = Path.GetExtension(fileNameWithoutExtension);
if (!String.IsNullOrEmpty(culture)) { if (!String.IsNullOrEmpty(culture)) {
try { try {
CultureInfo dummy = CultureInfo.GetCultureInfo(culture); CultureInfo.GetCultureInfo(culture);
// the specified file is a localized resource file itself // the specified file is a localized resource file itself
LoggingService.Debug("ResourceToolkit: DefaultFileLocalizedResourcesFinder.GetLocalizedContents: Returning null for file '"+fileName+"' because it has been detected as being a localized resource file itself."); LoggingService.Debug("ResourceToolkit: DefaultFileLocalizedResourcesFinder.GetLocalizedContents: Returning null for file '"+fileName+"' because it has been detected as being a localized resource file itself.");
return null; return null;

4
src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceFileContent/MergedResourceFileContent.cs

@ -28,6 +28,7 @@ namespace Hornung.ResourceToolkit.ResourceFileContent
/// <param name="masterContent">The master resource file content.</param> /// <param name="masterContent">The master resource file content.</param>
/// <param name="otherContents">Additional resource file contents.</param> /// <param name="otherContents">Additional resource file contents.</param>
/// <exception cref="ArgumentException">The cultures of the specified resource file contents do not match.</exception> /// <exception cref="ArgumentException">The cultures of the specified resource file contents do not match.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")]
public MergedResourceFileContent(IResourceFileContent masterContent, IResourceFileContent[] otherContents) public MergedResourceFileContent(IResourceFileContent masterContent, IResourceFileContent[] otherContents)
{ {
this.masterContent = masterContent; this.masterContent = masterContent;
@ -123,6 +124,7 @@ namespace Hornung.ResourceToolkit.ResourceFileContent
/// Modify the value of an existing entry. /// Modify the value of an existing entry.
/// </summary> /// </summary>
/// <exception cref="ArgumentException">The specified key does not exist.</exception> /// <exception cref="ArgumentException">The specified key does not exist.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String,System.String)")]
public void SetValue(string key, object value) public void SetValue(string key, object value)
{ {
if (this.masterContent.ContainsKey(key)) { if (this.masterContent.ContainsKey(key)) {
@ -145,6 +147,7 @@ namespace Hornung.ResourceToolkit.ResourceFileContent
/// <param name="oldName">The old name of the resource key to rename.</param> /// <param name="oldName">The old name of the resource key to rename.</param>
/// <param name="newName">The new name of the resource key.</param> /// <param name="newName">The new name of the resource key.</param>
/// <exception cref="ArgumentException">The specified key does not exist or the new key does already exist.</exception> /// <exception cref="ArgumentException">The specified key does not exist or the new key does already exist.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String,System.String)")]
public void RenameKey(string oldName, string newName) public void RenameKey(string oldName, string newName)
{ {
if (this.masterContent.ContainsKey(oldName)) { if (this.masterContent.ContainsKey(oldName)) {
@ -166,6 +169,7 @@ namespace Hornung.ResourceToolkit.ResourceFileContent
/// </summary> /// </summary>
/// <param name="key">The resource key to remove.</param> /// <param name="key">The resource key to remove.</param>
/// <exception cref="ArgumentException">The specified key does not exist.</exception> /// <exception cref="ArgumentException">The specified key does not exist.</exception>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String,System.String)")]
public void RemoveKey(string key) public void RemoveKey(string key)
{ {
if (this.masterContent.ContainsKey(key)) { if (this.masterContent.ContainsKey(key)) {

53
src/AddIns/Misc/ResourceToolkit/Project/Src/ResourceItem.cs

@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Christian Hornung" email="c-hornung@gmx.de"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Hornung.ResourceToolkit
{
/// <summary>
/// Describes a resource item by file name and key.
/// </summary>
public class ResourceItem
{
readonly string fileName;
readonly string key;
/// <summary>
/// Initializes a new instance of the <see cref="ResourceItem"/> class.
/// </summary>
/// <param name="fileName">The name of the resource file.</param>
/// <param name="key">The resource key.</param>
/// <exception cref="ArgumentNullException">The <paramref name="fileName"/> parameter is <c>null</c>.</exception>
public ResourceItem(string fileName, string key)
{
if (fileName == null) {
throw new ArgumentNullException("fileName");
}
this.fileName = fileName;
this.key = key;
}
/// <summary>
/// Gets the name of the resource file this resource item is contained in.
/// </summary>
public string FileName {
get {
return fileName;
}
}
/// <summary>
/// Gets the resource key of this resource item.
/// </summary>
public string Key {
get {
return key;
}
}
}
}
Loading…
Cancel
Save