private bool IsEnabled(IExtensibleEnum value, IBusinessObject businessObject)
 {
     return(_enumerationValueFilter.IsEnabled(
                new EnumerationValueInfo(value, value.ID, null, true),
                businessObject,
                this));
 }
Example #2
0
        public bool TryGetExtensibleEnumValueDisplayName(IExtensibleEnum value, out string result)
        {
            ArgumentUtility.CheckNotNull("value", value);

            var resourceType    = value.GetValueInfo().DefiningMethod.DeclaringType;
            var resourceManager = _globalizationService.GetResourceManager(TypeAdapter.Create(resourceType));

            return(resourceManager.TryGetString(value.ID, out result));
        }
Example #3
0
        public static string GetLocalizedName(this IExtensibleEnum extensibleEnum)
        {
            ArgumentUtility.CheckNotNull("extensibleEnum", extensibleEnum);
            string name;

            if (s_tryGetExtensibleEnumValueDisplayName.Value(extensibleEnum, out name))
            {
                return(name);
            }
            return(extensibleEnum.ValueName);
        }
        /// <summary>
        ///   Checks whether a human-readable extensible-enumeration name of the spefified reflection object exists.
        /// </summary>
        /// <param name="extensibleEnumGlobalizationService">
        ///   The <see cref="IExtensibleEnumGlobalizationService"/> to use during the lookup. Must not be <see langword="null" />.
        /// </param>
        /// <param name="value">
        ///   The <see cref="IExtensibleEnum"/> that defines the name for the resource lookup. Must not be <see langword="null" />.
        /// </param>
        /// <returns><see langword="true" /> if a resource could be found.</returns>
        public static bool ContainsExtensibleEnumValueDisplayName(
            [NotNull] this IExtensibleEnumGlobalizationService extensibleEnumGlobalizationService,
            [NotNull] IExtensibleEnum value)
        {
            ArgumentUtility.CheckNotNull("extensibleEnumGlobalizationService", extensibleEnumGlobalizationService);
            ArgumentUtility.CheckNotNull("value", value);

            string result;

            return(extensibleEnumGlobalizationService.TryGetExtensibleEnumValueDisplayName(value, out result));
        }
        public bool TryGetExtensibleEnumValueDisplayName(IExtensibleEnum value, out string result)
        {
            ArgumentUtility.CheckNotNull("value", value);

            var extensibleEnumInfo = value.GetValueInfo();

            Assertion.IsNotNull(extensibleEnumInfo, "No value info found for extensible enum '{0}'.", value.ID);

            var definingMethod = extensibleEnumInfo.DefiningMethod;

            Assertion.IsNotNull(definingMethod, "No defining method found for extensible enum '{0}'.", value.ID);

            return(_localizedNameForEnumerationProvider.TryGetLocalizedNameForCurrentUICulture(definingMethod, out result));
        }
Example #6
0
        public bool TryGetExtensibleEnumValueDisplayName(IExtensibleEnum value, out string result)
        {
            ArgumentUtility.CheckNotNull("value", value);

            foreach (var service in _extensibleEnumGlobalizationServices)
            {
                if (service.TryGetExtensibleEnumValueDisplayName(value, out result))
                {
                    return(true);
                }
            }

            result = null;
            return(false);
        }
        public static string GetExtensibleEnumValueDisplayNameOrDefault(
            [NotNull] this IExtensibleEnumGlobalizationService extensibleEnumGlobalizationService,
            [NotNull] IExtensibleEnum value)
        {
            ArgumentUtility.CheckNotNull("extensibleEnumGlobalizationService", extensibleEnumGlobalizationService);
            ArgumentUtility.CheckNotNull("value", value);

            string result;

            if (extensibleEnumGlobalizationService.TryGetExtensibleEnumValueDisplayName(value, out result))
            {
                return(result);
            }

            return(null);
        }
Example #8
0
 /// <inheritdoc />
 public bool IsDefined(IExtensibleEnum value)
 {
     ArgumentUtility.CheckNotNull("value", value);
     return(value.GetEnumType() == GetEnumType() && IsDefined(value.ID));
 }
 public void SetUp()
 {
     _serviceStub = MockRepository.GenerateStub <IExtensibleEnumGlobalizationService>();
     _valueStub   = MockRepository.GenerateStub <IExtensibleEnum>();
 }
Example #10
0
 public abstract bool IsDefined(IExtensibleEnum value);
Example #11
0
 /// <summary>
 /// Gets the localized display name of the extensible enumeration value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>The localized display name.</returns>
 public string GetExtensibleEnumerationValueDisplayName(IExtensibleEnum value) //move to member info globalization service
 {
     ArgumentUtility.CheckNotNull("value", value);
     return(_extensibleEnumGlobalizationService.GetExtensibleEnumValueDisplayName(value));
 }
 private bool IsEnabled(ExtensibleEnumerationProperty propertyWithFilteredType, IExtensibleEnum value)
 {
     return(propertyWithFilteredType.CreateEnumerationValueInfo(value.GetValueInfo(), null).IsEnabled);
 }