• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ProtoWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Write

 public override void Write(object value, ProtoWriter dest)
 {
     if(getSpecified == null || (bool)getSpecified.Invoke(value, null))
     {
         Tail.Write(value, dest);
     }
 }
开发者ID:Rasarack,项目名称:SteamBot,代码行数:7,代码来源:MemberSpecifiedDecorator.cs


示例2: GenerateTypeSerializer

 public void GenerateTypeSerializer()
 {
     var head = new TypeSerializer(typeof(CustomerStruct),
         new int[] { 1, 2 },
         new IProtoSerializer[] {
             new PropertyDecorator(typeof(CustomerStruct), typeof(CustomerStruct).GetProperty("Id"), new TagDecorator(1, WireType.Variant,false,  new Int32Serializer())),
             new FieldDecorator(typeof(CustomerStruct), typeof(CustomerStruct).GetField("Name"), new TagDecorator(2, WireType.String,false,  new StringSerializer()))
         }, null, false, true, null, null, null);
     var ser = CompilerContext.BuildSerializer(head);
     var deser = CompilerContext.BuildDeserializer(head);
     CustomerStruct cs1 = new CustomerStruct { Id = 123, Name = "Fred" };
     using (MemoryStream ms = new MemoryStream())
     {
         using (ProtoWriter writer = new ProtoWriter(ms, null, null))
         {
             ser(cs1, writer);
         }
         byte[] blob = ms.ToArray();
         ms.Position = 0;
         using (ProtoReader reader = new ProtoReader(ms, null, null))
         {
             CustomerStruct? cst = (CustomerStruct?)deser(null, reader);
             Assert.IsTrue(cst.HasValue);
             CustomerStruct cs2 = cst.Value;
             Assert.AreEqual(cs1.Id, cs2.Id);
             Assert.AreEqual(cs1.Name, cs2.Name);
         }
     }
 }
开发者ID:Ribosome2,项目名称:protobuf-net-1,代码行数:29,代码来源:Struct.cs


示例3: Writer

 public void Writer(ProtoWriter writer, object instance)
 {
     switch (this.typeCode)
     {
         case TypeCode.Byte:
             writer.Write((uint)(byte)instance);
             break;
         case TypeCode.SByte:
             writer.Write((uint)(sbyte)instance);
             break;
         case TypeCode.Int16:
             writer.Write((uint)(short)instance);
             break;
         case TypeCode.Int32:
             writer.Write((uint)(int)instance);
             break;
         case TypeCode.UInt16:
             writer.Write((uint)(ushort)instance);
             break;
         case TypeCode.UInt32:
             writer.Write((uint)instance);
             break;
         case TypeCode.Int64:
             writer.Write((ulong)(long)instance);
             break;
         case TypeCode.UInt64:
             writer.Write((ulong)instance);
             break;
     }
 }
开发者ID:,项目名称:,代码行数:30,代码来源:


示例4: Write

        public override void Write(object value, ProtoWriter dest)
        {
            Helpers.DebugAssert(value != null);
            value = field.GetValue(value);
			//if (value!=null) Tail.Write(value, dest);
			if (!Helpers.IsDefault(value)) Tail.Write(value, dest);
        }
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:7,代码来源:FieldDecorator.cs


示例5: RowWriter

        public RowWriter(
            ProtoWriter writer,
            IEnumerable<ProtoDataColumn> columns,
            ProtoDataWriterOptions options)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            this.writer = writer;
            this.columns = columns;
            this.options = options;
            rowIndex = 0;
        }
开发者ID:julienadam,项目名称:protobuf-net-data,代码行数:25,代码来源:RowWriter.cs


示例6: Write

 public override void Write(object value, ProtoWriter dest)
 {
     if (!object.Equals(value, defaultValue))
     {
         Tail.Write(value, dest);
     }
 }
开发者ID:Ribosome2,项目名称:protobuf-net-1,代码行数:7,代码来源:DefaultValueDecorator.cs


示例7: Write

 public void Write(object value, ProtoWriter dest)
 {
     for(int i = 0 ; i < tails.Length ; i++)
     {
         object val = GetValue(value, i);
         if(val != null) tails[i].Write(val, dest);
     }
 }
开发者ID:Ribosome2,项目名称:protobuf-net-1,代码行数:8,代码来源:TupleSerializer.cs


示例8: Write

 public override void Write(object value, ProtoWriter dest)
 {
     value = this.field.GetValue(value);
     if (value != null)
     {
         this.Tail.Write(value, dest);
     }
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:8,代码来源:FieldDecorator.cs


示例9: HeaderWriter

        public HeaderWriter(ProtoWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            this.writer = writer;
        }
开发者ID:julienadam,项目名称:protobuf-net-data,代码行数:9,代码来源:HeaderWriter.cs


示例10:

 void IProtoSerializer.Write(object value, ProtoWriter dest)
 {
     if (recursionCheck)
     {
         ProtoWriter.WriteObject(value, key, dest);
     }
     else
     {
         ProtoWriter.WriteRecursionSafeObject(value, key, dest);
     }
 }
开发者ID:tsuixl,项目名称:Frame,代码行数:11,代码来源:SubItemSerializer.cs


示例11: Writer

 public void Writer(ProtoWriter writer, object instance)
 {
     if (instance == null)
     {
         writer.WriteNull();
     }
     else
     {
         int messageId = writer.BeginSubMessage();
         this.itemSerializer.Writer(writer, instance);
         writer.EndSubMessage(messageId);
     }
 }
开发者ID:robb83,项目名称:Protocols,代码行数:13,代码来源:TypeDecorator.cs


示例12: Write

 public void Write(object value, ProtoWriter dest)
 {
     if (map == null)
     {
         ProtoWriter.WriteInt32(EnumToWire(value), dest);
     }
     else
     {
         for (int i = 0; i < map.Length; i++) {
             if (object.Equals(map[i].Value, value)) {
                 ProtoWriter.WriteInt32(map[i].WireValue, dest);
                 return;
             }
         }
         ProtoWriter.ThrowEnumException(dest, value);
     }            
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:17,代码来源:EnumSerializer.cs


示例13: WriteObjectContent

 /// <summary>
 /// Writes the body of an object in the output
 /// </summary>
 public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     if (graph == null)
     {
         writer.WriteAttributeString("nil", "true");
     }
     else
     {
         using (MemoryStream ms = new MemoryStream())
         {
             using (ProtoWriter protoWriter = new ProtoWriter(ms, model, null))
             {
                 model.Serialize(key, graph, protoWriter);
             }
             byte[] buffer = ms.GetBuffer();
             writer.WriteBase64(buffer, 0, (int)ms.Length);
         }
     }
 }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:22,代码来源:XmlProtoSerializer.cs


示例14: Writer

        public void Writer(ProtoWriter writer, object instance)
        {
            IEnumerable enumerable = (IEnumerable)instance;

            int messageId = writer.BeginSubMessage();

            foreach (var e in enumerable)
            {
                if (e == null)
                {
                    writer.SetFieldNumber(1);
                    writer.WriteNull();
                }
                else
                {
                    writer.SetFieldNumber(1);
                    this.typeDescription.NestedMessageSerializer.Writer(writer, e);
                }
            }

            writer.EndSubMessage(messageId);
        }
开发者ID:robb83,项目名称:Protocols,代码行数:22,代码来源:ListSerializer.cs


示例15: Write

 public void Write(object value, ProtoWriter dest)
 {
     BclHelpers.WriteDecimal((decimal)value, dest);
 }
开发者ID:Rasarack,项目名称:SteamBot,代码行数:4,代码来源:DecimalSerializer.cs


示例16:

 void IProtoSerializer.Write(object value, ProtoWriter dest)
 {
     ProtoWriter.WriteObject(value, key, dest);
 }
开发者ID:martindevans,项目名称:DistributedServiceProvider,代码行数:4,代码来源:SubItemSerializer.cs


示例17: Write

 public abstract void Write(object value, ProtoWriter dest);
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:1,代码来源:ProtoDecoratorBase.cs


示例18: Write

 public override void Write(object value, ProtoWriter dest)
 {
     ProtoWriter.WriteFieldHeader(fieldNumber, wireType, dest);
     Tail.Write(value, dest);
 }
开发者ID:tsuixl,项目名称:Frame,代码行数:5,代码来源:TagDecorator.cs


示例19: Write

 public void Write(object value, ProtoWriter dest)
 {
     BclHelpers.WriteNetObject(value, dest, key, options);
 }
开发者ID:he0x,项目名称:xRAT,代码行数:4,代码来源:NetObjectSerializer.cs


示例20: Write

 public override void Write(object value, ProtoWriter dest)
 {
     IList arr = (IList)value;
     int len = arr.Count;
     SubItemToken token;
     bool writePacked = (options & OPTIONS_WritePacked) != 0;
     if (writePacked)
     {
         ProtoWriter.WriteFieldHeader(fieldNumber, WireType.String, dest);
         token = ProtoWriter.StartSubItem(value, dest);
         ProtoWriter.SetPackedField(fieldNumber, dest);
     }
     else
     {
         token = new SubItemToken(); // default
     }
     bool checkForNull = !SupportNull;
     for (int i = 0; i < len; i++)
     {
         object obj = arr[i];
         if (checkForNull && obj == null) { throw new NullReferenceException(); }
         Tail.Write(obj, dest);
     }
     if (writePacked)
     {
         ProtoWriter.EndSubItem(token, dest);
     }            
 }
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:28,代码来源:ArrayDecorator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Protocol类代码示例发布时间:2022-05-24
下一篇:
C# ProtoVessel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap