zoukankan      html  css  js  c++  java
  • NetworkComms V3 序列化器之Protobuf.net和 JSONSerializer

    NetworkComms v3版本中,默认使用的是protobuf.net序列化器。

    即当您没有指定序列化的时候,系统自动使用默认的protobuf.net序列化器。

    当然我们也可以自己指定序列化器

    语法如下:

    SendReceiveOptions aboveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer<ProtobufSerializer>(), null, null);
    使用protobuf.net 传送的类,需要添加protobuf相关的attribute,大致如下.

    如果传送的类,是sql数据表相对应的实体类,可以通过模板生成  NetworkComms网络通信框架配套CodeSmith模板使用简介


    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using ProtoBuf;
    using EEDocManage.Data;

    namespace EEDocManage.Business
    {
    [ProtoContract]
    public class Dep
    {

    #region Constructors

    public Dep()
    { }


    #endregion

    #region Private Properties

    private int iD = -1;
    private string title = string.Empty;

    #endregion

    #region Public Properties

    [ProtoMember(1)]
    public int ID
    {
    get { return iD; }
    set { iD = value; }
    }
    [ProtoMember(2)]
    public string Title
    {
    get { return title; }
    set { title = value; }
    }

    #endregion


    }

    }

    NeworkComms V3框架还自定了 JSONSerializer 序列化器(支持.net Framework 4.0版本)

    使用的话只要指定一下序列化器即可

    SendReceiveOptions aboveOptions = new SendReceiveOptions(DPSManager.GetDataSerializer<JSONSerializer>(), null, null);
    具体的其他设置,由于我对json还不是太了解,正在探索中

    www.networkComms.cn整理
    ---------------------
    作者:networkcomms
    来源:CSDN
    原文:https://blog.csdn.net/networkcomms/article/details/44218197
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    视图和触发器
    45题的难点
    表连接、Tsql基本编程和存储过程
    五种函数、子查询和分页查询
    语句创建数据库表及增删改查
    约束
    pyhton的参数类型
    python的数组与集合
    python基础--编码
    NSIS的Push与Pop
  • 原文地址:https://www.cnblogs.com/Jeely/p/10972223.html
Copyright © 2011-2022 走看看