public void Deserialize(IPofReader reader)
            {
                keysPolymorphic   = reader.ReadBoolean(0);
                valuesPolymorphic = reader.ReadBoolean(1);
                var count = reader.ReadS32(2);
                var data  = reader.ReadBytes(3);

                var context    = reader.Context;
                var serializer = new PofSerializer(context);

                using (var elementStream = new MemoryStream(data))
                    using (var elementStreamReader = new BinaryReader(elementStream)) {
                        Func <TKey> readKey = keysPolymorphic ? new Func <TKey>(() => (TKey)serializer.Deserialize(elementStreamReader))
                                                    : new Func <TKey>(() => (TKey)serializer.Deserialize(elementStreamReader, SerializationFlags.Typeless, typeof(TKey)));
                        Func <TValue> readValue = valuesPolymorphic ? new Func <TValue>(() => (TValue)serializer.Deserialize(elementStreamReader))
                                                        : new Func <TValue>(() => (TValue)serializer.Deserialize(elementStreamReader, SerializationFlags.Typeless, typeof(TValue)));
                        var items = new Dictionary <TKey, TValue>(count);
                        for (var i = 0; i < count; i++)
                        {
                            var key   = readKey();
                            var value = readValue();
                            items.Add(key, value);
                        }
                        this.items = items;
                    }
            }
Esempio n. 2
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            if (m_dtdUri != null || m_dtdName != null || m_encoding != null || m_comment != null)
            {
                throw new Exception("deserialization not active");
            }

            base.ReadExternal(reader);

            if (reader.ReadBoolean(12))
            {
                m_dtdUri = reader.ReadString(13);
            }

            if (reader.ReadBoolean(14))
            {
                m_dtdName = reader.ReadString(15);
            }

            if (reader.ReadBoolean(16))
            {
                m_encoding = reader.ReadString(17);
            }

            if (reader.ReadBoolean(18))
            {
                m_comment = reader.ReadString(19);
            }
        }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.t.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">">
        /// If an I/O error occurs.
        /// </exception>
        /// <seealso cref="Request.ReadExternal"/>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            Add       = reader.ReadBoolean(1);
            Extractor = (IValueExtractor)reader.ReadObject(2);
            IsOrdered = reader.ReadBoolean(3);
            Comparer  = (IComparer)reader.ReadObject(4);
        }
Esempio n. 4
0
        /// <summary>
        /// Restore the contents of a user type instance by reading
        /// its state using the specified <see cref="IPofReader"/>
        /// object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's
        /// state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            if (reader.ReadBoolean(10)) /* redirect supported? */
            {
                IsRedirect = reader.ReadBoolean(11);
            }
        }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        /// <seealso cref="Request.ReadExternal"/>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            Add     = reader.ReadBoolean(2);
            IsLite  = reader.ReadBoolean(3);
            Trigger = (ICacheTrigger)reader.ReadObject(4);
            if (ImplVersion > 5)
            {
                IsPriming = reader.ReadBoolean(5);
            }
        }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public virtual void ReadExternal(IPofReader reader)
        {
            if (m_value != null || m_isAttribute || !m_isMutable)
            {
                throw new Exception("deserialization not active");
            }

            switch (reader.ReadByte(0))
            {
            case 0:
                break;

            case (byte)XmlValueType.Boolean:
                m_value = reader.ReadBoolean(1);
                break;

            case (byte)XmlValueType.Integer:
                m_value = reader.ReadInt32(1);
                break;

            case (byte)XmlValueType.Long:
                m_value = reader.ReadInt64(1);
                break;

            case (byte)XmlValueType.Double:
                m_value = reader.ReadDouble(1);
                break;

            case (byte)XmlValueType.Decimal:
                m_value = reader.ReadDecimal(1);
                break;

            case (byte)XmlValueType.String:
                m_value = reader.ReadString(1);
                break;

            case (byte)XmlValueType.Binary:
                m_value = reader.ReadBinary(1);
                break;

            case (byte)XmlValueType.DateTime:
                m_value = reader.ReadDateTime(1);
                break;

            default:
                throw new IOException();
            }

            m_isAttribute = reader.ReadBoolean(2);
            m_isMutable   = reader.ReadBoolean(3);
        }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            RequestId = reader.ReadInt64(0);
            IsFailure = reader.ReadBoolean(1);

            // determine which result format is being used
            ResultFormatType format = (ResultFormatType)reader.ReadInt32(2);

            ResultFormat = format;

            switch (format)
            {
            default:
            case ResultFormatType.Generic:
                Result = reader.ReadObject(3);
                break;

            case ResultFormatType.Collection:
                ICollection collection = reader.ReadCollection(4, null);
                Result = collection;
                break;

            case ResultFormatType.Map:
                IDictionary map = reader.ReadDictionary(5, new HashDictionary());
                Result = map;
                break;
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public override void ReadExternal(IPofReader reader)
 {
     m_fetchExtractor = reader.ReadBoolean(0);
     m_query          = reader.ReadString(1);
     m_env            = (object[])reader.ReadArray(2, null);
     m_bindings       = (IDictionary)reader.ReadDictionary(3, null);
 }
Esempio n. 9
0
 public void Deserialize(IPofReader reader)
 {
     MobileId      = reader.ReadS32(0);
     X             = reader.ReadS32(1);
     Y             = reader.ReadS32(2);
     IsStartOfGame = reader.ReadBoolean(3);
 }
Esempio n. 10
0
 public void Deserialize(IPofReader reader)
 {
     MobileId = reader.ReadS32(0);
      X = reader.ReadS32(1);
      Y = reader.ReadS32(2);
      IsStartOfGame = reader.ReadBoolean(3);
 }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public virtual void ReadExternal(IPofReader reader)
        {
            bool isSame = reader.ReadBoolean(0);

            m_extractorOld = (IValueExtractor)reader.ReadObject(1);
            m_extractorNew = isSame ? m_extractorOld : (IValueExtractor)reader.ReadObject(2);
        }
Esempio n. 12
0
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public virtual void ReadExternal(IPofReader reader)
 {
     IsParallel = reader.ReadBoolean(0);
     Extractor  = (IValueExtractor)reader.ReadObject(1);
     Comparer   = (IComparer)reader.ReadObject(2);
     Results    = reader.ReadInt32(3);
 }
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            m_ignoreCase = reader.ReadBoolean(2);
            m_escape     = reader.ReadChar(3);
        }
        public void Deserialize(IPofReader reader)
        {
            var version = reader.ReadS32(0);
             IsEnabled = reader.ReadBoolean(1);

             Trace.Assert(version == kVersion, "version == kVersion");
        }
        public void ReadExternal(IPofReader reader)
        {
            Assert.AreEqual(INTEGER, reader.ReadInt32(0));
            IPofReader nested1 = reader.CreateNestedPofReader(1);

            IPofReader nested2 = nested1.CreateNestedPofReader(0);

            Assert.AreEqual(STRING, nested2.ReadString(0));
            var person2 = (PortablePerson)nested2.ReadObject(1);

            double[] doubleArray = nested2.ReadDoubleArray(2);
            Assert.AreEqual(ArrayEqual(DOUBLE_ARRAY, doubleArray), true);

            IPofReader nested3     = nested2.CreateNestedPofReader(3);
            var        stringArray = (String[])nested3.ReadArray(0, new String[0]);

            Assert.IsTrue(ArrayEqual(stringArray, STRING_ARRAY));
            nested3.ReadRemainder();

            // close nested3 and continue to nested2
            bool boolVal = nested2.ReadBoolean(4);

            Assert.AreEqual(false, boolVal);

            // nested1
            ICollection          col     = nested1.ReadCollection(1, null);
            ICollection <String> results = new Collection <String>();

            foreach (object res in col)
            {
                results.Add((string)res);
            }
            foreach (String val in set)
            {
                Assert.IsTrue(results.Contains(val));
            }

            Assert.AreEqual(2.0, nested1.ReadDouble(2));
            Assert.AreEqual(5, nested1.ReadInt32(3));

            results = nested1.ReadCollection(4, results);
            foreach (String val in set)
            {
                Assert.IsTrue(results.Contains(val));
            }

            var person1 = (PortablePerson)nested1.ReadObject(5);

            Assert.AreEqual(2.222, nested1.ReadDouble(10));

            nested1.ReadRemainder();

            Assert.AreEqual(4.444, reader.ReadDouble(2));
            Assert.AreEqual(15, reader.ReadInt32(3));
            var person = (PortablePerson)reader.ReadObject(4);

            Assert.IsTrue(person == person1);
            Assert.IsTrue(person1 == person2);
        }
Esempio n. 16
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        /// <seealso cref="Request.ReadExternal"/>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            KeysOnly     = reader.ReadBoolean(2);
            Cookie       = reader.ReadBinary(3);
            FilterCookie = reader.ReadObject(4);
        }
Esempio n. 17
0
            public void Deserialize(IPofReader reader)
            {
                int i = 0;

                key       = reader.ReadObject <TKey>(i++);
                value     = reader.ReadObject <TValue>(i++);
                isPresent = reader.ReadBoolean(i++);
            }
        public void Deserialize(IPofReader reader)
        {
            var version = reader.ReadS32(0);

            IsEnabled = reader.ReadBoolean(1);

            Trace.Assert(version == kVersion, "version == kVersion");
        }
Esempio n. 19
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public virtual void ReadExternal(IPofReader reader)
        {
            m_filters = (IFilter[])reader.ReadArray(0, EMPTY_FILTER_ARRAY);

            // if we read an old version of the filter that didn't have this field,
            // it would result in maintaining the old behavior
            m_preserveOrder = reader.ReadBoolean(1);
        }
Esempio n. 20
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        /// <seealso cref="Request.ReadExternal"/>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            Value            = reader.ReadObject(2);
            ExpiryDelay      = reader.ReadInt64(3);
            IsReturnRequired = reader.ReadBoolean(4);
        }
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public void ReadExternal(IPofReader reader)
 {
     m_version     = reader.ReadInt64(VERSION);
     m_lockId      = reader.ReadInt64(LOCK_ID);
     m_lockTime    = reader.ReadDateTime(LOCK_TIME);
     m_initialized = reader.ReadBoolean(INITIALIZED);
     m_timeout     = TimeSpan.FromMilliseconds(reader.ReadInt64(TIMEOUT));
     m_binModel    = reader.ReadBinary(ITEMS);
 }
Esempio n. 22
0
        /// <summary>
        /// Restore the contents of a user type instance by reading
        /// its state using the specified <see cref="IPofReader"/>
        /// object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's
        /// state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            IsRedirect = reader.ReadBoolean(10);
            if (IsRedirect)
            {
                RedirectList = (IList)reader.ReadCollection(11, new ArrayList());
            }
        }
                /// <summary>
                /// Restore the contents of a user type instance by reading its state
                /// using the specified <see cref="IPofReader"/> object.
                /// </summary>
                /// <param name="reader">
                /// The <b>IPofReader</b> from which to read the object's state.
                /// </param>
                /// <exception cref="IOException">
                /// If an I/O error occurs.
                /// </exception>
                public virtual void ReadExternal(IPofReader reader)
                {
                    m_sExtractor = (string)reader.ReadObject(0);
                    m_sIndex     = (string)reader.ReadObject(1);
                    m_fOrdered   = reader.ReadBoolean(2);

                    if (m_sIndex != null)
                    {
                        ParseIndexDescription(m_sIndex);
                    }
                }
Esempio n. 24
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            EventType = (CacheEventType)reader.ReadInt32(0);
            int implVersion = ImplVersion;

            if (implVersion > 3)
            {
                FilterIds = reader.ReadInt64Array(1);
            }
            else
            {
                FilterId = reader.ReadInt64(1);
            }
            Key         = reader.ReadObject(2);
            ValueNew    = reader.ReadObject(3);
            ValueOld    = reader.ReadObject(4);
            IsSynthetic = reader.ReadBoolean(5);

            // COH-9355
            if (implVersion > 4)
            {
                TransformState = (CacheEventArgs.TransformationState)reader.ReadInt32(6);
            }

            // COH-13916
            if (implVersion > 5)
            {
                IsTruncate = reader.ReadBoolean(7);
            }

            // COH-18376
            if (implVersion > 6)
            {
                IsPriming = reader.ReadBoolean(8);
            }
        }
Esempio n. 25
0
            public void Deserialize(IPofReader reader)
            {
                isPolymorphic = reader.ReadBoolean(0);
                var length = reader.ReadS32(1);
                var data   = reader.ReadBytes(2);

                var context    = reader.Context;
                var serializer = new PofSerializer(context);

                using (var elementStream = new MemoryStream(data))
                    using (var elementStreamReader = new BinaryReader(elementStream)) {
                        Func <TElement> readElement = isPolymorphic ? new Func <TElement>(() => (TElement)serializer.Deserialize(elementStreamReader))
                                                          : new Func <TElement>(() => (TElement)serializer.Deserialize(elementStreamReader, SerializationFlags.Typeless, typeof(TElement)));
                        elements = Util.Generate(length, i => readElement());
                    }
            }
 public void Deserialize(IPofReader reader) {
    OverridingEnabled = reader.ReadBoolean(0);
 }
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public virtual void ReadExternal(IPofReader reader)
 {
     m_filter = (IFilter)reader.ReadObject(0);
     m_value  = reader.ReadObject(1);
     m_return = reader.ReadBoolean(2);
 }
Esempio n. 28
0
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public virtual void ReadExternal(IPofReader reader)
 {
     m_isParallel = reader.ReadBoolean(0);
     m_extractor  = (IValueExtractor)reader.ReadObject(1);
 }
Esempio n. 29
0
 public void Deserialize(IPofReader reader)
 {
     OverridingEnabled = reader.ReadBoolean(0);
 }
Esempio n. 30
0
        /// <summary>
        /// Restore the contents of a user type instance by reading its state
        /// using the specified <see cref="IPofReader"/> object.
        /// </summary>
        /// <param name="reader">
        /// The <b>IPofReader</b> from which to read the object's state.
        /// </param>
        /// <exception cref="IOException">
        /// If an I/O error occurs.
        /// </exception>
        /// <seealso cref="Request.ReadExternal"/>
        public override void ReadExternal(IPofReader reader)
        {
            base.ReadExternal(reader);

            IsTruncate = reader.ReadBoolean(1);
        }
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public virtual void ReadExternal(IPofReader reader)
 {
     m_name  = reader.ReadString(0);
     m_useIs = reader.ReadBoolean(1);
 }
 /// <summary>
 /// Restore the contents of a user type instance by reading its state
 /// using the specified <see cref="IPofReader"/> object.
 /// </summary>
 /// <param name="reader">
 /// The <b>IPofReader</b> from which to read the object's state.
 /// </param>
 /// <exception cref="IOException">
 /// If an I/O error occurs.
 /// </exception>
 public override void ReadExternal(IPofReader reader)
 {
     base.ReadExternal(reader);
     m_numInc  = reader.ReadObject(1);
     m_postInc = reader.ReadBoolean(2);
 }
Esempio n. 33
0
 public void Deserialize(IPofReader reader) {
    success = reader.ReadBoolean(0);
    accountId = reader.ReadS64(1);
    name = reader.ReadString(2);
 }