コード例 #1
0
ファイル: ExtWrapTagged.cs プロジェクト: ryanbehr/csrosa
        //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));
            }
        }
コード例 #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 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));
            }
        }
コード例 #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 metaReadExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
 {
     type     = ExtUtil.readInt(in_Renamed);
     keyType  = ExtWrapTagged.readTag(in_Renamed, pf);
     dataType = ExtWrapTagged.readTag(in_Renamed, pf);
 }