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


C# ProtoWriter类代码示例

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


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


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