示例#1
0
        /// <summary>使用指定的上下文和区域性信息将给定的对象转换为此转换器的类型。</summary>
        /// <returns>表示转换的 value 的 <see cref="T:System.Object" />。</returns>
        /// <param name="context">一个 <see cref="T:System.ComponentModel.ITypeDescriptorContext" />,提供格式上下文。</param>
        /// <param name="culture">用作当前区域性的 <see cref="T:System.Globalization.CultureInfo" />。</param>
        /// <param name="value">要转换的 <see cref="T:System.Object" />。</param>
        /// <exception cref="T:System.NotSupportedException">不能执行转换。</exception>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var realValue = value as string;

            if (realValue == null)
            {
                throw new NotSupportedException();
            }

            return(PagerItemLinkGenerators.FromConfiguration(realValue));
        }
示例#2
0
        /// <inheritdoc />
        protected override IPagerItemLinkGenerator GetLinkGenerator(string baseUri)
        {
            if (string.IsNullOrEmpty(QueryName))
            {
                throw new InvalidOperationException($"The value of '{QueryNameAttributeName}' attribute cannot be null or empty string.");
            }

            var result = PagerItemLinkGenerators.QueryName(QueryName);

            result.BaseUri = baseUri;

            return(result);
        }