Ejemplo n.º 1
0
        public override Connection TryConnect(AbstractBluetoothDevice device, TimeSpan timeout)
        {
            var source = new ConnectionSource();

            source.Source.SetResult(false);
            return(source);
        }
 public void TargetConnectable(IConnectable target)
 {
     if (ConnectionSource != null && ConnectionSource != target && ConnectionSource.CanConnect(target))
     {
         ConnectionTarget = target;
     }
 }
Ejemplo n.º 3
0
        public SqlDb(string connection, SqlSyntax syntax, string userName = null, ConnectionSource connectionSource = ConnectionSource.ConfigFile)
        {
            _syntax = syntax;

            UserName = userName;

            switch (connectionSource)
            {
            case ConnectionSource.ConfigFile:
                try
                {
                    _connectionString = ConfigurationManager.ConnectionStrings[connection].ConnectionString;
                    ConnectionName    = connection;
                }
                catch (NullReferenceException)
                {
                    string fileName       = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
                    string allConnections = AllConnectionNames();
                    throw new NullReferenceException($"Connection string named '{connection}' was not found in {fileName}. These connection names are defined: {allConnections}");
                }
                break;

            case ConnectionSource.Literal:
                _connectionString = connection;
                break;
            }

            if (_connectionString.StartsWith("@"))
            {
                string name = _connectionString.Substring(1);
                _connectionString = ConnectionStringReference.Resolve(name);
            }
        }
Ejemplo n.º 4
0
        public override void SetUp()
        {
            _idToName.ClearAll();

            ConnectionSource.CleanBasicDocuments();
            _container = Container.For <DevelopmentModeRegistry>();
            _session   = _container.GetInstance <IDocumentSession>();
        }
Ejemplo n.º 5
0
 private static void createRoles()
 {
     using (var conn = new ConnectionSource().Create())
     {
         conn.Open();
         conn.CreateCommand("DROP ROLE IF EXISTS foo;create role foo;").ExecuteNonQuery();
         conn.CreateCommand("DROP ROLE IF EXISTS bar;create role bar;").ExecuteNonQuery();
     }
 }
Ejemplo n.º 6
0
        public override Connection TryConnect(AbstractBluetoothDevice device, TimeSpan timeout)
        {
            OnStatusUpdated("Connecting");
            var conn = new ConnectionSource();

            ((DeviceHolder)device).Device.ConnectGatt(null, false, new GattCallback(this, conn));
            Task.Delay(timeout).ContinueWith(_ => conn.Source.SetCanceled());
            return(conn);
        }
Ejemplo n.º 7
0
        public override Connection TryConnect(AbstractBluetoothDevice device, TimeSpan timeout)
        {
            OnStatusUpdated("Connecting");
            var peripheral = ((DeviceHolder)device).Device;
            var connection = new ConnectionSource();

            peripheral.Delegate = new PeripheralDelegate(this, connection);
            _manager.ConnectPeripheral(peripheral);
            return(connection);
        }
Ejemplo n.º 8
0
 public override Point GetConnectionSourcePoint(int nSource)
 {
     if (nSource != -1)
     {
         ConnectionSource source = (ConnectionSource)nSource;
         Debug.Assert((source == ConnectionSource.Plus) || (source == ConnectionSource.Minus));
         return((source == ConnectionSource.Plus) ? this.PointPlus : this.PointMinus);
     }
     return(this.PointPlus);
 }
Ejemplo n.º 9
0
        public async Task can_get_last_event_progression_on_initial_check()
        {
            var factory = new ConnectionSource();

            using (var data = new StagedEventData(theOptions, factory, new EventGraph(new StoreOptions()), new JilSerializer()))
            {
                var lastEncountered = await data.LastEventProgression().ConfigureAwait(false);

                lastEncountered.ShouldBe(0);
            }
        }
Ejemplo n.º 10
0
 public GattCallback(Bluetooth parent, ConnectionSource connection)
 {
     _parent     = parent;
     _identifier = Encoding.UTF8.GetBytes(parent._identifier);
     _handler    = new BluetoothHandler(connection)
     {
         DisconnectDevice = Disconnect,
         WriteValue       = WriteValue,
         UpdateStatus     = _parent.OnStatusUpdated,
     };
 }
Ejemplo n.º 11
0
 public PeripheralDelegate(Bluetooth parent, ConnectionSource connection)
 {
     _manager     = parent._manager;
     _parent      = parent;
     _adapterName = UIDevice.CurrentDevice.Name;
     _handler     = new BluetoothHandler(connection)
     {
         WriteValue       = WriteValue,
         DisconnectDevice = Disconnect,
         UpdateStatus     = _parent.OnStatusUpdated,
     };
 }
        public when_deriving_the_table_definition_from_the_database_schema_Tests()
        {
            ConnectionSource.CleanBasicDocuments();
            _schema = _container.GetInstance <DocumentSchema>();

            theMapping = _schema.MappingFor(typeof(User)).As <DocumentMapping>();
            theMapping.DuplicateField("UserName");


            _storage = _schema.StorageFor(typeof(User));

            theDerivedTable = _schema.TableSchema(theMapping.TableName);
        }
Ejemplo n.º 13
0
        public override bool CanTrainMoveThruSource(TrainBase t, int nSource)
        {
            int index = this.m_alTrainsPlusToMinus.IndexOf(t);

            if (index == -1)
            {
                Debug.Assert(false);
                return(false);
            }
            ConnectionSource source = (ConnectionSource)nSource;

            if (source == ConnectionSource.Plus)
            {
                return(index == 0);
            }
            return(index == (this.m_alTrainsPlusToMinus.Count - 1));
        }
Ejemplo n.º 14
0
        internal static string Build(ConnectionSource connectionSource)
        {
            string connectionStringName;

            switch (connectionSource)
            {
            default:
            case ConnectionSource.Data:
            {
                if (Settings.CurrentDataConfigurationSettings != null && !string.IsNullOrEmpty(Settings.CurrentDataConfigurationSettings.ConnectionString))
                {
                    return(Settings.CurrentDataConfigurationSettings.ConnectionString);
                }

                connectionStringName = Settings.Data.ConnectionName;
            }
            break;

            case ConnectionSource.Communication:
            {
                if (Settings.CurrentCommunicationConfigurationSettings != null && !string.IsNullOrEmpty(Settings.CurrentCommunicationConfigurationSettings.ConnectionString))
                {
                    return(Settings.CurrentCommunicationConfigurationSettings.ConnectionString);
                }

                connectionStringName = Settings.Communication.ConnectionName;
            }
            break;

            case ConnectionSource.Log:
            {
                if (Settings.CurrentLogConfigurationSettings != null && !string.IsNullOrEmpty(Settings.CurrentLogConfigurationSettings.ConnectionString))
                {
                    return(Settings.CurrentLogConfigurationSettings.ConnectionString);
                }

                connectionStringName = Settings.Log.ConnectionName;
            }
            break;
            }

            return(System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString);
        }
Ejemplo n.º 15
0
        public async Task can_get_last_event_progression_from_existing_data()
        {
            var factory = new ConnectionSource();

            using (var conn = factory.Create())
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.Sql("insert into mt_event_progression (name, last_seq_id) values ('something', 121)");

                    await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);
                }
            }

            using (var data = new StagedEventData(theOptions, factory, new EventGraph(new StoreOptions()), new JilSerializer()))
            {
                var lastEncountered = await data.LastEventProgression().ConfigureAwait(false);

                lastEncountered.ShouldBe(121);
            }
        }
        public bool TryToConnect(int retries, int wait, bool force, ConnectionSource connectionSource)
        {
            if (force || m_connected == false)
            {
                WireProtocol.Commands.Monitor_Ping cmd = new Microsoft.SPOT.Debugger.WireProtocol.Commands.Monitor_Ping();

                cmd.m_source = WireProtocol.Commands.Monitor_Ping.c_Ping_Source_Host;
                cmd.m_dbg_flags = (m_stopDebuggerOnConnect ? WireProtocol.Commands.Monitor_Ping.c_Ping_DbgFlag_Stop : 0);

                WireProtocol.IncomingMessage msg = SyncMessage(WireProtocol.Commands.c_Monitor_Ping, 0, cmd, retries, wait);

                if (msg == null)
                {
                    m_connected = false;
                    return false;
                }

                WireProtocol.Commands.Monitor_Ping.Reply reply = msg.Payload as WireProtocol.Commands.Monitor_Ping.Reply;

                if (reply != null)
                {
                    this.m_targetIsBigEndian = (reply.m_dbg_flags & WireProtocol.Commands.Monitor_Ping.c_Ping_DbgFlag_BigEndian).Equals(WireProtocol.Commands.Monitor_Ping.c_Ping_DbgFlag_BigEndian);
                }
                m_connected = true;

                m_connectionSource = (reply == null || reply.m_source == WireProtocol.Commands.Monitor_Ping.c_Ping_Source_TinyCLR) ? ConnectionSource.TinyCLR : ConnectionSource.TinyBooter;
 
                if (m_silent)
                {
                    SetExecutionMode(WireProtocol.Commands.Debugging_Execution_ChangeConditions.c_fDebugger_Quiet, 0);
                }

                // resume execution for older clients, since server tools no longer do this.
                if (!m_stopDebuggerOnConnect && (msg != null && msg.Payload == null))
                {
                    ResumeExecution();
                }
            }

            if ((force || m_capabilities.IsUnknown) && m_connectionSource == ConnectionSource.TinyCLR)
            {
                m_capabilities = DiscoverCLRCapabilities();
                m_ctrl.Capabilities = m_capabilities;
            }

            if (connectionSource != ConnectionSource.Unknown && connectionSource != m_connectionSource)
            {
                m_connected = false;
                return false;
            }

            return true;
        }
Ejemplo n.º 17
0
 public DocumentSchemaTests()
 {
     ConnectionSource.CleanBasicDocuments();
     _schema = _container.GetInstance <DocumentSchema>();
 }
Ejemplo n.º 18
0
        public static SqlConnection CreateConnection(ConnectionSource connectionSource)
        {
            string connectionString = ConnectionStringBuilder.Build(connectionSource);

            return(new SqlConnection(ClearConnectionString(connectionString)));
        }