using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Services { /// /// 接收事件类 /// public class ReceivedEventArgs:EventArgs { public byte[] buffer; public string type; } /// /// 通讯基类 /// public abstract class CommunicationBase:IDisposable { public abstract void SendData(byte[] buffer,object o); public delegate void ReceivedEventHandler(object o, ReceivedEventArgs e); public event ReceivedEventHandler ReceivedEvent; public abstract void Open(); public abstract void Close(); private bool isOpen; public virtual object GetTag() { return null; } public bool IsOpen { get { return isOpen; } set { isOpen = value; } } protected virtual void OnReceivedEvent(object o, ReceivedEventArgs e) { if (ReceivedEvent != null) { ReceivedEvent(o, e); } } public virtual void Dispose() { } } }