コード例 #1
0
        private static TConnector CastConnector <TConnector>(ITikConnector connector)
            where TConnector : class, ITikConnector
        {
            Guard.ArgumentNotNull(connector, "connector");

            TConnector castedConnector = connector as TConnector;

            if (castedConnector == null)
            {
                throw new TikConnectorException(string.Format(CultureInfo.CurrentCulture, "Connector '{0}' does't implement '{1}'.", connector.GetType(), typeof(TConnector)));
            }
            else
            {
                return(castedConnector);
            }
        }
コード例 #2
0
        private TikSession(ITikConnector connector, TikConnectorType connectorType)
        {
            if ((connectorType == TikConnectorType.Custom))
            {
                if (connector == null)
                {
                    throw new ArgumentException("Use constructor with connector instance for custom connectors.", "connectorType");
                }
                else
                {
                    this.connector = connector;
                }
            }
            else
            {
                switch (connectorType)
                {
                case TikConnectorType.Api:
                    this.connector = new Tik4Net.Connector.Api.ApiConnector();
                    break;

                case TikConnectorType.Ssh:
                    throw new NotImplementedException();

                case TikConnectorType.Telnet:
                    throw new NotImplementedException();

                default:
                    throw new NotImplementedException(string.Format(CultureInfo.CurrentCulture, "Not supported TikConnectorType '{0}'.", connectorType));
                }
            }

            this.connectorType = connectorType;

            if (activeSessions == null)
            {
                activeSessions = new Stack <TikSession>();
            }
            activeSessions.Push(this);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TikSession"/> class with <see cref="TikConnectorType.Custom"/>
 /// <see cref="ConnectorType"/> and custom instance of <see cref="Connector"/>.
 /// </summary>
 public TikSession(ITikConnector connector)
     : this(connector, TikConnectorType.Custom)
 {
 }