/// <summary> /// 递归执行转换 /// 调用头转换器进行解析context /// </summary> /// <param name="context">转换上下文</param> /// <returns></returns> protected IEnumerable <KeyValuePair <string, string> > Recurse(ConvertContext context) { if (context.Depths >= this.maxDepth) { throw new NotSupportedException("转换的层数已超过设置的MaxDepth"); } context.Depths = context.Depths + 1; return(this.first.Invoke(context)); }
/// <summary> /// 结合context.Options约定 /// 将context的Value值转换为键值对 /// </summary> /// <param name="context">上下文</param> /// <exception cref="ArgumentNullException"></exception> /// <returns></returns> protected KeyValuePair <string, string> GetKeyValuePair(ConvertContext context) { return(this.GetKeyValuePair(context.Name, context.Value, context.Options)); }
/// <summary> /// 递归序列化 /// 使用与Converter关联的IJsonFormatter进行序列化 /// </summary> /// <param name="context">上下文</param> /// <returns></returns> protected IEnumerable <KeyValuePair <string, string> > Recursion(ConvertContext context) { return(this.Recursion(context.Name, context.Value, context.Options)); }
/// <summary> /// 执行转换 /// </summary> /// <param name="context">转换上下文</param> /// <returns></returns> public abstract IEnumerable <KeyValuePair <string, string> > Invoke(ConvertContext context);