public Object valueOf(Serializer serializer, SerializedData serialized, Dictionary<string, object> context)
        {
            int oid = serialized.consumeSize();
            serialized.skipOver(1);     // "{"
            string name = (string)serializer.valueOf(serialized, context);
            serialized.skipOver(1);     // "}";

            return Proxy.NewProxyInstance(oid, name, (XPProtocol)context["handler"]);
        }
Exemplo n.º 2
0
        public Object valueOf(Serializer serializer, SerializedData serialized, Dictionary <string, object> context)
        {
            int oid = serialized.consumeSize();

            serialized.skipOver(1);     // "{"
            string name = (string)serializer.valueOf(serialized, context);

            serialized.skipOver(1);     // "}";

            return(Proxy.NewProxyInstance(oid, name, (XPProtocol)context["handler"]));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Retrieve value of a serialized string
        /// </summary>
        /// <param name="serialized"></param>
        /// <returns></returns>
        public object valueOf(SerializedData serialized, Dictionary <string, object> context)
        {
            char token = serialized.consumeToken();

            switch (token)
            {
            case 'b':
                return(!serialized.consumeWord().Equals("0"));        // 0 = false, any other value = true

            case 'i':
                return(int.Parse(serialized.consumeWord()));

            case 'd':
                return(double.Parse(serialized.consumeWord()));

            case 's':
                return(serialized.consumeString());

            case 'a':
                System.Collections.Hashtable array = new System.Collections.Hashtable();
                int length = serialized.consumeSize();

                serialized.skipOver(1);         // {
                for (int i = 0; i < length; i++)
                {
                    array[this.valueOf(serialized, context)] = this.valueOf(serialized, context);
                }
                serialized.skipOver(1);         // }
                return(array);

            case 'O':
                String classname = serialized.consumeString();
                int    members   = serialized.consumeSize();

                // Check if we can map this type to a class, if we can't, use UnknownRemoteObject
                Type t = Type.GetType(classname);
                if (t == null)
                {
                    UnknownRemoteObject instance = new UnknownRemoteObject();
                    instance.name = classname;
                    serialized.skipOver(1);       // {
                    for (int i = 0; i < members; i++)
                    {
                        instance.members[(string)this.valueOf(serialized, context)] = this.valueOf(serialized, context);
                    }
                    serialized.skipOver(1);         // }
                    return(instance);
                }
                else
                {
                    object instance = Activator.CreateInstance(t);
                    serialized.skipOver(1);         // {
                    for (int i = 0; i < members; i++)
                    {
                        string member = (string)this.valueOf(serialized, context);
                        object value  = this.valueOf(serialized, context);
                        t.GetMember(member).SetValue(value, 0);
                    }
                    serialized.skipOver(1);         // }
                    return(instance);
                }

            default:

                // Check the mappings
                if (this.mappings.ContainsKey(token))
                {
                    return(this.mappings[token].valueOf(this, serialized, context));
                }

                // No mapping, not builtin
                throw new FormatException("Unknown token " + token);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Retrieve value of a serialized string
        /// </summary>
        /// <param name="serialized"></param>
        /// <returns></returns>
        public object valueOf(SerializedData serialized, Dictionary<string, object> context)
        {
            char token = serialized.consumeToken();
            switch (token)
            {
                case 'b':
                    return !serialized.consumeWord().Equals("0");     // 0 = false, any other value = true

                case 'i':
                    return int.Parse(serialized.consumeWord());

                case 'd':
                    return double.Parse(serialized.consumeWord());

                case 's':
                    return serialized.consumeString();

                case 'a':
                    System.Collections.Hashtable array = new System.Collections.Hashtable();
                    int length = serialized.consumeSize();

                    serialized.skipOver(1);     // {
                    for (int i = 0; i < length; i++)
                    {
                        array[this.valueOf(serialized, context)] = this.valueOf(serialized, context);
                    }
                    serialized.skipOver(1);     // }
                    return array;

                case 'O':
                    String classname = serialized.consumeString();
                    int members = serialized.consumeSize();

                    // Check if we can map this type to a class, if we can't, use UnknownRemoteObject
                    Type t= Type.GetType(classname);
                    if (t == null)
                    {
                        UnknownRemoteObject instance= new UnknownRemoteObject();
                        instance.name = classname;
                        serialized.skipOver(1);   // {
                        for (int i = 0; i < members; i++)
                        {
                            instance.members[(string)this.valueOf(serialized, context)] = this.valueOf(serialized, context);
                        }
                        serialized.skipOver(1);     // }
                        return instance;
                    } else {
                        object instance = Activator.CreateInstance(t);
                        serialized.skipOver(1);     // {
                        for (int i = 0; i < members; i++)
                        {
                            string member = (string)this.valueOf(serialized, context);
                            object value = this.valueOf(serialized, context);
                            t.GetMember(member).SetValue(value, 0);
                        }
                        serialized.skipOver(1);     // }
                        return instance;
                    }

                default:

                    // Check the mappings
                    if (this.mappings.ContainsKey(token))
                    {
                        return this.mappings[token].valueOf(this, serialized, context);
                    }

                    // No mapping, not builtin
                    throw new FormatException("Unknown token " + token);
            }
        }