Esempio n. 1
0
        /// <summary>
        /// 刷新信息.
        /// </summary>
        private void RefreshInfo()
        {
            string name = cboAssembly.SelectedItem as string;

            if (null == name)
            {
                return;
            }
            // 重新获取程序集.
            if (!name.Equals(m_OldAssemblyName, StringComparison.Ordinal))
            {
                try {
                    m_CurAssembly     = InfoAssembly.LoadAssembly(name);
                    m_OldAssemblyName = name;
                    RefreshModeList();
                }
                catch (Exception ex) {
                    m_OldAssemblyName = null;
                    txtInfo.Text      = ex.ToString();
                }
            }
            if (null == m_CurAssembly)
            {
                return;
            }
            // 计算显示方式.
            InfoMode mode   = 0;
            Type     tp     = null;
            bool     isshow = false;
            object   obj    = cboMode.SelectedItem;

            if (obj is Type)
            {
                tp     = obj as Type;
                isshow = true;
            }
            else if (obj is InfoMode)
            {
                mode   = (InfoMode)obj;
                isshow = true;
            }
            if (!isshow)
            {
                return;
            }
            // 显示信息.
            StringBuilder         sb      = new StringBuilder();
            IIndentedWriter       iw      = new TextIndentedWriter(new StringWriter(sb));
            IndentedWriterContext context = new IndentedWriterContext();

            context.VisitOnce = (bool)chkVisitOnce.IsChecked;
            //this.UseWaitCursor = true;
            this.Cursor = Cursors.Wait;
            //Application.DoEvents();
            try {
                if (null != tp)
                {
                    IndentedWriterMemberOptions options = IndentedWriterMemberOptions.OnlyStatic;
                    if (chkMethod.IsChecked != false)
                    {
                        options |= IndentedWriterMemberOptions.AllowMethod;
                    }
                    InfoAssembly.WriteTypeStatic(iw, context, tp, options);
                }
                else
                {
                    InfoAssembly.WriteInfo(iw, context, m_CurAssembly, mode);
                }
            }
            catch (Exception ex) {
                sb.AppendLine(ex.ToString());
            }
            //this.UseWaitCursor = false;
            this.Cursor  = null;
            txtInfo.Text = sb.ToString();
        }
Esempio n. 2
0
        /// <summary>
        /// 刷新信息.
        /// </summary>
        private void RefreshInfo()
        {
            if (null == cboAssembly)
            {
                return;
            }
            string name = cboAssembly.SelectedItem as string;

            if (null == name)
            {
                return;
            }
            // 重新获取程序集.
            if (!name.Equals(m_OldAssemblyName, StringComparison.Ordinal))
            {
                try {
                    m_CurAssembly     = InfoAssembly.LoadAssembly(name);
                    m_OldAssemblyName = name;
                    RefreshModeList();
                }
                catch (Exception ex) {
                    m_OldAssemblyName = null;
                    txtInfo.Text      = ex.ToString();
                    return;
                }
            }
            if (null == m_CurAssembly)
            {
                return;
            }
            // 计算显示方式.
            InfoMode mode   = 0;
            Type     tp     = null;
            bool     isshow = false;
            object   obj    = cboMode.SelectedItem;

            if (obj is Type)
            {
                tp     = obj as Type;
                isshow = true;
            }
            else if (obj is InfoMode)
            {
                mode   = (InfoMode)obj;
                isshow = true;
            }
            if (!isshow)
            {
                return;
            }
            // 显示信息.
            StringBuilder         sb      = new StringBuilder();
            IIndentedWriter       iw      = new TextIndentedWriter(new StringWriter(sb));
            IndentedWriterContext context = new IndentedWriterContext();

            context.VisitOnce = (bool)chkVisitOnce.IsChecked;
            //this.UseWaitCursor = true;
            //this.Cursor = Cursors.Wait;
            //Application.DoEvents();
            try {
                // test
                //if (false) {
                //	sb.AppendFormat("{0}:\n", m_CurAssembly.FullName);
                //	//IndentedObjectFunctor.CommonProc(iw, m_CurAssembly, null);
                //	Type tp1 = m_CurAssembly.GetType();
                //	foreach (PropertyInfo pi in tp1.GetRuntimeProperties()) {
                //		if (pi.CanRead && pi.GetIndexParameters().Length <= 0) {
                //			try {
                //				object o = pi.GetValue(m_CurAssembly);
                //				sb.AppendFormat("{0}:\t{1}\n", pi.Name, o);
                //			}
                //			catch (Exception ex) {
                //				sb.AppendFormat("{0}\n", ex);
                //			}
                //		}
                //	}
                //}
                // show
                if (true)
                {
                    if (null != tp)
                    {
                        IndentedWriterMemberOptions options = IndentedWriterMemberOptions.OnlyStatic;
                        if (chkMethod.IsChecked != false)
                        {
                            options |= IndentedWriterMemberOptions.AllowMethod;
                        }
                        InfoAssembly.WriteTypeStatic(iw, context, tp, options);
                    }
                    else
                    {
                        InfoAssembly.WriteInfo(iw, context, m_CurAssembly, mode);
                    }
                }
            }
            catch (Exception ex) {
                sb.AppendLine(ex.ToString());
            }
            //this.UseWaitCursor = false;
            //this.Cursor = null;
            txtInfo.Text = sb.ToString();
        }