/// <summary> /// Initializes a new instance of ExtensionViewModel. /// </summary> public ExtensionViewModel() { _extensionModel = (App.Current as App).ExtensionModel; _extensionModel.ExtensionLoaded += (sender, e) => { CurrentExtension = e.Extension; }; SetCurrentPageLinkCommand = new SignalCommand(); SetCurrentPageLinkCommand.Executed += (sender, e) => { if ((e.Parameter != null) && (e.Parameter is PageLink)) { CurrentPageLink = e.Parameter as PageLink; } }; SetCurrentExtensionCommand = new SignalCommand(); SetCurrentExtensionCommand.Executed += (sender, e) => { if ((e.Parameter != null) && (e.Parameter is ExtensionLink)) { var link = e.Parameter as ExtensionLink; CheckExtension(link); if (link.Extension != null) // may be null because of async loading (in this case, see _extensionModel.ExtensionLoaded event) { CurrentExtension = link.Extension; } } }; }
private static void SignalExecute(SignalCommand opts) { var baseAddress = new Uri(opts.Url); foreach (var loop in Enumerable.Range(1, opts.Repeat)) { using (var client = new HttpClient()) { client.BaseAddress = baseAddress; var response = client.GetAsync("web/signal").Result; if (response.IsSuccessStatusCode) { var serializer = new XmlSerializer(typeof(SignalStatusDto)); SignalStatus status; using (var stream = response.Content.ReadAsStreamAsync().Result) { status = (serializer.Deserialize(stream) as SignalStatusDto)?.ToViewModel(); } Console.WriteLine(status?.ToCsv()); if (opts.Repeat > 1) { Thread.Sleep(TimeSpan.FromSeconds(opts.PoolingTime)); } } } } }
public void ExecuteShouldSetHasBeenRunToTrue() { var sc = new SignalCommand(); sc.Execute(); Assert.True(sc.HasBeenRun); }
//private static string _currentSkinKey = "CurrentSkin"; public SkinViewModel() { _model = new SkinModel(); // CurrentSkin = (string)AssemblyConfigManager.Settings[_currentSkinKey]; //if (!String.IsNullOrEmpty(CurrentSkin)) //{ // LoadApplicationSkin(CurrentSkin); //} //else //{ // SkinManager.Current.LoadDefaultSkin(); // Perspective.Wpf.SkinManager.Current.LoadDefaultSkin(); // Perspective.Wpf3D.SkinManager.Current.LoadDefaultSkin(); //} SetCurrentSkinCommand = new SignalCommand(); SetCurrentSkinCommand.Executed += (sender, e) => { if ((e.Parameter != null) && (e.Parameter is string)) { CurrentSkin = e.Parameter as string; // LoadApplicationSkin(CurrentSkin); // AssemblyConfigManager.Settings[_currentSkinKey] = CurrentSkin; // AssemblyConfigManager.SaveSettings(); } }; }
public static Task Close(this ITransportConnection connection) { var command = new SignalCommand { Type = CommandType.Disconnect }; return connection.SendCommand(command); }
public static Task Close(this ITransportConnection connection) { var command = new SignalCommand { Type = CommandType.Disconnect }; return(connection.SendCommand(command)); }
public static Task Close(this ITransportConnection connection, string connectionId) { var command = new SignalCommand { Type = CommandType.Disconnect }; return(connection.Send(SignalCommand.AddCommandSuffix(connectionId), command)); }
private Task SendDisconnectCommand() { var command = new SignalCommand { Type = CommandType.Disconnect, ExpiresAfter = TimeSpan.FromMinutes(30) }; return(Connection.SendCommand(command)); }
private async Task <SignalsDTO> CheckSignals(string currency) { SignalCommand signalCommand = new SignalCommand { Currency = currency }; CommandResult <SignalsDTO> commandResult = await _cryptoCompareGateway.LatestSignals(signalCommand); return(commandResult?.Content); }
public void HasBeenRunShouldBeTrueAfterMultipleExecutions(int executions) { var sc = new SignalCommand(); for (int i = 0; i < executions; i++) { sc.Execute(); } Assert.True(sc.HasBeenRun); }
public async Task <CommandResult <SignalsDTO> > LatestSignals(SignalCommand command) { var request = new SignalsRequest(_defaultRequest) { Currecny = command?.Currency }; var response = await _tradingSignalsUseCase.Execute(request, _uriBuilder); return(response); }
public void IgnoresLeadingAndTrailingWhitespaceInCommandIds(string commandId, string commandIdToExecute) { var ce = new RouterCommand(); var command = new SignalCommand(); ce.Register(commandId, command); ce.Execute(commandIdToExecute); Assert.True(command.HasBeenRun); }
private Task SendCommand(string clientId, CommandType commandType, object commandValue) { string signal = _hubName + "." + clientId + "." + PersistentConnection.SignalrCommand; var groupCommand = new SignalCommand { Type = commandType, Value = commandValue }; return(_connection.Broadcast(signal, groupCommand)); }
private Task SendCommand(string connectionId, CommandType commandType, object commandValue) { string signal = SignalCommand.AddCommandSuffix(_hubName + "." + connectionId); var groupCommand = new SignalCommand { Type = commandType, Value = commandValue }; return(_connection.Broadcast(signal, groupCommand)); }
/// <summary> /// Initializes a new instance of MainViewModel. /// </summary> public MainViewModel() { _model = new ExtensionModel(); SetCurrentPageInfoCommand = new SignalCommand(); SetCurrentPageInfoCommand.Executed += (sender, e) => { if ((e.Parameter != null) && (e.Parameter is PageInfo)) { CurrentPageInfo = e.Parameter as PageInfo; } }; }
private Task SendCommand(string clientId, CommandType commandType, object commandValue) { string signal = _hubName + "." + clientId + "." + PersistentConnection.SignalrCommand; var groupCommand = new SignalCommand { Type = commandType, Value = commandValue }; return _connection.Broadcast(signal, groupCommand); }
private Task SendDisconnectCommand() { _disconnected = true; var command = new SignalCommand { Type = CommandType.Disconnect, ExpiresAfter = TimeSpan.FromMinutes(30) }; // Force connection to close by sending a command signal return(_connection.SendCommand(command)); }
public void ExecuteSpecifiedRegisteredCommand(string commandId) { var ce = new RouterCommand(); var commandToRun = new SignalCommand(); var commandNotToRun = new SignalCommand(); ce.Register(commandId, commandToRun); ce.Register("anotherCommand", commandNotToRun); ce.Execute(commandId); Assert.True(commandToRun.HasBeenRun); Assert.True(commandNotToRun.HasBeenRun == false); }
private IEnumerable <string> GetSignals(ClientHubInfo hubInfo, string connectionId) { var clientSignals = new[] { hubInfo.CreateQualifiedName(connectionId), SignalCommand.AddCommandSuffix(hubInfo.CreateQualifiedName(connectionId)) }; // Try to find the associated hub type Type hubType = _hubTypeResolver.ResolveType(hubInfo.Name); if (hubType == null) { throw new InvalidOperationException(String.Format("Unable to resolve hub {0}.", hubInfo.Name)); } // Set the full type name hubInfo.Name = hubType.FullName; // Create the signals for hubs return(hubInfo.Methods.Select(hubInfo.CreateQualifiedName) .Concat(clientSignals)); }
private IEnumerable <string> GetSignals(ClientHubInfo hubInfo, string connectionId) { // Try to find the associated hub type HubDescriptor hubDescriptor = _manager.EnsureHub(hubInfo.Name); // Add this to the list of hub desciptors this connection is interested in _hubs.Add(hubDescriptor); // Update the name (Issue #344) hubInfo.Name = hubDescriptor.Name; // Create the signals for hubs // 1. The hub name e.g. MyHub // 2. The connection id for this hub e.g. MyHub.{guid} // 3. The command signal for this connection var clientSignals = new[] { hubInfo.Name, hubInfo.CreateQualifiedName(connectionId), SignalCommand.AddCommandSuffix(hubInfo.CreateQualifiedName(connectionId)) }; return(clientSignals); }
public LocalizationViewModel() { _model = new LocalizationModel(); foreach (LocaleInfo localeInfo in LocaleInfos) { if (localeInfo.CultureName == Thread.CurrentThread.CurrentCulture.Name) { CurrentLocaleInfo = localeInfo; break; } } CultureManager.Current.UICultureChanged += new EventHandler <Perspective.Core.ChangedEventArgs <string> >(Current_UICultureChanged); SetCurrentLocaleInfoCommand = new SignalCommand(); SetCurrentLocaleInfoCommand.Executed += (sender, e) => { if ((e.Parameter != null) && (e.Parameter is LocaleInfo)) { CurrentLocaleInfo = e.Parameter as LocaleInfo; CultureManager.Current.UICulture = CurrentLocaleInfo.CultureName; } }; }
public static Task SendCommand(this IConnection connection, string connectionId, SignalCommand command) { return connection.Send(SignalCommand.AddCommandSuffix(connectionId), command); }
private Task SendDisconnectCommand() { var command = new SignalCommand { Type = CommandType.Disconnect, ExpiresAfter = TimeSpan.FromMinutes(30) }; return Connection.SendCommand(command); }
private Task SendCommand(string connectionId, CommandType commandType, object commandValue) { string signal = SignalCommand.AddCommandSuffix(_hubName + "." + connectionId); var groupCommand = new SignalCommand { Type = commandType, Value = commandValue }; return _connection.Broadcast(signal, groupCommand); }
public async Task <CommandResult <SignalsDTO> > LatestSignals([FromQuery] SignalCommand command) { var result = await _cryptoCompareGateway.LatestSignals(command); return(result); }
public void HasBeenRunShouldBeFalseBeforeExecuting() { var sc = new SignalCommand(); Assert.False(sc.HasBeenRun); }
private Task SendDisconnectCommand() { _disconnected = true; var command = new SignalCommand { Type = CommandType.Disconnect, ExpiresAfter = TimeSpan.FromMinutes(30) }; // Force connection to close by sending a command signal return _connection.SendCommand(command); }
public static Task SendCommand(this IConnection connection, string connectionId, SignalCommand command) { return(connection.Send(SignalCommand.AddCommandSuffix(connectionId), command)); }