コード例 #1
0
        private void cbbMethods_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.dataGridView1.Rows.Clear();

            MethodInfo    mi  = this.methods[this.cbbMethods.SelectedIndex];
            ParameterInfo ret = mi.ReturnParameter;

            this.dataGridView1.Rows.Add("返回值类型", ret.ParameterType.Name, "");
            ParameterInfo[] para = mi.GetParameters();
            foreach (ParameterInfo pi in para)
            {
                string defaultVa = Parser.Instance.GetDefalutValue(pi.ParameterType, ReflectUtil.GetMarshalAsAttribute(pi));
                if (pi.ParameterType.Name.Equals("Array&"))
                {
                    this.dataGridView1.Rows.Add(pi.Name, pi.ParameterType.Name + "(" + ArrayParser.typeDic[ReflectUtil.GetMarshalAsAttribute(pi).SafeArraySubType].Name + ")", defaultVa);
                }
                else
                {
                    this.dataGridView1.Rows.Add(pi.Name, pi.ParameterType.Name, defaultVa);
                }
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Tag = pi;
            }

            this.OnFuctionSlected(mi);
        }
コード例 #2
0
        /// <summary>
        /// 创建要调用的参数
        /// </summary>
        /// <returns></returns>
        protected object[] CreateParameters()
        {
            object[] values = new object[this.dataGridView1.Rows.Count - 1];
            for (int i = 1; i < this.dataGridView1.Rows.Count; i++)
            {
                ParameterInfo pi       = this.dataGridView1.Rows[i].Tag as ParameterInfo;
                Type          paraType = pi.ParameterType;

                values[i - 1] = Parser.Instance.Parse(paraType, ReflectUtil.GetMarshalAsAttribute(pi), this.dataGridView1.Rows[i].Cells[this.colValue.Index].Value.ToString());
            }
            return(values);
        }
コード例 #3
0
        private void cbbClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.currentType   = null;
            this.currentObject = null;
            this.currentCI     = null;
            this.dgvTypeInfo.Rows.Clear();

            this.currentType = this.types[this.cbbClass.SelectedIndex];
            ConstructorInfo[] cis = this.currentType.GetConstructors();
            foreach (ConstructorInfo c in cis)
            {
                if (c.GetParameters().Length != 0)
                {
                    this.currentCI = c;
                    break;
                }
            }
            if (this.currentCI == null)
            {
                MessageBox.Show("该方法不具有带参的构造函数");
                this.currentCI = cis[0];
            }

            try
            {
                ParameterInfo[] pis = this.currentCI.GetParameters();
                foreach (ParameterInfo pi in pis)
                {
                    if (pi.ParameterType.Name.Equals("Array&"))
                    {
                        this.dgvTypeInfo.Rows.Add(pi.Name, pi.ParameterType.Name + "(" + ArrayParser.typeDic[ReflectUtil.GetMarshalAsAttribute(pi).SafeArraySubType].Name + ")", "");
                    }
                    else
                    {
                        this.dgvTypeInfo.Rows.Add(pi.Name, pi.ParameterType.Name, "");
                    }
                    this.dgvTypeInfo.Rows[this.dgvTypeInfo.Rows.Count - 1].Tag = pi;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "创建对象失败");
            }
        }