Rev | Line | |
---|
[12503] | 1 |
|
---|
| 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
| 5 | using System.Text;
|
---|
| 6 | using System.Windows.Markup;
|
---|
| 7 | using System.Resources;
|
---|
| 8 |
|
---|
| 9 | namespace 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.