Example #1
0
        public CQ_Value New(CQ_Content content, IList <CQ_Value> _params)
        {
            if (contentMemberCalc == null)
            {
                contentMemberCalc = new CQ_Content();
            }
            NewStatic();
            CQ_Expression_Value_ScriptValue sv = new CQ_Expression_Value_ScriptValue();

            sv.value_type       = this;
            sv.value_value      = new CQClassInstance();
            sv.value_value.type = this;
            foreach (KeyValuePair <string, Member> i in this.members)
            {
                if (i.Value.bStatic == false)
                {
                    if (i.Value.expr_defvalue == null)
                    {
                        sv.value_value.member[i.Key]       = new CQ_Value();
                        sv.value_value.member[i.Key].type  = i.Value.type.typeBridge;
                        sv.value_value.member[i.Key].value = i.Value.type.defaultValue;
                    }
                    else
                    {
                        var value = i.Value.expr_defvalue.ComputeValue(contentMemberCalc);
                        if (i.Value.type.typeBridge != value.type)
                        {
                            sv.value_value.member[i.Key]       = new CQ_Value();
                            sv.value_value.member[i.Key].type  = i.Value.type.typeBridge;
                            sv.value_value.member[i.Key].value = value.ConvertTo(i.Value.type.typeBridge);
                        }
                        else
                        {
                            sv.value_value.member[i.Key] = value;
                        }
                    }
                }
            }
            if (this.functions.ContainsKey(this.Name))//有同名函数就调用
            {
                MemberCall(content, sv.value_value, this.Name, _params);
            }
            return(CQ_Value.FromICQ_Value(sv));
        }