Пример #1
0
        public OntologySdk(string node, ConnectionMethodFactory.ConnectionMethod connectionMethod)
        {
            var factory = new ConnectionMethodFactory();

            ConnectionManager = factory.SetConnectionMethod(connectionMethod);
            _account          = new Basic.Account(node);
        }
        public OntologySdk(string node, ConnectionMethodFactory.ConnectionMethod connectionMethod)
        {
            NodeHost = node;
            var factory = new ConnectionMethodFactory();

            Connection = factory.SetConnectionMethod(node, connectionMethod);
        }
Пример #3
0
        public static Connection getConnection(ConnectionEnum connectionEnum, IConnectionMethod connectionMethod)
        {
            Connection _connection = new Connection();

            _connection.setConnectionMethod(connectionMethod);

            switch (connectionEnum.ToString())
            {
            case "POSTS":
                _connection.URI = POSTS_URI;
                break;

            case "USERS":
                _connection.URI = USERS_URI;
                break;

            default:
                break;
            }

            return(_connection);
        }
Пример #4
0
 public void setConnectionMethod(IConnectionMethod connectionMethod)
 {
     _connectionMethod = connectionMethod;
 }
Пример #5
0
        static void Main()
        {
            bool  createdNew;
            Mutex mutex = new Mutex(true, "RemoteControlV2", out createdNew);

            Logger = Logger.AllocateLogger();
            Logger.Initialize();
            Logger.Log(LogType.Runtime, LogSeverity.Info, "Application Started");
            Logger.Log(LogType.Runtime, LogSeverity.Debug, "Loading configuration...");
            if (File.Exists("config.json"))
            {
                try
                {
                    Logger.Log(LogType.Runtime, LogSeverity.Debug, "Found configuration file. Loading...");
                    Config = Configuration.FromFile("config.json");
                }
                catch (Exception ex)
                {
                    Logger.Log(LogType.Runtime, LogSeverity.Debug, $"Exception of type {ex.GetType()}: {ex.Message}");
                    Logger.Log(LogType.Runtime, LogSeverity.Trace, ex.StackTrace);
                    Logger.Log(LogType.Runtime, LogSeverity.Fatal, "Could not load configuration file.");
                    Exit(-1);
                }
            }
            else
            {
                try
                {
                    Logger.Log(LogType.Runtime, LogSeverity.Debug, "No configuration file found. Creating it...");
                    Config.Save("config.json");
                }
                catch (Exception ex)
                {
                    Logger.Log(LogType.Runtime, LogSeverity.Debug, $"Exception of type {ex.GetType()}: {ex.Message}");
                    Logger.Log(LogType.Runtime, LogSeverity.Trace, ex.StackTrace);
                    Logger.Log(LogType.Runtime, LogSeverity.Fatal, "Could not create configuration file.");
                    Exit(-1);
                }
            }
            AddStandardCommands();

            try
            {
                Logger.Log(LogType.Runtime, LogSeverity.Debug, "Initializing serial connection method...");
                var v1 = new SerialConnectionMethod(Config.Port, Config.BaudRate);
                Logger.Log(LogType.Runtime, LogSeverity.Debug, "Initializing TCP connection method...");
                var v2 = new TCPConnectionMethod(Config.NetPort);
                Connection = new AggregateConnectionMethod(v1, v2);
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.Runtime, LogSeverity.Debug, $"Exception of type {ex.GetType()}: {ex.Message}");
                Logger.Log(LogType.Runtime, LogSeverity.Trace, ex.StackTrace);
                Logger.Log(LogType.Runtime, LogSeverity.Fatal, "Could not initialize connection method.");
                Exit(-1);
            }

            Manager.Plugins = EnumeratePlugins();
            Manager.LoadAllPlugins();
            InitializePlugins();
            Logger.Log(LogType.Runtime, LogSeverity.Info, "Plugins loaded and initialized.");

            Connection.Initialize();
            Connection.OnCommandReceived += Connection_OnCommandReceived;
            Logger.Log(LogType.Runtime, LogSeverity.Debug, "Adding notification tray icon...");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Icon         = new NotifyIcon();
            Icon.Icon    = Resources.Icon;
            Icon.Text    = "RemoteControlV2";
            Icon.Visible = Config.ShowIcon;
            SubMenu      = new ContextMenuStrip();
            MainItem     = new ToolStripMenuItem("Main Window");
            ExitItem     = new ToolStripMenuItem("Exit");
            SubMenu.Items.AddRange(new ToolStripMenuItem[] { MainItem, ExitItem });
            Icon.ContextMenuStrip = SubMenu;
            MainItem.Click       += MainItem_Click;
            ExitItem.Click       += (o, e) => Exit(0);
            Logger.Log(LogType.Runtime, LogSeverity.Debug, "Notification tray icon added.");
            Logger.Log(LogType.Runtime, LogSeverity.Debug, "Starting message loop.");
            Application.Run();
        }
Пример #6
0
 public AggregateConnectionMethod(IConnectionMethod a, IConnectionMethod b)
 {
     method1 = a;
     method2 = b;
 }