Example #1
0
        /// <summary>
        /// Reads an object of type <see cref="object"/> from the current stream
        /// and advances the stream position.
        /// </summary>
        /// <returns>object read from the stream</returns>
        public override object ReadObject()
        {
            // read type handle
            short handle = reader.ReadInt16();
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, context.CacheContext);


            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), context.CacheContext);
            }

            //If surrogate not found defaultSurrogate is returned
            //if (surrogate == null) throw new CompactSerializationException("Type handle " + handle + " is not registered with Compact Serialization Framework");

            object obj = null;

            try
            {
                obj = surrogate.Read(this);
            }
            catch (CompactSerializationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new CompactSerializationException(e.Message, e);
            }

            return(obj);
        }
Example #2
0
        /// <summary>
        /// Deserializes an object from the specified compact binary writer.
        /// </summary>
        /// <param name="reader">Stream containing reader</param>
        /// <param name="cacheContext">Name of the cache</param>
        /// <param name="skip">True to skip the bytes returning null</param>
        static internal object Deserialize(CompactBinaryReader reader, string cacheContext, bool skip)
        {
            // read type handle
            short handle = reader.ReadInt16();

            reader.Context.CacheContext = cacheContext;
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, cacheContext);

            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), cacheContext);
            }

            if (surrogate == null)
            {
                throw new CompactSerializationException("Type handle " + handle + "is not registered with Compact Serialization Framework");
            }
            if (!skip)
            {
                return(surrogate.Read(reader));
            }
            else
            {
                surrogate.Skip(reader);
                return(null);
            }
        }
Example #3
0
        public override void Skip(CompactBinaryReader reader)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            decimalSurrogate.Skip(reader);
            decimalSurrogate.Skip(reader);
        }
        public override void WriteDirect(CompactBinaryWriter writer, object graph)
        {
            object[] array = (object[])graph;
            writer.Write(array.Length);

            if (!typeof(object[]).Equals(graph.GetType()))
            {
                object obj = null;
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] != null)
                    {
                        obj = array[i];
                        break;
                    }
                }
                ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForObject(obj, writer.CacheContext);
                writer.Write(surrogate.TypeHandle);
                if (surrogate.SubTypeHandle > 0)
                {
                    writer.Write(surrogate.SubTypeHandle);
                }
            }
            else
            {
                ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForObject(new object(), writer.CacheContext);
                writer.Write(surrogate.TypeHandle);
            }

            for (int i = 0; i < array.Length; i++)
            {
                writer.WriteObject(array[i]);
            }
        }
        /// <summary>
        /// Reads an object of type <see cref="object"/> from the current stream
        /// and advances the stream position.
        /// </summary>
        /// <returns>object read from the stream</returns>
        public override object ReadObject()
        {
            // read type handle
            short handle = reader.ReadInt16();
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, context.CacheContext);

            object obj = null;

            try
            {
                obj = surrogate.Read(this);
            }
            catch (CompactSerializationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new CompactSerializationException(e.Message, e);
            }

            return(obj);
        }
Example #6
0
 /// <summary>
 /// Registra os tipos compactos.
 /// </summary>
 public static void RegisterCompactTypes()
 {
     TypeSurrogateSelector.RegisterTypeSurrogate(new ArraySerializationSurrogate(typeof(CacheEntry[])));
     TypeSurrogateSelector.RegisterTypeSurrogate(new ArraySerializationSurrogate(typeof(WriteBehindAsyncProcessor.IWriteBehindTask[])));
     TypeSurrogateSelector.RegisterTypeSurrogate(new CustomArraySerializationSurrogate(typeof(CustomArraySerializationSurrogate)));
     CompactFormatterServices.RegisterCompactType(typeof(CacheEntry), 0x3d);
     CompactFormatterServices.RegisterCompactType(typeof(CounterHint), 0x3e);
     CompactFormatterServices.RegisterCompactType(typeof(TimestampHint), 0x3f);
     CompactFormatterServices.RegisterCompactType(typeof(PriorityEvictionHint), 0x40);
     CompactFormatterServices.RegisterCompactType(typeof(AggregateExpirationHint), 0x44);
     CompactFormatterServices.RegisterCompactType(typeof(IdleExpiration), 0x45);
     CompactFormatterServices.RegisterCompactType(typeof(LockExpiration), 0x87);
     CompactFormatterServices.RegisterCompactType(typeof(FixedExpiration), 70);
     CompactFormatterServices.RegisterCompactType(typeof(KeyDependency), 0x47);
     CompactFormatterServices.RegisterCompactType(typeof(FixedIdleExpiration), 0x48);
     CompactFormatterServices.RegisterCompactType(typeof(DependencyHint), 0x49);
     CompactFormatterServices.RegisterCompactType(typeof(CompactCacheEntry), 0x69);
     CompactFormatterServices.RegisterCompactType(typeof(CallbackEntry), 0x6b);
     CompactFormatterServices.RegisterCompactType(typeof(CallbackInfo), 0x6f);
     CompactFormatterServices.RegisterCompactType(typeof(AsyncCallbackInfo), 0x70);
     CompactFormatterServices.RegisterCompactType(typeof(Colosoft.Caching.Synchronization.CacheSyncDependency), 0x71);
     CompactFormatterServices.RegisterCompactType(typeof(CacheInsResultWithEntry), 0x76);
     CompactFormatterServices.RegisterCompactType(typeof(ExtensibleDependency), 0x77);
     CompactFormatterServices.RegisterCompactType(typeof(WriteThruProviderManager.WriteBehindTask), 120);
     CompactFormatterServices.RegisterCompactType(typeof(WriteThruProviderManager.BulkWriteBehindTask), 0x79);
     CompactFormatterServices.RegisterCompactType(typeof(UserBinaryObject), 0x7d);
 }
        /// <summary>
        /// Skips an object of type <see cref="object"/> from the current stream
        /// and advances the stream position.
        /// </summary>
        public override void SkipObject()
        {
            // read type handle
            short handle = reader.ReadInt16();
            // Find an appropriate surrogate by handle
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, context.CacheContext);

            if (surrogate == null)
            {
                surrogate = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), context.CacheContext);
            }


            try
            {
                surrogate.Skip(this);
            }
            catch (CompactSerializationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new CompactSerializationException(e.Message);
            }
        }
 public STDFRecordFormatter()
 {
     // Add default provider
     TypeSurrogateSelector.AddSurrogate(typeof(ATR), new ATRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(BPS), new BPSSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(DTR), new DTRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(EPS), new EPSSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(FAR), new FARSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(FTR), new FTRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(GDR), new GDRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(HBR), new HBRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(MIR), new MIRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(MPR), new MPRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(MRR), new MRRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PCR), new PCRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PGR), new PGRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PIR), new PIRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PLR), new PLRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PMR), new PMRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PRR), new PRRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(PTR), new PTRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(RDR), new RDRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(SBR), new SBRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(SDR), new SDRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(TSR), new TSRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(WCR), new WCRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(WIR), new WIRSurrogate());
     TypeSurrogateSelector.AddSurrogate(typeof(WRR), new WRRSurrogate());
 }
Example #9
0
        public override void Skip(CompactBinaryReader reader)
        {
            // read type handle
            short handle = reader.ReadInt16();

            // Find an appropriate surrogate by handle
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, null);

            if (typeSurr == null)
            {
                typeSurr = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), reader.Context.CacheContext);
            }

            int length = reader.ReadInt32();

            T?[] array = new T?[length];
            while (true)
            {
                int index = reader.ReadInt32();
                if (index < 0)
                {
                    break;
                }

                typeSurr.Skip(reader);
            }
        }
Example #10
0
        /// <summary>
        /// Serializa a instancia no escritor.
        /// </summary>
        /// <param name="writer">Escritor onde os dados serão salvos.</param>
        /// <param name="graph">Instancia que será serializada.</param>
        /// <param name="cacheContext"></param>
        internal static void Serialize(CompactBinaryWriter writer, object graph, string cacheContext)
        {
            var surrogateForObject = TypeSurrogateSelector.GetSurrogateForObject(graph, cacheContext);

            writer.Context.CacheContext = cacheContext;
            writer.Write(surrogateForObject.TypeHandle);
            surrogateForObject.Write(writer, graph);
        }
Example #11
0
        public override T ReadObjectAs <T>()
        {
            // Find an appropriate surrogate by type
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForType(typeof(T), context.CacheContext);

            return((T)surrogate.Read(this));
        }
        public override void Write(CompactBinaryWriter writer, object graph)
        {
            Type enumType = Enum.GetUnderlyingType(ActualType);
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForType(enumType, writer.Context.CacheContext);

            writer.Write(typeSurr.TypeHandle);
            typeSurr.Write(writer, graph);
        }
Example #13
0
        public override void Skip(CompactBinaryReader reader)
        {
            // Find an appropriate surrogate by handle
            short handle = reader.ReadInt16();
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);

            typeSurr.Skip(reader);
        }
Example #14
0
        public override void SkipObjectAs <T>()
        {
            // Find an appropriate surrogate by type
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForType(typeof(T), context.CacheContext);

            surrogate.Skip(this);
        }
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="graph"></param>
 public override void WriteObjectAs <T>(T graph)
 {
     if (graph == null)
     {
         throw new ArgumentNullException("graph");
     }
     TypeSurrogateSelector.GetSurrogateForType(typeof(T), _context.CacheContext).Write(this, graph);
 }
Example #16
0
        public override object Read(CompactBinaryReader reader)
        {
            // Find an appropriate surrogate by handle
            short handle = reader.ReadInt16();
            ISerializationSurrogate typeSurr = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);

            return(Enum.ToObject(ActualType, typeSurr.Read(reader)));
        }
 /// <summary>
 /// Escreve o objeto do tipo informado.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="graph"></param>
 public override void WriteObjectAs(Type type, object graph)
 {
     type.Require("type").NotNull();
     if (graph == null)
     {
         throw new ArgumentNullException("graph");
     }
     TypeSurrogateSelector.GetSurrogateForType(type, _context.CacheContext).Write(this, graph);
 }
Example #18
0
        public override void Write(CompactBinaryWriter writer, object graph)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            AverageResult result = (AverageResult)graph;

            decimalSurrogate.Write(writer, result.Sum);
            decimalSurrogate.Write(writer, result.Count);
        }
        /// <summary>
        /// Reads data from an STDF data stream and deserializes it into the corresponding STDF record type.
        /// </summary>
        /// <param name="stream">Stream object to read the record data from.</param>
        /// <returns></returns>
        public override object Deserialize(Stream stream)
        {
            SerializeStream = stream;
            EndOfStream     = SerializeStream.Position >= SerializeStream.Length;
            if (EndOfStream)
            {
                return(null);
            }
            ReadHeader(out ushort recordLength, out ushort recordTypeCode);
            if (SerializeStream.Position + recordLength > SerializeStream.Length)
            {
                throw new EndOfStreamException("Unexpected end of record during serialization.");
            }
            Type       recordType          = STDFFormatterServices.ConvertTypeCode(recordTypeCode);
            ISurrogate serializerSurrogate = TypeSurrogateSelector.GetSurrogate(recordType);

            if (serializerSurrogate == null)
            {
                // no surrogate to deserialize this type.  Skip to next record and return
                SerializeStream.Seek(recordLength, SeekOrigin.Current);
                //Console.WriteLine("Skipping record type " + recordType.Name);
                return(null);
            }
            ISTDFRecord record = (ISTDFRecord)STDFFormatterServices.GetUninitializedObject(recordType);

            record.RecordLength = recordLength;
            SerializationInfo info = SerializationInfo.Create(recordType, Converter);
            long startPosition     = SerializeStream.Position;

            foreach (SerializationInfoEntry field in info)
            {
                EndOfRecord = (SerializeStream.Position - startPosition) >= recordLength;
                if (EndOfRecord)
                {
                    // If end of record reached yet we still have more fields to serialize, then we can skip the rest of the record.
                    break;
                }
                if (field.ItemCountIndex >= 0)
                {
                    // Field has an item count property, so we are deserializing an array.
                    // Get the number of items to deserialize from the value that was deserialized earlier.
                    int itemCount = info.GetValue <int>((int)field.ItemCountIndex);
                    if (itemCount > 0)
                    {
                        info.SetValue(field.Index, ReadArray(field.Type.GetElementType(), itemCount));
                    }
                }
                else
                {
                    info.SetValue(field.Index, Read(field.Type));
                }
            }
            EndOfStream = SerializeStream.Position >= SerializeStream.Length;
            // Set the fields on the record
            serializerSurrogate.SetObjectData(record, info);
            return(record);
        }
 /// <summary>
 /// Lê um objeto do tipo informado.
 /// </summary>
 /// <param name="type">Tipo que será deserializado.</param>
 /// <returns></returns>
 public override object ReadObjectAs(Type type)
 {
     if (typeof(ICompactSerializable).IsAssignableFrom(type))
     {
         ICompactSerializable graph = Activator.CreateInstance(type) as ICompactSerializable;
         graph.Deserialize(this);
         return(graph);
     }
     return(TypeSurrogateSelector.GetSurrogateForType(type, _context.CacheContext).Read(this));
 }
Example #21
0
        public override object Read(CompactBinaryReader reader)
        {
            ISerializationSurrogate decimalSurrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(decimal), null);

            AverageResult result = new AverageResult();

            result.Sum   = (decimal)decimalSurrogate.Read(reader);
            result.Count = (decimal)decimalSurrogate.Read(reader);
            return(result);
        }
Example #22
0
        public override void SkipDirect(CompactBinaryReader reader, object graph)
        {
            object[] array  = (object[])graph;
            short    handle = reader.ReadInt16();
            ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.CacheContext);

            for (int i = 0; i < array.Length; i++)
            {
                reader.SkipObject();
            }
        }
        public override object Read(CompactBinaryReader reader)
        {
            short handle = reader.ReadInt16();
            var   surrogateForTypeHandle = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);

            if (surrogateForTypeHandle == null)
            {
                surrogateForTypeHandle = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), reader.Context.CacheContext);
            }
            return(Enum.ToObject(base.ActualType, surrogateForTypeHandle.Read(reader)));
        }
        public override void Skip(CompactBinaryReader reader)
        {
            short handle = reader.ReadInt16();
            var   surrogateForTypeHandle = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.Context.CacheContext);

            if (surrogateForTypeHandle == null)
            {
                surrogateForTypeHandle = TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), reader.Context.CacheContext);
            }
            surrogateForTypeHandle.Skip(reader);
        }
Example #25
0
        /// <summary>
        /// Serializes an object into the specified compact binary writer.
        /// </summary>
        /// <param name="writer">specified compact binary writer</param>
        /// <param name="graph">object</param>
        static internal void Serialize(CompactBinaryWriter writer, object graph, string cacheContext)
        {
            // Find an appropriate surrogate for the object
            ISerializationSurrogate surrogate =
                TypeSurrogateSelector.GetSurrogateForObject(graph, cacheContext);

            // write type handle
            writer.Context.CacheContext = cacheContext;
            writer.Write(surrogate.TypeHandle);
            surrogate.Write(writer, graph);
        }
Example #26
0
        public override void WriteObjectAs <T>(T graph)
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }

            // Find an appropriate surrogate for the object
            ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForType(typeof(T), context.CacheContext);

            surrogate.Write(this, graph);
        }
        private static void EmitPortableWriteInstruction(FieldInfo field, ILGenerator il)
        {
            MethodInfo meth = null;

            if (field != null)
            {
                Type fieldType = field.FieldType;
                il.Emit(OpCodes.Ldfld, field);
                if (fieldType.IsPrimitive)
                {
                    ISerializationSurrogate surrogateForType = TypeSurrogateSelector.GetSurrogateForType(fieldType, null);
                    il.Emit(OpCodes.Ldarg_0);
                    il.Emit(OpCodes.Ldc_I4, (int)surrogateForType.TypeHandle);
                    il.Emit(OpCodes.Conv_I2);
                    MethodInfo method = typeof(CompactBinaryWriter).GetMethod("Write", new Type[] {
                        typeof(short)
                    });
                    if (method != null)
                    {
                        il.Emit(OpCodes.Callvirt, method);
                    }
                    meth = typeof(CompactBinaryWriter).GetMethod("Write", new Type[] {
                        fieldType
                    });
                    if (meth != null)
                    {
                        il.Emit(OpCodes.Callvirt, meth);
                    }
                }
                if (meth == null)
                {
                    if (fieldType.IsValueType)
                    {
                        il.Emit(OpCodes.Box, fieldType);
                    }
                    if (fieldType.IsInterface || !fieldType.IsPrimitive)
                    {
                        il.Emit(OpCodes.Callvirt, _compactBinaryWriterWriteObject);
                    }
                    else
                    {
                        il.Emit(OpCodes.Ldtoken, fieldType);
                        il.Emit(OpCodes.Call, _type_GetTypeFromHandle);
                        il.Emit(OpCodes.Callvirt, _compactBinaryWriterWriteObjectAs);
                    }
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #28
0
        /// <summary>
        /// Salta os dados do leitor.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="graph"></param>
        public override void SkipDirect(CompactBinaryReader reader, object graph)
        {
            object[] objArray = (object[])graph;
            short    handle   = reader.ReadInt16();

            if (TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.CacheContext) == null)
            {
                TypeSurrogateSelector.GetSurrogateForSubTypeHandle(handle, reader.ReadInt16(), reader.Context.CacheContext);
            }
            for (int i = 0; i < objArray.Length; i++)
            {
                reader.SkipObject();
            }
        }
Example #29
0
        /// <summary>
        /// Registers types with the Compact Serializatin Framework. Range of reserved
        /// typeHandle is (61 - 1000). 
        /// </summary>
        public static void RegisterCompactTypes()
        {
            TypeSurrogateSelector.RegisterTypeSurrogate(new ArraySerializationSurrogate(typeof(CacheEntry[])));
            TypeSurrogateSelector.RegisterTypeSurrogate(new CustomArraySerializationSurrogate(typeof(CustomArraySerializationSurrogate)));
            CompactFormatterServices.RegisterCompactType(typeof(CacheEntry), 61);
            CompactFormatterServices.RegisterCompactType(typeof(PriorityEvictionHint), 64);
            CompactFormatterServices.RegisterCompactType(typeof(CacheStatistics), 65);
            CompactFormatterServices.RegisterCompactType(typeof(ClusterCacheStatistics), 66);
            CompactFormatterServices.RegisterCompactType(typeof(NodeInfo), 67);
            CompactFormatterServices.RegisterCompactType(typeof(IdleExpiration), 69);
            CompactFormatterServices.RegisterCompactType(typeof(LockExpiration), 135);
            CompactFormatterServices.RegisterCompactType(typeof(FixedExpiration), 70);
            CompactFormatterServices.RegisterCompactType(typeof(CompactCacheEntry), 105);
            CompactFormatterServices.RegisterCompactType(typeof(CallbackEntry), 107);
            CompactFormatterServices.RegisterCompactType(typeof(CallbackInfo), 111);
            CompactFormatterServices.RegisterCompactType(typeof(AsyncCallbackInfo), 112);
            CompactFormatterServices.RegisterCompactType(typeof(BucketStatistics), 117);
            CompactFormatterServices.RegisterCompactType(typeof(CacheInsResultWithEntry), 118);
            CompactFormatterServices.RegisterCompactType(typeof(UserBinaryObject), 125);

            CompactFormatterServices.RegisterCompactType(typeof(VirtualArray), 149);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.Locking.LockManager), 150);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataStructures.DistributionMaps), 160);
            CompactFormatterServices.RegisterCompactType(typeof(EventCacheEntry), 262);
            CompactFormatterServices.RegisterCompactType(typeof(EventContext), 263);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.AutoExpiration.LockMetaInfo), 264);

            CompactFormatterServices.RegisterCompactType(typeof(Function), 75);
            CompactFormatterServices.RegisterCompactType(typeof(AggregateFunction), 76);
            CompactFormatterServices.RegisterCompactType(typeof(PartitionedCacheBase.Identity), 77);
            CompactFormatterServices.RegisterCompactType(typeof(ReplicatedCacheBase.Identity), 78);
            CompactFormatterServices.RegisterCompactType(typeof(StateTxfrInfo), 116);
            CompactFormatterServices.RegisterCompactType(typeof(CompressedValueEntry), 133);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.Queries.QueryResultSet), 151);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationContext), 153);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationContext[]), 345);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.EventContext[]), 346);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.OperationID), 163);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Caching.NCacheSessionItem), 129);

            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.ReaderResultSet), 333);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.RecordSet), 334);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.ColumnCollection), 335);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.RowCollection), 336);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.SubsetInfo), 337);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.RecordRow), 338);
            CompactFormatterServices.RegisterCompactType(typeof(Alachisoft.NCache.Common.DataReader.RecordColumn), 339);
        }
Example #30
0
        public override object ReadDirect(CompactBinaryReader reader, object graph)
        {
            object[] array = (object[])graph;

            short handle = reader.ReadInt16();
            ISerializationSurrogate surrogate = TypeSurrogateSelector.GetSurrogateForTypeHandle(handle, reader.CacheContext);

            Object obj = Array.CreateInstance(surrogate.ActualType, array.Length);

            for (int i = 0; i < array.Length; i++)
            {
                ((Array)obj).SetValue(reader.ReadObject(), i);
            }
            //array[i] = reader.ReadObject();

            return(obj);
        }