コード例 #1
0
        /// <inheritdoc />
        public ViewComponentDescriptor SelectComponent(string componentName)
        {
            if (componentName == null)
            {
                throw new ArgumentNullException(nameof(componentName));
            }

            var collection = _descriptorProvider.ViewComponents;

            if (_cache == null || _cache.Version != collection.Version)
            {
                _cache = new ViewComponentDescriptorCache(collection);
            }

            // ViewComponent names can either be fully-qualified, or refer to the 'short-name'. If the provided
            // name contains a '.' - then it's a fully-qualified name.
            if (componentName.Contains("."))
            {
                return(_cache.SelectByFullName(componentName));
            }
            else
            {
                return(_cache.SelectByShortName(componentName));
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public ViewComponentDescriptor SelectComponent([NotNull] string componentName)
        {
            var collection = _descriptorProvider.ViewComponents;
            if (_cache == null || _cache.Version != collection.Version)
            {
                _cache = new ViewComponentDescriptorCache(collection);
            }

            // ViewComponent names can either be fully-qualified, or refer to the 'short-name'. If the provided
            // name contains a '.' - then it's a fully-qualified name.
            if (componentName.Contains("."))
            {
                return _cache.SelectByFullName(componentName);
            }
            else
            {
                return _cache.SelectByShortName(componentName);
            }
        }