示例#1
0
    //添加一个参数
    public static void AddObjectArgs(ref VarList args, ref object o)
    {
        System.Type itype = o.GetType();
        if (itype == typeof(bool))
        {
            args.AddBool((bool)o);
        }
        else if (itype == typeof(int))
        {
            args.AddInt((int)o);
        }
        else if (itype == typeof(long))
        {
            args.AddInt64((long)o);
        }
        else if (itype == typeof(float))
        {
            args.AddFloat((float)o);
        }
        else if (itype == typeof(double))
        {
            args.AddDouble((double)o);
        }
        else if (itype == typeof(ObjectID))
        {
            args.AddObject((ObjectID)o);
        }
        else if (itype == typeof(string))
        {
            args.AddString((string)o);
        }
        else if (itype == typeof(byte[]))
        {
            args.AddUserData((byte[])o);
        }
        else if (itype == typeof(WideString))
        {
            args.AddWideStr(((WideString)o).mstrContent);
        }
        else if (itype == typeof(VarList))
        {
            int iCount = ((VarList)o).GetCount();
            for (int j = 0; j < iCount; j++)
            {
                switch (((VarList)o).GetType(j))
                {
                case VarType.Bool:
                    args.AddBool(((VarList)o).GetBool(j));
                    break;

                case VarType.Int:
                    args.AddInt(((VarList)o).GetInt(j));
                    break;

                case VarType.Int64:
                    args.AddInt64(((VarList)o).GetInt64(j));
                    break;

                case VarType.Float:
                    args.AddFloat(((VarList)o).GetFloat(j));
                    break;

                case VarType.Double:
                    args.AddDouble(((VarList)o).GetDouble(j));
                    break;

                case VarType.String:
                    args.AddString(((VarList)o).GetString(j));
                    break;

                case VarType.WideStr:
                    args.AddWideStr(((VarList)o).GetWideStr(j));
                    break;

                case VarType.Object:
                    args.AddObject(((VarList)o).GetObject(j));
                    break;

                case VarType.UserData:
                    args.AddUserData(((VarList)o).GetUserData(j));
                    break;
                }
            }
        }
    }