// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; namespace Microsoft.Extensions.Localization { /// /// A locale specific string. /// public class LocalizedString { /// /// Creates a new . /// /// The name of the string in the resource it was loaded from. /// The actual string. public LocalizedString(string name, string value) : this(name, value, resourceNotFound: false) { } /// /// Creates a new . /// /// The name of the string in the resource it was loaded from. /// The actual string. /// Whether the string was found in a resource. Set this to false to indicate an alternate string value was used. public LocalizedString(string name, string value, bool resourceNotFound) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } Name = name; Value = value; ResourceNotFound = resourceNotFound; } public static implicit operator string(LocalizedString localizedString) { return localizedString?.Value; } /// /// The name of the string in the resource it was loaded from. /// public string Name { get; } /// /// The actual string. /// public string Value { get; } /// /// Whether the string was found in a resource. If false, an alternate string value was used. /// public bool ResourceNotFound { get; } /// /// Returns the actual string. /// /// The actual string. public override string ToString() => Value; } }