Example #1
0
        public byte[] Energize(AbstractReferenceObject o)
        {
            int index = 0;

            Energize(o, bytes, ref index, true);
            byte[] result = this.instantiator.AcquireByteArray(index);
            Buffer.BlockCopy(bytes, 0, result, 0, index);
            return(result);
        }
Example #2
0
 public void Reclaim(AbstractReferenceObject o)
 {
     if (o != null)
     {
         if (o.Thing != null)
         {
             this.Reclaim(o.Thing);
         }
         o.Thing = default(AbstractThing);
         this.instantiator.DiscardAbstractReferenceObject(o);
     }
 }
Example #3
0
        public void Energize(AbstractReferenceObject o, byte[] bytes, ref int index, bool writeTypeId)
        {
            if (writeTypeId)
            {
                bytes[index++] = 24;
            }
            // NULL FLAGS
            int nullFlagsIndex = index - 1;

            bytes[index++] = 0;
            nullFlagsIndex++;
            // REFERENCE: Thing
            if (o.Thing != null)
            {
                bytes[nullFlagsIndex] |= (byte)(128);
                Energize((IReferenceTestObject)o.Thing, bytes, ref index, true);
            }
        }
 public void DiscardAbstractReferenceObject(AbstractReferenceObject o)
 {
     // Dispose?
 }
Example #5
0
        public object Energize(byte[] bytes, ref int index, ushort typeId)
        {
            switch (typeId)
            {
            case 11:
            {
                Thing o = this.instantiator.AcquireThing();
                // PRIMITIVE: IntValue
                o.IntValue =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 12:
            {
                // NULL FLAGS
                int nullFlagsIndex = index - 1;
                index += 1;
                FinalObject o = this.instantiator.AcquireFinalObject();
                nullFlagsIndex++;
                // REFERENCE: ThingValue
                if ((bytes[nullFlagsIndex] & (byte)128) > 0)
                {
                    o.ThingValue = (Thing)Energize(bytes, ref index, 11);
                }
                return(o);
            }

            case 22:
            {
                FinalThing1 o = this.instantiator.AcquireFinalThing1();
                // PRIMITIVE: IntValue1
                o.IntValue1 =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                // PRIMITIVE: IntValue2a
                o.IntValue2a =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 23:
            {
                FinalThing2 o = this.instantiator.AcquireFinalThing2();
                // PRIMITIVE: IntValue1
                o.IntValue1 =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                // PRIMITIVE: IntValue2a
                o.IntValue2a =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 24:
            {
                // NULL FLAGS
                int nullFlagsIndex = index - 1;
                index += 1;
                AbstractReferenceObject o = this.instantiator.AcquireAbstractReferenceObject();
                nullFlagsIndex++;
                // REFERENCE: Thing
                if ((bytes[nullFlagsIndex] & (byte)128) > 0)
                {
                    o.Thing = (AbstractThing)Energize(bytes, ref index);
                }
                return(o);
            }

            default:
                throw new ReferenceTestPatternBufferException("Unrecognized type ID: " + typeId + " ");
            }
        }
Example #6
0
        public object Energize(byte[] bytes, ref int index)
        {
            ulong vuread_e2gF4LLKmgmj = 0;

            for (int i_bUcUI05wA86c = 0; i_bUcUI05wA86c < 9; i_bUcUI05wA86c++)
            {
                byte b = bytes[index++];
                if (i_bUcUI05wA86c < 8)
                {
                    vuread_e2gF4LLKmgmj += (((ulong)b & (ulong)127) << (7 * i_bUcUI05wA86c));
                    if ((int)(b & 128) == 0)
                    {
                        break;
                    }
                }
                else
                {
                    vuread_e2gF4LLKmgmj += (ulong)b << (7 * i_bUcUI05wA86c);
                    break;
                }
            }
            ushort typeId = (ushort)vuread_e2gF4LLKmgmj;

            switch (typeId)
            {
            case 11:
            {
                Thing o = this.instantiator.AcquireThing();
                // PRIMITIVE: IntValue
                o.IntValue =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 12:
            {
                // NULL FLAGS
                int nullFlagsIndex = index - 1;
                index += 1;
                FinalObject o = this.instantiator.AcquireFinalObject();
                nullFlagsIndex++;
                // REFERENCE: ThingValue
                if ((bytes[nullFlagsIndex] & (byte)128) > 0)
                {
                    o.ThingValue = (Thing)Energize(bytes, ref index, 11);
                }
                return(o);
            }

            case 22:
            {
                FinalThing1 o = this.instantiator.AcquireFinalThing1();
                // PRIMITIVE: IntValue1
                o.IntValue1 =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                // PRIMITIVE: IntValue2a
                o.IntValue2a =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 23:
            {
                FinalThing2 o = this.instantiator.AcquireFinalThing2();
                // PRIMITIVE: IntValue1
                o.IntValue1 =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                // PRIMITIVE: IntValue2a
                o.IntValue2a =
                    (int)(
                        ((int)bytes[index++] << 24) |
                        ((int)bytes[index++] << 16) |
                        ((int)bytes[index++] << 8) |
                        (int)bytes[index++]
                        );
                return(o);
            }

            case 24:
            {
                // NULL FLAGS
                int nullFlagsIndex = index - 1;
                index += 1;
                AbstractReferenceObject o = this.instantiator.AcquireAbstractReferenceObject();
                nullFlagsIndex++;
                // REFERENCE: Thing
                if ((bytes[nullFlagsIndex] & (byte)128) > 0)
                {
                    o.Thing = (AbstractThing)Energize(bytes, ref index);
                }
                return(o);
            }

            default:
                throw new ReferenceTestPatternBufferException("Unrecognized type ID: " + typeId + " ");
            }
        }