private static TagHelperAttributeDescriptor ToAttributeDescriptor(
            IPropertyInfo property,
            string attributeName,
            string typeName,
            bool isIndexer,
            bool isStringProperty,
            bool designTime)
        {
            TagHelperAttributeDesignTimeDescriptor propertyDesignTimeDescriptor = null;

#if !DOTNET5_4
            if (designTime)
            {
                var runtimeProperty = property as RuntimePropertyInfo;
                if (runtimeProperty != null)
                {
                    propertyDesignTimeDescriptor =
                        TagHelperDesignTimeDescriptorFactory.CreateAttributeDescriptor(runtimeProperty.Property);
                }
            }
#endif

            return(new TagHelperAttributeDescriptor
            {
                Name = attributeName,
                PropertyName = property.Name,
                TypeName = typeName,
                IsStringProperty = isStringProperty,
                IsIndexer = isIndexer,
                DesignTimeDescriptor = propertyDesignTimeDescriptor
            });
        }
        private TagHelperAttributeDescriptor ToAttributeDescriptor(
            PropertyInfo property,
            string attributeName,
            string typeName,
            bool isIndexer,
            bool isStringProperty)
        {
            TagHelperAttributeDesignTimeDescriptor propertyDesignTimeDescriptor = null;

            if (_designTime)
            {
                propertyDesignTimeDescriptor = _designTimeDescriptorFactory.CreateAttributeDescriptor(property);
            }

            return new TagHelperAttributeDescriptor
            {
                Name = attributeName,
                PropertyName = property.Name,
                IsEnum = property.PropertyType.GetTypeInfo().IsEnum,
                TypeName = typeName,
                IsStringProperty = isStringProperty,
                IsIndexer = isIndexer,
                DesignTimeDescriptor = propertyDesignTimeDescriptor
            };
        }
示例#3
0
        public void CreateAttributeDescriptor_WithLocalizedProperty_ReturnsExpectedDescriptors(
            Type tagHelperType,
            TagHelperAttributeDesignTimeDescriptor expectedDesignTimeDescriptor,
            string culture)
        {
            // Arrange
            var mockPropertyInfo = new Mock <PropertyInfo>();

            mockPropertyInfo.Setup(propertyInfo => propertyInfo.DeclaringType).Returns(tagHelperType);
            mockPropertyInfo
            .Setup(propertyInfo => propertyInfo.Name)
            .Returns(nameof(DocumentedTagHelper.RemarksAndSummaryProperty));
            TagHelperAttributeDesignTimeDescriptor designTimeDescriptor;

            // Act
            using (new CultureReplacer(culture))
            {
                designTimeDescriptor = TagHelperDesignTimeDescriptorFactory.CreateAttributeDescriptor(
                    mockPropertyInfo.Object);
            }

            // Assert
            Assert.Equal(
                expectedDesignTimeDescriptor,
                designTimeDescriptor,
                TagHelperAttributeDesignTimeDescriptorComparer.Default);
        }
        private static TagHelperAttributeDescriptor ToAttributeDescriptor(
            PropertyInfo property,
            string attributeName,
            string typeName,
            bool isIndexer,
            bool designTime)
        {
            TagHelperAttributeDesignTimeDescriptor propertyDesignTimeDescriptor = null;

#if !DNXCORE50
            if (designTime)
            {
                propertyDesignTimeDescriptor =
                    TagHelperDesignTimeDescriptorFactory.CreateAttributeDescriptor(property);
            }
#endif

            return(new TagHelperAttributeDescriptor
            {
                Name = attributeName,
                PropertyName = property.Name,
                TypeName = typeName,
                IsIndexer = isIndexer,
                DesignTimeDescriptor = propertyDesignTimeDescriptor
            });
        }
示例#5
0
        public void CreateAttributeDescriptor_ReturnsExpectedDescriptors(
            Type tagHelperType,
            string propertyName,
            TagHelperAttributeDesignTimeDescriptor expectedDesignTimeDescriptor)
        {
            // Arrange
            var mockPropertyInfo = new Mock <PropertyInfo>();

            mockPropertyInfo.Setup(propertyInfo => propertyInfo.DeclaringType).Returns(tagHelperType);
            mockPropertyInfo.Setup(propertyInfo => propertyInfo.Name).Returns(propertyName);

            // Act
            var designTimeDescriptor = TagHelperDesignTimeDescriptorFactory.CreateAttributeDescriptor(
                mockPropertyInfo.Object);

            // Assert
            Assert.Equal(
                expectedDesignTimeDescriptor,
                designTimeDescriptor,
                TagHelperAttributeDesignTimeDescriptorComparer.Default);
        }