Пример #1
0
        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);
        }
Пример #2
0
 public static Type GetInstanceType(CommucationType type)
 {
     if (_resources.ContainsKey(type))
     {
         return(_resources[type]);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Пример #3
0
            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();
            }
        }
Пример #5
0
        public static ICommunication GetInstance(CommucationType type)
        {
            Type t = CommunicationTypeHelper.GetInstanceType(type);

            return((ICommunication)Activator.CreateInstance(t));
        }
Пример #6
0
        public static ICommunication GetInstance(CommucationType type)
        {
            var t = CommucationResources.GetInstanceType(type);

            return((ICommunication)Activator.CreateInstance(t));
        }