Esempio n. 1
0
 //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
 public static System.Object read(System.IO.BinaryReader in_Renamed, System.Type type, PrototypeFactory pf)
 {
     if (typeof(Externalizable).IsAssignableFrom(type))
     {
         Externalizable ext = (Externalizable)PrototypeFactory.getInstance(type);
         ext.readExternal(in_Renamed, pf == null?defaultPrototypes():pf);
         return(ext);
     }
     else if (type == typeof(System.SByte))
     {
         return((sbyte)readByte(in_Renamed));
     }
     else if (type == typeof(System.Int16))
     {
         return((short)readShort(in_Renamed));
     }
     else if (type == typeof(System.Int32))
     {
         return((System.Int32)readInt(in_Renamed));
     }
     else if (type == typeof(System.Int64))
     {
         return((long)readNumeric(in_Renamed));
     }
     else if (type == typeof(System.Char))
     {
         return(readChar(in_Renamed));
     }
     else if (type == typeof(System.Single))
     {
         //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
         return((float)readDecimal(in_Renamed));
     }
     else if (type == typeof(System.Double))
     {
         return((double)readDecimal(in_Renamed));
     }
     else if (type == typeof(System.Boolean))
     {
         return(readBool(in_Renamed));
     }
     else if (type == typeof(System.String))
     {
         return(readString(in_Renamed));
     }
     else if (type == typeof(System.DateTime))
     {
         return(readDate(in_Renamed));
     }
     else if (type == typeof(sbyte[]))
     {
         return(readBytes(in_Renamed));
     }
     else
     {
         //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
         throw new System.InvalidCastException("Not a deserializable datatype: " + type.FullName);
     }
 }
Esempio n. 2
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static ExternalizableWrapper readTag(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            sbyte[] tag = new sbyte[PrototypeFactory.CLASS_HASH_SIZE];

            in_Renamed.Read((byte[])(Array)tag, 0, tag.Length);



            if (PrototypeFactory.compareHash(tag, WRAPPER_TAG))
            {
                int wrapperCode = ExtUtil.readInt(in_Renamed);

                //find wrapper indicated by code
                ExternalizableWrapper type = null;

                foreach (Object key in WRAPPER_CODES.Keys)
                {
                    System.Type t = (System.Type)key;
                    if ((int)WRAPPER_CODES[key] == wrapperCode)
                    {
                        try
                        {
                            type = (ExternalizableWrapper)PrototypeFactory.getInstance(t);
                        }
                        catch (CannotCreateObjectException ccoe)
                        {
                            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                            throw new CannotCreateObjectException("Serious problem: cannot create built-in ExternalizableWrapper [" + t.FullName + "]");
                        }
                    }
                }
                if (type == null)
                {
                    throw new DeserializationException("Unrecognized ExternalizableWrapper type [" + wrapperCode + "]");
                }

                type.metaReadExternal(in_Renamed, pf);
                return(type);
            }
            else
            {
                System.Type type = pf.getClass(tag);
                if (type == null)
                {
                    throw new DeserializationException("No datatype registered to serialization code " + ExtUtil.printBytes((byte[])(Array)tag));
                }

                return(new ExtWrapBase(type));
            }
        }