Esempio n. 1
0
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public static void  writeTag(System.IO.BinaryWriter out_Renamed, System.Object o)
        {
            if (o is ExternalizableWrapper && !(o is ExtWrapBase))
            {
                out_Renamed.Write(SupportClass.ToByteArray(WRAPPER_TAG), 0, PrototypeFactory.CLASS_HASH_SIZE);
                ExtUtil.writeNumeric(out_Renamed, WRAPPER_CODES.get_Renamed(o.GetType()));
                ((ExternalizableWrapper)o).metaWriteExternal(out_Renamed);
            }
            else
            {
                System.Type type = null;

                if (o is ExtWrapBase)
                {
                    ExtWrapBase extType = (ExtWrapBase)o;
                    if (extType.val != null)
                    {
                        o = extType.val;
                    }
                    else
                    {
                        type = extType.type;
                    }
                }
                if (type == null)
                {
                    type = o.GetType();
                }

                sbyte[] tag = PrototypeFactory.getClassHash(type);                 //cache this?
                out_Renamed.Write(SupportClass.ToByteArray(tag), 0, tag.Length);
            }
        }
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 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. 3
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 override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     if (in_Renamed.ReadBoolean())
     {
         val = ExtUtil.read(in_Renamed, type, pf);
     }
     else
     {
         val = null;
     }
 }
Esempio n. 4
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 override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(0));

            long size = ExtUtil.readNumeric(in_Renamed);

            for (int i = 0; i < size; i++)
            {
                v.Add(ExtUtil.read(in_Renamed, new ExtWrapTagged(), pf));
            }

            val = v;
        }
Esempio n. 5
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));
            }
        }
Esempio n. 6
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 override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            if (type != TYPE_SLOW_READ_ONLY)
            {
                System.Collections.IDictionary h;
                long size = ExtUtil.readNumeric(in_Renamed);
                switch (type)
                {
                case (TYPE_NORMAL):
                    //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
                    h = new System.Collections.Hashtable((int)size);
                    break;

                case (TYPE_ORDERED):
                    h = new OrderedMap();
                    break;

                case (TYPE_SLOW_COMPACT):
                    h = (IDictionary)(new Map((int)size));
                    break;

                default:
                    //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
                    h = new System.Collections.Hashtable((int)size);
                    break;
                }

                for (int i = 0; i < size; i++)
                {
                    System.Object key  = ExtUtil.read(in_Renamed, keyType, pf);
                    System.Object elem = ExtUtil.read(in_Renamed, dataType, pf);
                    h[key] = elem;
                }

                val = h;
            }
            else
            {
                int       size = ExtUtil.readInt(in_Renamed);
                ArrayList k    = new ArrayList(size);
                ArrayList v    = new ArrayList(size);
                for (int i = 0; i < size; i++)
                {
                    k[i] = ExtUtil.read(in_Renamed, keyType, pf);
                    v[i] = ExtUtil.read(in_Renamed, dataType, pf);
                }
                val = (IDictionary)(new Map(k, v));
            }
        }
Esempio n. 7
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 override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable h = ordered?new OrderedMap():new System.Collections.Hashtable();

            long size = ExtUtil.readNumeric(in_Renamed);

            for (int i = 0; i < size; i++)
            {
                System.Object key  = ExtUtil.read(in_Renamed, keyType, pf);
                System.Object elem = ExtUtil.read(in_Renamed, new ExtWrapTagged(), pf);
                h[key] = elem;
            }

            val = h;
        }
Esempio n. 8
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 override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            sbyte b = (sbyte)in_Renamed.ReadByte();
            long  l;

            if (b == (sbyte)SupportClass.Identity(0xff))
            {
                l = in_Renamed.ReadInt32();
            }
            else
            {
                l = (b < 0?b + 256:b) - bias;
            }

            val = (long)l;
        }
Esempio n. 9
0
        public static sbyte[] getClassHash(System.Type type)
        {
            sbyte[] hash = new sbyte[CLASS_HASH_SIZE];
            //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'"
            sbyte[] md5 = MD5.hash(SupportClass.ToSByteArray(SupportClass.ToByteArray(type.FullName)));             //add support for a salt, in case of collision?

            for (int i = 0; i < hash.Length; i++)
            {
                hash[i] = md5[i];
            }
            sbyte[] badHash = new sbyte[] { 0, 4, 78, 97 };
            if (PrototypeFactory.compareHash(badHash, hash))
            {
                //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'"
                System.Console.Out.WriteLine("BAD CLASS: " + type.FullName);
            }

            return(hash);
        }
Esempio n. 10
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 override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            long  l = 0;
            sbyte b;
            bool  firstByte = true;

            do
            {
                b = (sbyte)in_Renamed.ReadByte();

                if (firstByte)
                {
                    firstByte = false;
                    l         = (((b >> 6) & 0x01) == 0 ? 0 : -1); //set initial sign
                }

                l = (l << 7) | (b & 0x7f);
            }while (((b >> 7) & 0x01) == 1);

            val = (long)l;
        }
Esempio n. 11
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 override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     if (!sealed_Renamed)
     {
         long size = ExtUtil.readNumeric(in_Renamed);
         System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(0));
         for (int i = 0; i < size; i++)
         {
             v.Add(ExtUtil.read(in_Renamed, type, pf));
         }
         val = v;
     }
     else
     {
         int             size   = (int)ExtUtil.readNumeric(in_Renamed);
         System.Object[] theval = new System.Object[size];
         for (int i = 0; i < size; i++)
         {
             theval[i] = ExtUtil.read(in_Renamed, type, pf);
         }
         val = theval;
     }
 }
Esempio n. 12
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 override void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            ExternalizableWrapper type = readTag(in_Renamed, pf);

            val = ExtUtil.read(in_Renamed, type, pf);
        }
Esempio n. 13
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 override void  metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     ordered = ExtUtil.readBool(in_Renamed);
     keyType = ExtWrapTagged.readTag(in_Renamed, pf);
 }
Esempio n. 14
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 override void metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     //do nothing
 }
Esempio n. 15
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 override void  metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     bias = in_Renamed.ReadByte();
 }
Esempio n. 16
0
 public static System.Object deserialize(sbyte[] data, System.Type type, PrototypeFactory pf)
 {
     return(read(new System.IO.BinaryReader(new System.IO.MemoryStream(SupportClass.ToByteArray(data))), type, pf));
 }
Esempio n. 17
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, ExternalizableWrapper ew, PrototypeFactory pf)
 {
     ew.readExternal(in_Renamed, pf == null?defaultPrototypes():pf);
     return(ew.val);
 }
Esempio n. 18
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 override void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     val = ExtUtil.read(in_Renamed, type, pf);
 }
Esempio n. 19
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 override void  metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     throw new System.SystemException("Tagged wrapper should never be tagged");
 }
Esempio n. 20
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 override void metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     type = ExtWrapTagged.readTag(in_Renamed, pf);
 }
Esempio n. 21
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 abstract void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf);
Esempio n. 22
0
 public static Object read(BinaryReader in_r, ExternalizableWrapper ew, PrototypeFactory pf)
 {
     ew.readExternal(in_r, pf == null ? defaultPrototypes() : pf);
     return(ew.val);
 }