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


C# Marshaller类代码示例

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


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

示例1: AtomicSequence

        /// <summary>
        /// Initializes a new instance of the <see cref="Apache.Ignite.Core.Impl.DataStructures.AtomicLong"/> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="marsh">The marshaller.</param>
        /// <param name="name">The name.</param>
        public AtomicSequence(IUnmanagedTarget target, Marshaller marsh, string name)
            : base(target, marsh)
        {
            Debug.Assert(!string.IsNullOrEmpty(name));

            _name = name;
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:13,代码来源:AtomicSequence.cs

示例2: Init

 public void Init()
 {
     var marshaller = new Marshaller<string>(
         (str) =>
         {
             if (str == "UNSERIALIZABLE_VALUE")
             {
                 // Google.Protobuf throws exception inherited from IOException
                 throw new IOException("Error serializing the message.");
             }
             return System.Text.Encoding.UTF8.GetBytes(str); 
         },
         (payload) =>
         {
             var s = System.Text.Encoding.UTF8.GetString(payload);
             if (s == "UNPARSEABLE_VALUE")
             {
                 // Google.Protobuf throws exception inherited from IOException
                 throw new IOException("Error parsing the message.");
             }
             return s;
         });
     helper = new MockServiceHelper(Host, marshaller);
     server = helper.GetServer();
     server.Start();
     channel = helper.GetChannel();
 }
开发者ID:xianglinghui,项目名称:grpc,代码行数:27,代码来源:MarshallingErrorsTest.cs

示例3: NativeMethodOverload

        public NativeMethodOverload(ICollection<MethodInfo> methods , JsObject prototype, IGlobal global)
            : base(prototype)
        {
            if (global == null)
                throw new ArgumentNullException("global");
            m_marshaller = global.Marshaller;

            foreach (MethodInfo info in methods)
            {
                Name = info.Name;
                break;
            }

            foreach (var method in methods)
            {
                if (method.IsGenericMethodDefinition)
                    m_generics.AddLast(method);
                else if (! method.ContainsGenericParameters)
                    m_methods.AddLast(method);
            }

            m_overloads = new NativeOverloadImpl<MethodInfo, JsMethodImpl>(
                m_marshaller,
                new NativeOverloadImpl<MethodInfo, JsMethodImpl>.GetMembersDelegate(this.GetMembers),
                new NativeOverloadImpl<MethodInfo, JsMethodImpl>.WrapMmemberDelegate(this.WrapMember)
            );
        }
开发者ID:cosh,项目名称:Jint,代码行数:27,代码来源:NativeMethodOverload.cs

示例4: 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

示例5: ReadSchema

        /// <summary>
        /// Reads the schema according to this header data.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="position">The position.</param>
        /// <param name="hdr">The header.</param>
        /// <param name="schema">The schema.</param>
        /// <param name="marsh">The marshaller.</param>
        /// <returns>
        /// Schema.
        /// </returns>
        public static BinaryObjectSchemaField[] ReadSchema(IBinaryStream stream, int position, BinaryObjectHeader hdr, 
            BinaryObjectSchema schema, Marshaller marsh)
        {
            Debug.Assert(stream != null);
            Debug.Assert(schema != null);
            Debug.Assert(marsh != null);

            return ReadSchema(stream, position, hdr, () => GetFieldIds(hdr, schema, marsh));
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:20,代码来源:BinaryObjectSchemaSerializer.cs

示例6: MessageSender

        /// <summary>
        /// Creates a message sender.
        /// </summary>
        /// <param name="serverAddress">The address of server that messages will be send to.</param>
        public MessageSender(IPEndPoint serverAddress)
        {
            _servers = new List<ServerInfo>();
            _tcpClient = new TcpClient(serverAddress);

            var validator = new MessageValidator();
            var serializer = new MessageSerializer();
            _marshaller = new Marshaller(serializer, validator);
        }
开发者ID:progala2,项目名称:DVRP,代码行数:13,代码来源:MessageSender.cs

示例7: BinarizableWriteBenchmark

 /// <summary>
 /// Initializes a new instance of the <see cref="BinarizableWriteBenchmark"/> class.
 /// </summary>
 public BinarizableWriteBenchmark()
 {
     _marsh = new Marshaller(new BinaryConfiguration
     {
         TypeConfigurations = new List<BinaryTypeConfiguration>
         {
             new BinaryTypeConfiguration(typeof (Address))
             //new BinaryTypeConfiguration(typeof (TestModel))
         }
     });
 }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:14,代码来源:BinarizableWriteBenchmark.cs

示例8: CacheEntryFilterHolder

        /// <summary>
        /// Initializes a new instance of the <see cref="CacheEntryFilterHolder" /> class.
        /// </summary>
        /// <param name="pred">The <see cref="ICacheEntryFilter{TK,TV}" /> to wrap.</param>
        /// <param name="invoker">The invoker func that takes key and value and invokes wrapped ICacheEntryFilter.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="keepBinary">Keep binary flag.</param>
        public CacheEntryFilterHolder(object pred, Func<object, object, bool> invoker, Marshaller marsh, 
            bool keepBinary)
        {
            Debug.Assert(pred != null);
            Debug.Assert(invoker != null);
            Debug.Assert(marsh != null);

            _pred = pred;
            _invoker = invoker;
            _marsh = marsh;
            _keepBinary = keepBinary;
        }
开发者ID:juanavelez,项目名称:ignite,代码行数:19,代码来源:CacheEntryFilterHolder.cs

示例9: Write

        /// <summary>
        /// Writes this instance to the stream.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        public void Write(IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            try
            {
                Marshal(writer);
            }
            finally
            {
                marsh.FinishMarshal(writer);
            }
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:18,代码来源:CacheEntryProcessorResultHolder.cs

示例10: JsFunctionDelegate

 public JsFunctionDelegate(IJintVisitor visitor, JsFunction function, JsDictionaryObject that,Type delegateType)
 {
     if (visitor == null)
         throw new ArgumentNullException("visitor");
     if (function == null)
         throw new ArgumentNullException("function");
     if (delegateType == null)
         throw new ArgumentNullException("delegateType");
     if (!typeof(Delegate).IsAssignableFrom(delegateType))
         throw new ArgumentException("A delegate type is required", "delegateType");
     m_visitor = visitor;
     m_function = function;
     m_delegateType = delegateType;
     m_that = that;
     m_marshaller = visitor.Global.Marshaller;
 }
开发者ID:cosh,项目名称:Jint,代码行数:16,代码来源:JsFunctionDelegate.cs

示例11: 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.
                foreach (BranchedType obj in objs)
                {
                    Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');

                    byte[] data = marsh.Marshal(obj);

                    BranchedType other = marsh.Unmarshal<BranchedType>(data);

                    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:dheep-purdessy,项目名称:ignite,代码行数:45,代码来源:BinaryStructureTest.cs

示例12: NativeIndexer

 public NativeIndexer(Marshaller marshaller, MethodInfo[] getters, MethodInfo[] setters)
 {
     m_getOverload = new NativeOverloadImpl<MethodInfo, JsIndexerGetter>(
         marshaller,
         delegate(Type[] genericArgs, int Length)
         {
             return Array.FindAll<MethodInfo>(getters, mi => mi.GetParameters().Length == Length);
         },
         new NativeOverloadImpl<MethodInfo, JsIndexerGetter>.WrapMmemberDelegate(marshaller.WrapIndexerGetter)
     );
     m_setOverload = new NativeOverloadImpl<MethodInfo, JsIndexerSetter>(
         marshaller,
         delegate(Type[] genericArgs, int Length)
         {
             return Array.FindAll<MethodInfo>(setters, mi => mi.GetParameters().Length == Length);
         },
         new NativeOverloadImpl<MethodInfo,JsIndexerSetter>.WrapMmemberDelegate(marshaller.WrapIndexerSetter)
     );
 }
开发者ID:cosh,项目名称:Jint,代码行数:19,代码来源:NativeIndexer.cs

示例13: TestCustomPosition

        public void TestCustomPosition()
        {
            var stream = new BinaryHeapStream(16);

            stream.WriteLong(54);

            var marsh = new Marshaller(new BinaryConfiguration());

            var writer = new BinaryWriter(marsh, stream);

            writer.WriteChar('x');

            stream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(54, stream.ReadLong());

            var reader = new BinaryReader(marsh, stream, BinaryMode.Deserialize, null);

            Assert.AreEqual('x', reader.ReadChar());
        }
开发者ID:vladisav,项目名称:ignite,代码行数:20,代码来源:BinaryReaderWriterTest.cs

示例14: BinarizableReadBenchmark

        /// <summary>
        /// Initializes a new instance of the <see cref="BinarizableReadBenchmark"/> class.
        /// </summary>
        public BinarizableReadBenchmark()
        {
            _marsh = new Marshaller(new BinaryConfiguration
            {
                TypeConfigurations = new List<BinaryTypeConfiguration>
                {
                    new BinaryTypeConfiguration(typeof (Address)),
                    new BinaryTypeConfiguration(typeof (TestModel))
                }
            });

            _mem = _memMgr.Allocate();

            var stream = _mem.GetStream();

            //_marsh.StartMarshal(stream).Write(_model);
            _marsh.StartMarshal(stream).Write(_address);

            stream.SynchronizeOutput();
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:23,代码来源:BinarizableReadBenchmark.cs

示例15: 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:RazmikMkrtchyan,项目名称:ignite,代码行数:29,代码来源:ServiceProxySerializer.cs


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