예제 #1
0
        public InstancePack CreateInstance(Netool.Logging.InstanceLogger logger, InstanceType type, object settings)
        {
            IInstance instance;

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            switch (type)
            {
            case InstanceType.Server:
                var s = settings as TcpServerSettings;
                if (s == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new CalcServer(s);
                break;

            default:
                throw new NotImplementedException();
            }
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, loader);

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }
예제 #2
0
        /// <inheritdoc/>
        public InstancePack CreateInstance(InstanceLogger logger, InstanceType type)
        {
            IInstance instance;

            switch (type)
            {
            case InstanceType.Server:
                instance = createServer(logger);
                break;

            case InstanceType.Client:
                instance = createClient(logger);
                break;

            default:
                instance = createProxy(logger);
                break;
            }
            if (instance == null)
            {
                throw new SetupAbortedByUserException();
            }
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, createChannelViewFactory());

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }
예제 #3
0
        /// <inheritdoc/>
        public InstancePack CreateInstance(InstanceLogger logger, InstanceType type)
        {
            IInstance instance;

            switch (type)
            {
            case InstanceType.Server:
                instance = createServer();
                break;

            case InstanceType.Client:
                instance = createClient();
                break;

            default:
                instance = createProxy();
                break;
            }
            if (instance == null)
            {
                throw new SetupAbortedByUserException();
            }
            // for now set manual driver to everything
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, loader);

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }
예제 #4
0
        public InstancePack RestoreInstance(Netool.Logging.InstanceLogger logger)
        {
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, logger, loader);

            view.SetController(cont);
            return(new InstancePack(view, cont, cont.GetInstanceType()));
        }
예제 #5
0
        /// <inheritdoc/>
        public InstancePack RestoreInstance(InstanceLogger logger)
        {
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, logger, createChannelViewFactory(true));

            view.SetController(cont);
            return(new InstancePack(view, cont, cont.GetInstanceType()));
        }
예제 #6
0
        /// <inheritdoc/>
        public InstancePack CreateInstance(InstanceLogger logger, InstanceType type, object settings)
        {
            IInstance instance;

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            switch (type)
            {
            case InstanceType.Server:
                var s = settings as HttpServerSettings;
                if (s == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new HttpServer(s, logger);
                break;

            case InstanceType.Client:
                var c = settings as HttpClientSettings;
                if (c == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new HttpClient(c, logger);
                break;

            default:
                var p = settings as DefaultProxySettings;
                if (p == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                var srv = p.Server as HttpServer;
                if (srv != null)
                {
                    srv.SetLogger(logger);
                }
                var factory = p.ClientFactory as HttpClientFactory;
                if (factory != null)
                {
                    factory.SetLogger(logger);
                }
                instance = new DefaultProxy(p);
                break;
            }
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, createChannelViewFactory());

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }
예제 #7
0
        /// <inheritdoc/>
        public InstancePack CreateInstance(InstanceLogger logger, InstanceType type, object settings)
        {
            IInstance instance;

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            switch (type)
            {
            case InstanceType.Server:
                var s = settings as TcpServerSettings;
                if (s == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new TcpServer(s);
                break;

            case InstanceType.Client:
                var c = settings as TcpClientSettings;
                if (c == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new TcpClient(c);
                break;

            default:
                var p = settings as DefaultProxySettings;
                if (p == null)
                {
                    throw new InvalidSettingsTypeException();
                }
                instance = new DefaultProxy(p);
                break;
            }
            // for now set manual driver to everything
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, loader);

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }
예제 #8
0
        public InstancePack CreateInstance(Netool.Logging.InstanceLogger logger, InstanceType type)
        {
            IInstance instance;

            switch (type)
            {
            case InstanceType.Server:
                instance = createServer();
                break;

            default:
                throw new NotImplementedException();
            }
            if (instance == null)
            {
                throw new SetupAbortedByUserException();
            }
            var view = new DefaultInstanceView();
            var cont = new DefaultInstanceController(view, instance, logger, loader);

            view.SetController(cont);
            return(new InstancePack(view, cont, type));
        }