Пример #1
0
        public void SetUp()
        {
            _memberInformationGlobalizationServiceMock = MockRepository.GenerateStrictMock <IMemberInformationGlobalizationService>();

            _validationRule = MockRepository.GenerateStub <IValidationRule>();
            _propertyRule   = PropertyRule.Create(ExpressionHelper.GetTypedMemberExpression <Customer, string> (c => c.LastName));

            _service = new PropertyDisplayNameGlobalizationService(_memberInformationGlobalizationServiceMock);
        }
Пример #2
0
        public void SetUp()
        {
            _mockRepository = new MockRepository();

            _innerService1 = _mockRepository.StrictMock <IMemberInformationGlobalizationService>();
            _innerService2 = _mockRepository.StrictMock <IMemberInformationGlobalizationService>();
            _innerService3 = _mockRepository.StrictMock <IMemberInformationGlobalizationService>();

            _service = new CompoundMemberInformationGlobalizationService(new[] { _innerService1, _innerService2, _innerService3 });
        }
        public void SetUp()
        {
            _typeInformationStub = MockRepository.GenerateStub <ITypeInformation>();
            _typeInformationStub.Stub(stub => stub.Name).Return("TypeName");

            _propertyInformationStub = MockRepository.GenerateStub <IPropertyInformation>();
            _propertyInformationStub.Stub(stub => stub.Name).Return("PropertyName");

            _typeInformationForResourceResolutionStub = MockRepository.GenerateStub <ITypeInformation>();

            _serviceStub = MockRepository.GenerateStub <IMemberInformationGlobalizationService> ();
        }
        /// <summary>
        ///   Checks whether a human-readable type name of the spefified reflection object exists.
        /// </summary>
        /// <param name="memberInformationGlobalizationService">
        ///   The <see cref="IMemberInformationGlobalizationService"/> to use during the lookup. Must not be <see langword="null" />.
        /// </param>
        /// <param name="typeInformation">
        ///   The <see cref="ITypeInformation"/> that defines the type name for the resource lookup. Must not be <see langword="null" />.
        /// </param>
        /// <param name="typeInformationForResourceResolution">
        ///   The <see cref="ITypeInformation"/> that should be used for the resource resolution. Must not be <see langword="null" />.
        /// </param>
        /// <returns><see langword="true" /> if a resource could be found.</returns>
        public static bool ContainsTypeDisplayName(
            [NotNull] this IMemberInformationGlobalizationService memberInformationGlobalizationService,
            [NotNull] ITypeInformation typeInformation,
            [NotNull] ITypeInformation typeInformationForResourceResolution)
        {
            ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService);
            ArgumentUtility.CheckNotNull("typeInformation", typeInformation);
            ArgumentUtility.CheckNotNull("typeInformationForResourceResolution", typeInformationForResourceResolution);

            string resourceValue;

            return(memberInformationGlobalizationService.TryGetTypeDisplayName(typeInformation, typeInformationForResourceResolution, out resourceValue));
        }
        public PropertyRuleDisplayNameStringSource(
            PropertyRule propertyRule, Type typeToValidate, IMemberInformationGlobalizationService globalizationService)
        {
            ArgumentUtility.CheckNotNull("propertyRule", propertyRule);
            ArgumentUtility.CheckNotNull("typeToValidate", typeToValidate);
            ArgumentUtility.CheckNotNull("globalizationService", globalizationService);

            _propertyRule         = propertyRule;
            _typeToValidate       = typeToValidate;
            _globalizationService = globalizationService;

            _resourceName = typeToValidate.FullName;
            _resourceType = globalizationService.GetType();
        }
Пример #6
0
        public BindableObjectGlobalizationService(
            IGlobalizationService globalizationServices,
            IMemberInformationGlobalizationService memberInformationGlobalizationService,
            IEnumerationGlobalizationService enumerationGlobalizationService,
            IExtensibleEnumGlobalizationService extensibleEnumGlobalizationService)
        {
            ArgumentUtility.CheckNotNull("globalizationServices", globalizationServices);
            ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService);
            ArgumentUtility.CheckNotNull("enumerationGlobalizationService", enumerationGlobalizationService);
            ArgumentUtility.CheckNotNull("extensibleEnumGlobalizationService", extensibleEnumGlobalizationService);

            _resourceManager = new Lazy <IResourceManager> (
                () => globalizationServices.GetResourceManager(typeof(ResourceIdentifier)),
                LazyThreadSafetyMode.ExecutionAndPublication);
            _memberInformationGlobalizationService = memberInformationGlobalizationService;
            _enumerationGlobalizationService       = enumerationGlobalizationService;
            _extensibleEnumGlobalizationService    = extensibleEnumGlobalizationService;
        }
        public static string GetPropertyDisplayNameOrDefault(
            this IMemberInformationGlobalizationService memberInformationGlobalizationService,
            IPropertyInformation propertyInformation,
            ITypeInformation typeInformationForResourceResolution)
        {
            ArgumentUtility.CheckNotNull("memberInformationGlobalizationService", memberInformationGlobalizationService);
            ArgumentUtility.CheckNotNull("propertyInformation", propertyInformation);
            ArgumentUtility.CheckNotNull("typeInformationForResourceResolution", typeInformationForResourceResolution);

            string resourceValue;

            if (memberInformationGlobalizationService.TryGetPropertyDisplayName(
                    propertyInformation,
                    typeInformationForResourceResolution,
                    out resourceValue))
            {
                return(resourceValue);
            }

            return(null);
        }
        public PropertyDisplayNameGlobalizationService(IMemberInformationGlobalizationService globalizationService)
        {
            ArgumentUtility.CheckNotNull("globalizationService", globalizationService);

            _globalizationService = globalizationService;
        }