internal static Type GetInstanceType(CommucationType type) { FieldInfo data = typeof(CommucationType).GetField(type.ToString()); Attribute attribute = Attribute.GetCustomAttribute(data, typeof(CommucationAttribute)); CommucationAttribute result = (CommucationAttribute)attribute; return(result.InstanceType); }
public static Type GetInstanceType(CommucationType type) { if (_resources.ContainsKey(type)) { return(_resources[type]); } else { throw new ArgumentNullException(); } }
public static ICommunication GetInstance(CommucationType type) { switch (type) { //case CommucationType.Tcp: // return new TcpCommunication(); case CommucationType.Udp: return(new UdpCommunication()); default: throw new ArgumentOutOfRangeException(); } }
public static ICommunication GetInstance(CommucationType type) { switch (type) { case CommucationType.Tcp: return(new TcpCommunication()); case CommucationType.SerialPort: return(new SerialCommunication()); default: throw new ArgumentOutOfRangeException(); } }
public static ICommunication GetInstance(CommucationType type) { Type t = CommunicationTypeHelper.GetInstanceType(type); return((ICommunication)Activator.CreateInstance(t)); }
public static ICommunication GetInstance(CommucationType type) { var t = CommucationResources.GetInstanceType(type); return((ICommunication)Activator.CreateInstance(t)); }