예제 #1
0
        private void cboMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            int idx = cboMode.SelectedIndex;

            if (idx < 0 || idx >= InfoData.NameProcs.Length)
            {
                return;
            }
            IndentedWriterObjectProc proc = InfoData.NameProcs[idx].Value;
            StringBuilder            sb   = new StringBuilder();
            IIndentedWriter          iw   = new TextIndentedWriter(new StringWriter(sb));

            try {
                proc(iw, null, null);
            }
            catch (Exception ex) {
                sb.AppendLine(ex.ToString());
            }
            txtInfo.Text = sb.ToString();
        }
예제 #2
0
        /// <summary>
        /// 输出对象_枚举条目.
        /// </summary>
        /// <param name="iw">带缩进输出者.</param>
        /// <param name="obj">object.</param>
        /// <param name="context">Context.</param>
        /// <param name="tp">类型.</param>
        public virtual void WriterObject_WriteEnumerate(IIndentedWriter iw, object obj, IndentedWriterContext context, Type tp)
        {
            if (0 != (m_Options & IndentedObjectFunctorOptions.NoEnumerate))
            {
                return;
            }
            IEnumerable lst = obj as IEnumerable;

            if (null == lst)
            {
                return;
            }
            int i = 0;

            foreach (object p in lst)
            {
                string name = string.Format("[{0}]", i);
                IndentedWriterObjectProc proc = null;
                if (null != context)
                {
                    proc = IndentedWriterUtil.LookupWriteProcAt(p, context, context.Procs);
                }
                if (null == proc && (m_WriterOptions & IndentedWriterMemberOptions.NoCommonProcs) == 0)
                {
                    if (IndentedObjectFunctor.CommonProc(null, p, context))
                    {
                        proc = IndentedObjectFunctor.CommonProc;
                    }
                }
                IndentedWriterUtil.WriteLineValue(iw, name, p, IndentedWriterValueOptions.Default, null);
                if (null != proc)
                {
                    proc(iw, p, context);
                }
                // next.
                ++i;
            }
        }