コード例 #1
0
        public void IsComponent(Type type, bool expected)
        {
            // Arrange & Act
            var result = ViewComponentConventions.IsComponent(type.GetTypeInfo());

            // Assert
            Assert.Equal(expected, result);
        }
コード例 #2
0
        /// <summary>
        /// Determines whether or not the given <see cref="TypeInfo"/> is a view component class.
        /// </summary>
        /// <param name="typeInfo">The <see cref="TypeInfo"/>.</param>
        /// <returns>
        /// <c>true</c> if <paramref name="typeInfo"/>represents a view component class, otherwise <c>false</c>.
        /// </returns>
        protected virtual bool IsViewComponentType(TypeInfo typeInfo)
        {
            if (typeInfo == null)
            {
                throw new ArgumentNullException(nameof(typeInfo));
            }

            return(ViewComponentConventions.IsComponent(typeInfo));
        }
コード例 #3
0
        private static ViewComponentDescriptor CreateCandidate(TypeInfo typeInfo)
        {
            var candidate = new ViewComponentDescriptor()
            {
                FullName  = ViewComponentConventions.GetComponentFullName(typeInfo),
                ShortName = ViewComponentConventions.GetComponentName(typeInfo),
                Type      = typeInfo.AsType(),
            };

            return(candidate);
        }
コード例 #4
0
        private static ViewComponentDescriptor CreateDescriptor(TypeInfo typeInfo)
        {
            var type      = typeInfo.AsType();
            var candidate = new ViewComponentDescriptor
            {
                FullName   = ViewComponentConventions.GetComponentFullName(typeInfo),
                ShortName  = ViewComponentConventions.GetComponentName(typeInfo),
                Type       = type,
                MethodInfo = FindMethod(type)
            };

            return(candidate);
        }
コード例 #5
0
 /// <summary>
 /// Determines whether or not the given <see cref="TypeInfo"/> is a View Component class.
 /// </summary>
 /// <param name="typeInfo">The <see cref="TypeInfo"/>.</param>
 /// <returns>
 /// <c>true</c> if <paramref name="typeInfo"/>represents a View Component class, otherwise <c>false</c>.
 /// </returns>
 protected virtual bool IsViewComponentType([NotNull] TypeInfo typeInfo)
 {
     return(ViewComponentConventions.IsComponent(typeInfo));
 }