当前位置: 首页>>代码示例>>C#>>正文


C# Marshaller.StartUnmarshal方法代码示例

本文整理汇总了C#中Marshaller.StartUnmarshal方法的典型用法代码示例。如果您正苦于以下问题:C# Marshaller.StartUnmarshal方法的具体用法?C# Marshaller.StartUnmarshal怎么用?C# Marshaller.StartUnmarshal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Marshaller的用法示例。


在下文中一共展示了Marshaller.StartUnmarshal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadProxyMethod

        /// <summary>
        /// Reads proxy method invocation data from the specified reader.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="mthdName">Method name.</param>
        /// <param name="mthdArgs">Method arguments.</param>
        public static void ReadProxyMethod(IBinaryStream stream, Marshaller marsh, 
            out string mthdName, out object[] mthdArgs)
        {
            var reader = marsh.StartUnmarshal(stream);

            var srvKeepBinary = reader.ReadBoolean();

            mthdName = reader.ReadString();

            if (reader.ReadBoolean())
            {
                mthdArgs = new object[reader.ReadInt()];

                if (srvKeepBinary)
                    reader = marsh.StartUnmarshal(stream, true);

                for (var i = 0; i < mthdArgs.Length; i++)
                    mthdArgs[i] = reader.ReadObject<object>();
            }
            else
                mthdArgs = null;
        }
开发者ID:dheep-purdessy,项目名称:ignite,代码行数:29,代码来源:ServiceProxySerializer.cs

示例2: TransactionsImpl

        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionsImpl" /> class.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="localNodeId">Local node id.</param>
        public TransactionsImpl(IUnmanagedTarget target, Marshaller marsh,
            Guid localNodeId) : base(target, marsh)
        {
            _localNodeId = localNodeId;

            TransactionConcurrency concurrency = default(TransactionConcurrency);
            TransactionIsolation isolation = default(TransactionIsolation);
            TimeSpan timeout = default(TimeSpan);

            DoInOp(OpCacheConfigParameters, stream =>
            {
                var reader = marsh.StartUnmarshal(stream).GetRawReader();

                concurrency = (TransactionConcurrency) reader.ReadInt();
                isolation = (TransactionIsolation) reader.ReadInt();
                timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
            });

            _dfltConcurrency = concurrency;
            _dfltIsolation = isolation;
            _dfltTimeout = timeout;
        }
开发者ID:dheep-purdessy,项目名称:ignite,代码行数:28,代码来源:TransactionsImpl.cs

示例3: ReadInvocationResult

        /// <summary>
        /// Reads method invocation result.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="keepBinary">Binary flag.</param>
        /// <returns>
        /// Method invocation result, or exception in case of error.
        /// </returns>
        public static object ReadInvocationResult(IBinaryStream stream, Marshaller marsh, bool keepBinary)
        {
            Debug.Assert(stream != null);
            Debug.Assert(marsh != null);

            var mode = keepBinary ? BinaryMode.ForceBinary : BinaryMode.Deserialize;

            var reader = marsh.StartUnmarshal(stream, mode);

            object err;

            var res = BinaryUtils.ReadInvocationResult(reader, out err);

            if (err == null)
                return res;

            var binErr = err as IBinaryObject;

            throw binErr != null
                ? new ServiceInvocationException("Proxy method invocation failed with a binary error. " +
                                                 "Examine BinaryCause for details.", binErr)
                : new ServiceInvocationException("Proxy method invocation failed with an exception. " +
                                                 "Examine InnerException for details.", (Exception) err);
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:33,代码来源:ServiceProxySerializer.cs

示例4: IgniteConfiguration

        /// <summary>
        /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
        /// </summary>
        /// <param name="configuration">The configuration to copy.</param>
        public IgniteConfiguration(IgniteConfiguration configuration)
        {
            IgniteArgumentCheck.NotNull(configuration, "configuration");

            CopyLocalProperties(configuration);

            using (var stream = IgniteManager.Memory.Allocate().GetStream())
            {
                var marsh = new Marshaller(configuration.BinaryConfiguration);

                configuration.Write(marsh.StartMarshal(stream));

                stream.SynchronizeOutput();

                stream.Seek(0, SeekOrigin.Begin);

                ReadCore(marsh.StartUnmarshal(stream));
            }
        }
开发者ID:vladisav,项目名称:ignite,代码行数:23,代码来源:IgniteConfiguration.cs

示例5: TestStructure

        public void TestStructure()
        {
            for (int i = 1; i <= RepeatCnt; i++)
            {
                Console.WriteLine(">>> Iteration started: " + i);

                // 1. Generate and shuffle objects.
                IList<BranchedType> objs = new List<BranchedType>();

                for (int j = 0; j < 6 * ObjectsPerMode; j++)
                    objs.Add(new BranchedType((j%6) + 1));

                objs = IgniteUtils.Shuffle(objs);

                // 2. Create new marshaller.
                BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));

                BinaryConfiguration cfg = new BinaryConfiguration
                {
                    TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
                };

                Marshaller marsh = new Marshaller(cfg);

                // 3. Marshal all data and ensure deserialized object is fine.
                // Use single stream to test object offsets
                using (var stream = new BinaryHeapStream(128))
                {
                    var writer = marsh.StartMarshal(stream);

                    foreach (var obj in objs)
                    {
                        Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');

                        writer.WriteObject(obj);

                    }

                    stream.Seek(0, SeekOrigin.Begin);

                    var reader = marsh.StartUnmarshal(stream);

                    foreach (var obj in objs)
                    {
                        var other = reader.ReadObject<BranchedType>();

                        Assert.IsTrue(obj.Equals(other));
                    }
                }

                Console.WriteLine();

                // 4. Ensure that all fields are recorded.
                var desc = marsh.GetDescriptor(typeof (BranchedType));

                CollectionAssert.AreEquivalent(new[] {"mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8"},
                    desc.WriterTypeStructure.FieldTypes.Keys);
            }
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:59,代码来源:BinaryStructureTest.cs

示例6: ReadPartitions

        /// <summary>
        /// Reads the partitions assignment from a stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="marsh">The marshaller.</param>
        /// <returns>Partitions assignment.</returns>
        internal static IEnumerable<IEnumerable<IClusterNode>> ReadPartitions(IBinaryStream stream, Marshaller marsh)
        {
            Debug.Assert(stream != null);
            Debug.Assert(marsh != null);

            var reader = marsh.StartUnmarshal(stream);

            var partCnt = reader.ReadInt();

            var res = new List<IEnumerable<IClusterNode>>(partCnt);

            for (var i = 0; i < partCnt; i++)
                res.Add(IgniteUtils.ReadNodes(reader));

            return res;
        }
开发者ID:juanavelez,项目名称:ignite,代码行数:22,代码来源:AffinityFunctionSerializer.cs


注:本文中的Marshaller.StartUnmarshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。