Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/Auxiliary/MarkupExtensions/ResourceExtension.cs @ 13757

Last change on this file since 13757 was 12503, checked in by aballeit, 10 years ago

#2283 added GUI and charts; fixed MCTS

File size: 1.4 KB
Line 
1
2using System;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Windows.Markup;
7using System.Resources;
8
9namespace Microsoft.Research.DynamicDataDisplay.MarkupExtensions
10{
11  /// <summary>
12  /// Represents a markup extension, which allows to get an access to application resource files.
13  /// </summary>
14  [MarkupExtensionReturnType(typeof(string))]
15  public class ResourceExtension : MarkupExtension
16  {
17    /// <summary>
18    /// Initializes a new instance of the <see cref="ResourceExtension"/> class.
19    /// </summary>
20    public ResourceExtension() { }
21
22    private string resourceKey;
23    //[ConstructorArgument("resourceKey")]
24    public string ResourceKey
25    {
26      get { return resourceKey; }
27      set
28      {
29        if (resourceKey == null)
30          throw new ArgumentNullException("resourceKey");
31
32        resourceKey = value;
33      }
34    }
35
36    /// <summary>
37    /// Initializes a new instance of the <see cref="ResourceExtension"/> class.
38    /// </summary>
39    /// <param name="resourceKey">The resource key.</param>
40    public ResourceExtension(string resourceKey)
41    {
42      if (resourceKey == null)
43        throw new ArgumentNullException("resourceKey");
44
45      this.resourceKey = resourceKey;
46    }
47
48    public override object ProvideValue(IServiceProvider serviceProvider)
49    {
50      return Strings.UIResources.ResourceManager.GetString(resourceKey);
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.