Exemplo n.º 1
0
        /// <summary>
        /// Write query arguments.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="args">Arguments.</param>
        internal static void WriteQueryArgs(PortableWriterImpl writer, object[] args)
        {
            if (args == null)
                writer.WriteInt(0);
            else
            {
                writer.WriteInt(args.Length);

                foreach (var arg in args)
                    writer.WriteObject(arg);
            }
        }
Exemplo n.º 2
0
        /** <inheritDoc /> */
        internal override void Write(PortableWriterImpl writer, bool keepPortable)
        {
            if (string.IsNullOrEmpty(Text))
                throw new ArgumentException("Text cannot be null or empty");

            if (string.IsNullOrEmpty(Type))
                throw new ArgumentException("Type cannot be null or empty");

            writer.WriteBoolean(Local);
            writer.WriteString(Text);
            writer.WriteString(Type);
            writer.WriteInt(PageSize);
        }
        /// <summary>
        /// Writes proxy method invocation data to the specified writer.
        /// </summary>
        /// <param name="writer">Writer.</param>
        /// <param name="method">Method.</param>
        /// <param name="arguments">Arguments.</param>
        public static void WriteProxyMethod(PortableWriterImpl writer, MethodBase method, object[] arguments)
        {
            Debug.Assert(writer != null);
            Debug.Assert(method != null);

            writer.WriteString(method.Name);

            if (arguments != null)
            {
                writer.WriteBoolean(true);
                writer.WriteInt(arguments.Length);

                foreach (var arg in arguments)
                    writer.WriteObject(arg);
            }
            else
                writer.WriteBoolean(false);
        }
        private void Marshal(PortableWriterImpl writer)
        {
            var pos = writer.Stream.Position;

            try
            {
                if (Error == null)
                {
                    writer.WriteByte((byte) Entry.State);

                    if (Entry.State == MutableCacheEntryState.ValueSet)
                        writer.Write(Entry.Value);

                    writer.Write(ProcessResult);
                }
                else
                {
                    writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
                    writer.Write(new PortableResultWrapper(Error));
                }
            }
            catch (Exception marshErr)
            {
                writer.Stream.Seek(pos, SeekOrigin.Begin);

                writer.WriteByte((byte) MutableCacheEntryState.ErrString);

                if (Error == null)
                {
                    writer.WriteString(string.Format(
                    "CacheEntryProcessor completed with error, but result serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
                else
                {
                    writer.WriteString(string.Format(
                    "CacheEntryProcessor completed with error, and error serialization failed [errType={0}, " +
                    "err={1}, serializationErrMsg={2}]", marshErr.GetType().Name, marshErr, marshErr.Message));
                }
            }
        }
        /// <summary>
        /// Writes the generic collection.
        /// </summary>
        public void WriteGeneric(PortableWriterImpl writer, object value)
        {
            Debug.Assert(writer != null);
            Debug.Assert(_writeFunc != null);

            _writeFunc(value, writer);
        }
Exemplo n.º 6
0
        /** <inheritDoc /> */
        internal override void Write(PortableWriterImpl writer, bool keepPortable)
        {
            if (string.IsNullOrEmpty(Sql))
                throw new ArgumentException("Sql cannot be null or empty");

            if (string.IsNullOrEmpty(Type))
                throw new ArgumentException("Type cannot be null or empty");

            // 2. Prepare.
            writer.WriteBoolean(Local);
            writer.WriteString(Sql);
            writer.WriteString(Type);
            writer.WriteInt(PageSize);

            WriteQueryArgs(writer, Arguments);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Writes this instance to a stream created with a specified delegate.
 /// </summary>
 /// <param name="writer">Writer.</param>
 /// <param name="keepPortable">Keep portable flag.</param>
 internal abstract void Write(PortableWriterImpl writer, bool keepPortable);
Exemplo n.º 8
0
        /// <summary>
        /// Writes the affinity info.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
        /// <param name="affinityKey">Affinity key.</param>
        private static void WriteAffinity(PortableWriterImpl writer, string cacheName, object affinityKey)
        {
            writer.WriteString(cacheName);

            writer.WriteObject(affinityKey);
        }