/// <summary> /// Initializes a new instance of the CustomAdapterConnectionFactory class /// </summary> public GenericAdapterConnectionFactory(ConnectionUri connectionUri , ClientCredentials clientCredentials , GenericAdapter adapter) { this.clientCredentials = clientCredentials; this.adapter = adapter; }
// ------ Data Subscriber Methods ------ // Creates and starts a data subscriber using the connection information supplied by the user in ConnectionUri. // Subscribers created through this method should also be released by the ReleaseDataSubscriber method. private DataSubscriber CreateDataSubscriber() { DataSubscriber subscriber = new DataSubscriber(); int index = ConnectionUri.IndexOf(URI_SEPARATOR); string server = (index >= 0) ? ConnectionUri.Substring(0, index) : ConnectionUri; subscriber.StatusMessage += DataSubscriber_StatusMessage; subscriber.ProcessException += DataSubscriber_ProcessException; subscriber.ConnectionEstablished += DataSubscriber_ConnectionEstablished; subscriber.ConnectionTerminated += DataSubscriber_ConnectionTerminated; subscriber.MetaDataReceived += DataSubscriber_MetaDataReceived; subscriber.DataStartTime += DataSubscriber_DataStartTime; subscriber.NewMeasurements += DataSubscriber_NewMeasurements; subscriber.ConnectionString = string.Format("server={0}; interface={1}; localCertificate={2}; remoteCertificate={3}; validPolicyErrors={4}; validChainFlags={5}", server, IPv6Enabled ? "::0" : "0.0.0.0", FilePath.GetAbsolutePath("Local.cer"), FilePath.GetAbsolutePath("Remote.cer"), ~SslPolicyErrors.None, ~X509ChainStatusFlags.NoError); subscriber.SecurityMode = EnableEncryption ? SecurityMode.TLS : SecurityMode.None; if (!EnableCompression) { subscriber.OperationalModes = DataSubscriber.DefaultOperationalModes & ~OperationalModes.CompressPayloadData; } subscriber.ReceiveInternalMetadata = true; subscriber.ReceiveExternalMetadata = true; subscriber.Initialize(); subscriber.Start(); return(subscriber); }
/// <summary> /// Builds a connection factory from the ConnectionUri and ClientCredentials /// </summary> protected override IConnectionFactory BuildConnectionFactory( ConnectionUri connectionUri , ClientCredentials clientCredentials , System.ServiceModel.Channels.BindingContext context) { return(new GenericAdapterConnectionFactory(connectionUri, clientCredentials, this)); }
/// <summary> /// Initializes a new instance of the SocketAdapterConnectionFactory class /// </summary> public SocketAdapterConnectionFactory(ConnectionUri connectionUri , ClientCredentials clientCredentials , SocketAdapter adapter) { this.clientCredentials = clientCredentials; this.adapter = adapter; this._Uri = connectionUri as SocketAdapterConnectionUri; }
/// <summary> /// Initializes a new instance of the FileAdapterConnectionFactory class /// </summary> public FileAdapterConnectionFactory(ConnectionUri connectionUri , ClientCredentials clientCredentials , FileAdapter adapter) { this.clientCredentials = clientCredentials; this.adapter = adapter; this.ConnectionUri = connectionUri as FileAdapterConnectionUri; }
/// <summary> /// Initializes a new instance of the ScheduleAdapterConnectionFactory class /// </summary> public ScheduleAdapterConnectionFactory(ConnectionUri connectionUri , ClientCredentials clientCredentials , ScheduleAdapter adapter) { this.clientCredentials = clientCredentials; this.adapter = adapter; ConnectionUri = connectionUri as ScheduleAdapterConnectionUri; }
/// <summary> /// Initializes a new instance of the <see cref="MockAdapterConnectionFactory"/> class /// </summary> /// <param name="connectionUri">The connection Uri</param> /// <param name="clientCredentials">THe client credentials for the adapter connection</param> /// <param name="adapter">The adapter instance</param> public MockAdapterConnectionFactory( ConnectionUri connectionUri, ClientCredentials clientCredentials, MockAdapter adapter) { this.clientCredentials = clientCredentials; this.adapter = adapter; this.connectionUri = connectionUri as MockAdapterConnectionUri; }
public bool Equals(Peer other) { if (other == null) { return(false); } // FIXME: Don't compare the port, just compare the IP if (BEncodedString.IsNullOrEmpty(PeerId) || BEncodedString.IsNullOrEmpty(other.PeerId)) { return(ConnectionUri.Equals(other.ConnectionUri)); } return(PeerId.Equals(other.PeerId)); }
// ------ Data Subscriber Methods ------ // Creates and starts a data subscriber using the connection information supplied by the user in ConnectionUri. // Subscribers created through this method should also be released by the ReleaseDataSubscriber method. private DataSubscriber CreateDataSubscriber() { DataSubscriber subscriber = new DataSubscriber(); int index = ConnectionUri.IndexOf(URI_SEPARATOR, StringComparison.Ordinal); string server = (index >= 0) ? ConnectionUri.Substring(0, index) : ConnectionUri; subscriber.StatusMessage += DataSubscriber_StatusMessage; subscriber.ProcessException += DataSubscriber_ProcessException; subscriber.ConnectionEstablished += DataSubscriber_ConnectionEstablished; subscriber.ConnectionTerminated += DataSubscriber_ConnectionTerminated; subscriber.MetaDataReceived += DataSubscriber_MetaDataReceived; subscriber.DataStartTime += DataSubscriber_DataStartTime; subscriber.NewMeasurements += DataSubscriber_NewMeasurements; subscriber.ConnectionString = $"server={server}; interface={(IPv6Enabled ? "::0" : "0.0.0.0")};{(UseZeroMQChannel ? " useZeroMQChannel=true;" : "")} localCertificate={FilePath.GetAbsolutePath("Local.cer")}; remoteCertificate={FilePath.GetAbsolutePath("Remote.cer")}; validPolicyErrors={~SslPolicyErrors.None}; validChainFlags={~X509ChainStatusFlags.NoError}"; subscriber.SecurityMode = EnableEncryption ? SecurityMode.TLS : SecurityMode.None; subscriber.OperationalModes = DataSubscriber.DefaultOperationalModes; subscriber.CompressionModes = CompressionModes.GZip; if (EnableCompression) { subscriber.OperationalModes |= OperationalModes.CompressPayloadData; bool usingUDP = false; if (index >= 0) { usingUDP = ConnectionUri.Substring(index + URI_SEPARATOR.Length).ParseKeyValuePairs('&').ContainsKey("udp"); } if (!usingUDP) { subscriber.CompressionModes |= CompressionModes.TSSC; // TSSC mode requires TCP connection } } subscriber.ReceiveInternalMetadata = true; subscriber.ReceiveExternalMetadata = true; subscriber.Initialize(); subscriber.Start(); return(subscriber); }
Repository(ConnectionUri uri, IHttpClient httpClient) { this.uri = uri; this.httpClient = httpClient; }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ComputerName.Expression != null) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (ConnectionUri.Expression != null) { targetCommand.AddParameter("ConnectionUri", ConnectionUri.Get(context)); } if (ConfigurationName.Expression != null) { targetCommand.AddParameter("ConfigurationName", ConfigurationName.Get(context)); } if (AllowRedirection.Expression != null) { targetCommand.AddParameter("AllowRedirection", AllowRedirection.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (ThrottleLimit.Expression != null) { targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context)); } if (State.Expression != null) { targetCommand.AddParameter("State", State.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (PSSessionId.Expression != null) { targetCommand.AddParameter("Id", PSSessionId.Get(context)); } if (ContainerId.Expression != null) { targetCommand.AddParameter("ContainerId", ContainerId.Get(context)); } if (VMId.Expression != null) { targetCommand.AddParameter("VMId", VMId.Get(context)); } if (VMName.Expression != null) { targetCommand.AddParameter("VMName", VMName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
/// <summary> /// Opens the stream and starts playback. /// </summary> /// <param name="songName">The name of the song to be played.</param> public void Play(string songName) { if (m_dataSubscriber != null && m_metadata != null) { UnsynchronizedSubscriptionInfo info; StringBuilder filterExpression = new StringBuilder(); DataTable deviceTable = m_metadata.Tables["DeviceDetail"]; DataTable measurementTable = m_metadata.Tables["MeasurementDetail"]; Dictionary <string, string> uriSettings; string dataChannel = null; int uriIndex = ConnectionUri.IndexOf(URI_SEPARATOR); m_channelIndexes = new ConcurrentDictionary <Guid, int>(); m_sampleRate = DEFAULT_SAMPLE_RATE; m_numChannels = DEFAULT_NUM_CHANNELS; // Get sample rate from metadata. if (deviceTable != null) { string sampleRate = deviceTable.Rows.Cast <DataRow>() .Single(row => row["Acronym"].ToNonNullString() == songName)["FramesPerSecond"].ToNonNullString(); if (!string.IsNullOrEmpty(sampleRate)) { m_sampleRate = int.Parse(sampleRate); } } // Get measurements from metadata. if (measurementTable != null) { IEnumerable <DataRow> measurementRows = measurementTable.Rows.Cast <DataRow>() .Where(row => row["DeviceAcronym"].ToNonNullString() == songName) .Where(row => row["SignalAcronym"].ToNonNullString() == "ALOG" || row["SignalAcronym"].ToNonNullString() == "VPHM") .Where(row => row["Enabled"].ToNonNullString().ParseBoolean()) .OrderBy(row => row["ID"].ToNonNullString()); m_numChannels = 0; foreach (DataRow row in measurementRows) { Guid measurementID = Guid.Parse(row["SignalID"].ToNonNullString()); if (m_numChannels > 0) { filterExpression.Append(';'); } filterExpression.Append(measurementID); m_channelIndexes[measurementID] = m_numChannels; m_numChannels++; } } // Create UDP data channel if specified. if (uriIndex >= 0) { uriSettings = ConnectionUri.Substring(uriIndex + URI_SEPARATOR.Length).ParseKeyValuePairs('&'); if (uriSettings.ContainsKey("udp")) { dataChannel = string.Format("dataChannel={{port={0}; interface={1}}}", uriSettings["udp"], IPv6Enabled ? "::0" : "0.0.0.0"); } } m_buffer = new ConcurrentQueue <IMeasurement>(); m_dumpTimer = CreateDumpTimer(); m_statTimer = CreateStatTimer(); m_waveProvider = new BufferedWaveProvider(new WaveFormat(m_sampleRate < MINIMUM_SAMPLE_RATE ? MINIMUM_SAMPLE_RATE : m_sampleRate, m_numChannels)); m_wavePlayer = CreateWavePlayer(m_waveProvider); m_waveProvider.DiscardOnBufferOverflow = true; info = new UnsynchronizedSubscriptionInfo(false) { FilterExpression = filterExpression.ToString(), ExtraConnectionStringParameters = dataChannel }; m_statTimer.Start(); m_wavePlayer.Play(); m_dataSubscriber.UnsynchronizedSubscribe(info); m_timeoutTimer.Start(); OnStateChanged(PlaybackState.Buffering); } }
public override int GetHashCode() => PeerId?.GetHashCode() ?? ConnectionUri.GetHashCode();
public override string ToString() { return(ConnectionUri.ToString()); }
public override int GetHashCode() { return(PeerId?.GetHashCode() ?? ConnectionUri.GetHashCode()); }
public static IRepository Create(string connectionString, IHttpClient httpClient) { return(new Repository(ConnectionUri.For(connectionString), httpClient)); }
public override string ToString() => ConnectionUri.ToString();