variable.cs
来自「短信网关的应用开发」· CS 代码 · 共 95 行
CS
95 行
using System;
using System.Collections.Generic;
using System.Text;
namespace SMPP.Variable
{
/// <summary>
/// SMPP数据接口
/// </summary>
public interface ISMPPData
{
/// <summary>
/// 获取字节数组
/// </summary>
/// <returns></returns>
byte[] GetBytes();
/// <summary>
/// 获取数据长度
/// </summary>
int Length
{
get;
}
/// <summary>
/// 从字节数组解析对象
/// </summary>
/// <param name="Datas">字节数组</param>
/// <param name="Index">启始索引</param>
void Parse(byte[] Datas, ref int Index);
}
/// <summary>
/// 数据类型接口
/// </summary>
public interface IVariable : ISMPPData
{
/// <summary>
/// 包含此变量的数据包对象
/// </summary>
IMessagePack Owner
{
get;
}
}
/// <summary>
/// 数据类型纯虚类
/// </summary>
public abstract class Variable : IVariable
{
protected internal IMessagePack _Owner = null;
internal void SetOwner(IMessagePack Owner)
{
if (_Owner != null)
throw new Exception("无法设置数据包对象,该数据已属于另一数据包。");
else
_Owner = Owner;
}
/// <summary>
/// 获取数据长度
/// </summary>
public abstract int Length
{
get;
}
/// <summary>
/// 包含此变量的数据包对象
/// </summary>
public IMessagePack Owner
{
get
{
return _Owner;
}
}
/// <summary>
/// 从字节数组解析对象
/// </summary>
/// <param name="Datas">字节数组</param>
/// <param name="Index">启始索引</param>
public abstract void Parse(byte[] Datas, ref int Index);
/// <summary>
/// 获取字节数组
/// </summary>
/// <returns></returns>
public abstract byte[] GetBytes();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?