示例#1
0
        internal static object GetArgumentInfoValue(Type t, XDRPCArgumentInfo argInfo)
        {
            object obj = (object)null;

            if (typeof(string) == t)
            {
                obj = (object)((XDRPCStringArgumentInfo)argInfo).Value;
            }
            else if (t.IsPrimitive || t.IsValueType || XDRPCMarshaler.IsValidArrayType(t))
            {
                Type type;
                if (t.IsPrimitive)
                {
                    type = typeof(XDRPCArgumentInfo <>).MakeGenericType(t);
                }
                else if (t.IsValueType)
                {
                    type = typeof(XDRPCStructArgumentInfo <>).MakeGenericType(t);
                }
                else
                {
                    type = typeof(XDRPCArrayArgumentInfo <>).MakeGenericType(t);
                }
                obj = type.GetProperty("Value").GetValue((object)argInfo, (object[])null);
            }
            return(obj);
        }
示例#2
0
 internal static bool IsValidArgumentType(Type t)
 {
     if (!XDRPCMarshaler.IsValidValueType(t) && !XDRPCMarshaler.IsValidArrayType(t))
     {
         return(typeof(string) == t);
     }
     return(true);
 }
示例#3
0
        internal static XDRPCArgumentInfo GenerateArgumentInfo(
            Type t,
            object o,
            ArgumentType at,
            int size,
            Encoding encoding)
        {
            XDRPCArgumentInfo xdrpcArgumentInfo = (XDRPCArgumentInfo)null;

            if (t.IsPrimitive || t.IsValueType)
            {
                Type type;
                if (t.IsPrimitive)
                {
                    type = typeof(XDRPCArgumentInfo <>).MakeGenericType(t);
                }
                else
                {
                    type = typeof(XDRPCStructArgumentInfo <>).MakeGenericType(t);
                }
                xdrpcArgumentInfo = (XDRPCArgumentInfo)type.GetConstructor(new Type[2]
                {
                    t,
                    typeof(ArgumentType)
                }).Invoke(new object[2] {
                    o, (object)at
                });
            }
            else if (XDRPCMarshaler.IsValidArrayType(t))
            {
                xdrpcArgumentInfo = (XDRPCArgumentInfo)typeof(XDRPCArrayArgumentInfo <>).MakeGenericType(t).GetConstructor(new Type[3]
                {
                    t,
                    typeof(ArgumentType),
                    typeof(int)
                }).Invoke(new object[3]
                {
                    o,
                    (object)at,
                    (object)size
                });
            }
            else if (typeof(string) == t)
            {
                xdrpcArgumentInfo = (XDRPCArgumentInfo) new XDRPCStringArgumentInfo((string)o, encoding, at, size, XDRPCStringArgumentInfo.GetDefaultCountTypeForEncoding(encoding));
            }
            return(xdrpcArgumentInfo);
        }
        public XDRPCArrayArgumentInfo(T v, ArgumentType t, int maxArrayLength)
        {
            Type t1 = typeof(T);

            if (!t1.IsArray)
            {
                throw new XDRPCInvalidTypeException(t1, "Array type must be provided for XDRPCArrayArgumentInfo.");
            }
            if (!XDRPCMarshaler.IsValidArrayType(t1))
            {
                throw new XDRPCInvalidTypeException(t1, string.Format("Array type {0} is not supported by XDRPC.", (object)t1.Name));
            }
            this.Value        = v;
            this._arrayLength = (object)this.Value == null ? 0 : ((object)this.Value as Array).Length;
            if (t == ArgumentType.Out && maxArrayLength <= 0)
            {
                throw new XDRPCException("The max array length must be specified for an Out type array.");
            }
            this.PassBy         = t;
            this._elementSize   = MarshalingUtils.SizeOf(t1.GetElementType());
            this.MaxArrayLength = this.PassBy != ArgumentType.ByRef ? (this.PassBy != ArgumentType.Out ? this._arrayLength : maxArrayLength) : Math.Max(this._arrayLength, maxArrayLength);
            this.ConstructArgumentInfoArray();
        }