Showing the changes to Source/Libraries/GSF.ServiceProcess/ClientHelper.cs (1 of 3 files). Show all
Unified · Split
| @@ -185,7 +185,7 @@ namespace GSF.ServiceProcess · 184 unmodified lines | ||
| 185 | 185 | public ClientHelper(IContainer container) |
| 186 | 186 | : this() |
| 187 | 187 | { |
| 188 | − if (container != null) | |
| 188 | + if ((object)container != null) | |
| 189 | 189 | container.Add(this); |
| 190 | 190 | } |
| 191 | 191 | |
| @@ -206,7 +206,7 @@ namespace GSF.ServiceProcess · 14 unmodified lines | ||
| 206 | 206 | } |
| 207 | 207 | set |
| 208 | 208 | { |
| 209 | − if (m_remotingClient != null) | |
| 209 | + if ((object)m_remotingClient != null) | |
| 210 | 210 | { |
| 211 | 211 | // Detach events from any existing instance |
| 212 | 212 | m_remotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished; |
| @@ -218,7 +218,7 @@ namespace GSF.ServiceProcess · 5 unmodified lines | ||
| 218 | 218 | |
| 219 | 219 | m_remotingClient = value; |
| 220 | 220 | |
| 221 | − if (m_remotingClient != null) | |
| 221 | + if ((object)m_remotingClient != null) | |
| 222 | 222 | { |
| 223 | 223 | // Attach events to new instance |
| 224 | 224 | m_remotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished; |
| @@ -245,7 +245,7 @@ namespace GSF.ServiceProcess · 20 unmodified lines | ||
| 245 | 245 | } |
| 246 | 246 | set |
| 247 | 247 | { |
| 248 | − if (value == null) | |
| 248 | + if ((object)value == null) | |
| 249 | 249 | throw new ArgumentNullException("value"); |
| 250 | 250 | |
| 251 | 251 | m_username = value; |
| @@ -267,7 +267,7 @@ namespace GSF.ServiceProcess · 15 unmodified lines | ||
| 267 | 267 | } |
| 268 | 268 | set |
| 269 | 269 | { |
| 270 | − if (value == null) | |
| 270 | + if ((object)value == null) | |
| 271 | 271 | throw new ArgumentNullException("value"); |
| 272 | 272 | |
| 273 | 273 | m_password = value; |
| @@ -327,14 +327,14 @@ namespace GSF.ServiceProcess · 53 unmodified lines | ||
| 327 | 327 | { |
| 328 | 328 | get |
| 329 | 329 | { |
| 330 | − if (m_remotingClient == null) | |
| 330 | + if ((object)m_remotingClient == null) | |
| 331 | 331 | return false; |
| 332 | 332 | |
| 333 | 333 | return m_remotingClient.Enabled; |
| 334 | 334 | } |
| 335 | 335 | set |
| 336 | 336 | { |
| 337 | − if (m_remotingClient != null) | |
| 337 | + if ((object)m_remotingClient != null) | |
| 338 | 338 | m_remotingClient.Enabled = value; |
| 339 | 339 | } |
| 340 | 340 | } |
| @@ -420,8 +420,14 @@ namespace GSF.ServiceProcess · 79 unmodified lines | ||
| 420 | 420 | // Save settings under the specified category. |
| 421 | 421 | ConfigurationFile config = ConfigurationFile.Current; |
| 422 | 422 | CategorizedSettingsElementCollection settings = config.Settings[m_settingsCategory]; |
| 423 | + | |
| 423 | 424 | settings["Username", true].Update(m_username); |
| 424 | 425 | settings["Password", true].Update(m_password); |
| 426 | + | |
| 427 | + settings["Username"].Scope = SettingScope.User; | |
| 428 | + settings["Password"].Scope = SettingScope.User; | |
| 429 | + settings["Password"].Encrypted = true; | |
| 430 | + | |
| 425 | 431 | config.Save(); |
| 426 | 432 | } |
| 427 | 433 | } |
| @@ -441,8 +447,10 @@ namespace GSF.ServiceProcess · 13 unmodified lines | ||
| 441 | 447 | // Load settings from the specified category. |
| 442 | 448 | ConfigurationFile config = ConfigurationFile.Current; |
| 443 | 449 | CategorizedSettingsElementCollection settings = config.Settings[m_settingsCategory]; |
| 444 | − settings.Add("Username", m_username, "Username to be used for authentication with the service."); | |
| 445 | − settings.Add("Password", m_password, "Password to be used for authentication with the service.", true); | |
| 450 | + | |
| 451 | + settings.Add("Username", m_username, "Username to be used for authentication with the service.", false, SettingScope.User); | |
| 452 | + settings.Add("Password", m_password, "Password to be used for authentication with the service.", true, SettingScope.User); | |
| 453 | + | |
| 446 | 454 | Username = settings["Username"].ValueAs(m_username); |
| 447 | 455 | Password = settings["Password"].ValueAs(m_password); |
| 448 | 456 | } |
| @@ -453,17 +461,20 @@ namespace GSF.ServiceProcess · 4 unmodified lines | ||
| 453 | 461 | /// </summary> |
| 454 | 462 | public void Connect() |
| 455 | 463 | { |
| 456 | − if (m_remotingClient == null) | |
| 464 | + if ((object)m_remotingClient == null) | |
| 457 | 465 | throw new InvalidOperationException("RemotingClient property of ClientHelper component is not set"); |
| 458 | 466 | |
| 459 | 467 | m_attemptReconnection = true; |
| 460 | 468 | m_authenticationComplete = false; |
| 461 | − m_remotingClient.Connect(); // Wait for connection. | |
| 469 | + | |
| 470 | + // Wait for connection. | |
| 471 | + m_remotingClient.Connect(); | |
| 462 | 472 | |
| 463 | 473 | while (!m_authenticationComplete && m_remotingClient.Enabled) |
| 464 | 474 | { |
| 475 | + // Wait for authentication. | |
| 465 | 476 | Thread.Sleep(100); |
| 466 | − } // Wait for authentication. | |
| 477 | + } | |
| 467 | 478 | } |
| 468 | 479 | |
| 469 | 480 | /// <summary> |
| @@ -473,7 +484,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines | ||
| 473 | 484 | { |
| 474 | 485 | m_attemptReconnection = false; |
| 475 | 486 | |
| 476 | − if (m_remotingClient != null) | |
| 487 | + if ((object)m_remotingClient != null) | |
| 477 | 488 | m_remotingClient.Disconnect(); |
| 478 | 489 | } |
| 479 | 490 | |
| @@ -485,7 +496,7 @@ namespace GSF.ServiceProcess · 5 unmodified lines | ||
| 485 | 496 | { |
| 486 | 497 | ClientRequest requestInstance = ClientRequest.Parse(request); |
| 487 | 498 | |
| 488 | − if (requestInstance != null) | |
| 499 | + if ((object)requestInstance != null) | |
| 489 | 500 | SendRequest(requestInstance); |
| 490 | 501 | else |
| 491 | 502 | UpdateStatus(UpdateType.Warning, string.Format("Request command \"{0}\" is invalid\r\n\r\n", request)); |
| @@ -507,7 +518,7 @@ namespace GSF.ServiceProcess · 15 unmodified lines | ||
| 507 | 518 | /// <param name="update">Update message received.</param> |
| 508 | 519 | protected virtual void OnReceivedServiceUpdate(UpdateType type, string update) |
| 509 | 520 | { |
| 510 | − if (ReceivedServiceUpdate != null) | |
| 521 | + if ((object)ReceivedServiceUpdate != null) | |
| 511 | 522 | ReceivedServiceUpdate(this, new EventArgs<UpdateType, string>(type, update)); |
| 512 | 523 | } |
| 513 | 524 | |
| @@ -517,7 +528,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines | ||
| 517 | 528 | /// <param name="response"><see cref="ServiceResponse"/> received.</param> |
| 518 | 529 | protected virtual void OnReceivedServiceResponse(ServiceResponse response) |
| 519 | 530 | { |
| 520 | − if (ReceivedServiceResponse != null) | |
| 531 | + if ((object)ReceivedServiceResponse != null) | |
| 521 | 532 | ReceivedServiceResponse(this, new EventArgs<ServiceResponse>(response)); |
| 522 | 533 | } |
| 523 | 534 | |
| @@ -527,7 +538,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines | ||
| 527 | 538 | /// <param name="state">New <see cref="ServiceState"/>.</param> |
| 528 | 539 | protected virtual void OnServiceStateChanged(ObjectState<ServiceState> state) |
| 529 | 540 | { |
| 530 | − if (ServiceStateChanged != null) | |
| 541 | + if ((object)ServiceStateChanged != null) | |
| 531 | 542 | ServiceStateChanged(this, new EventArgs<ObjectState<ServiceState>>(state)); |
| 532 | 543 | } |
| 533 | 544 | |
| @@ -537,7 +548,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines | ||
| 537 | 548 | /// <param name="state">New <see cref="ServiceProcessState"/>.</param> |
| 538 | 549 | protected virtual void OnProcessStateChanged(ObjectState<ServiceProcessState> state) |
| 539 | 550 | { |
| 540 | − if (ProcessStateChanged != null) | |
| 551 | + if ((object)ProcessStateChanged != null) | |
| 541 | 552 | ProcessStateChanged(this, new EventArgs<ObjectState<ServiceProcessState>>(state)); |
| 542 | 553 | } |
| 543 | 554 | |
| @@ -546,7 +557,7 @@ namespace GSF.ServiceProcess · 2 unmodified lines | ||
| 546 | 557 | /// </summary> |
| 547 | 558 | protected virtual void OnAuthenticationSuccess() |
| 548 | 559 | { |
| 549 | − if (AuthenticationSuccess != null) | |
| 560 | + if ((object)AuthenticationSuccess != null) | |
| 550 | 561 | AuthenticationSuccess(this, EventArgs.Empty); |
| 551 | 562 | |
| 552 | 563 | m_authenticationComplete = true; |
| @@ -559,7 +570,7 @@ namespace GSF.ServiceProcess · 6 unmodified lines | ||
| 559 | 570 | { |
| 560 | 571 | CancelEventArgs args = new CancelEventArgs(true); |
| 561 | 572 | |
| 562 | − if (AuthenticationFailure != null) | |
| 573 | + if ((object)AuthenticationFailure != null) | |
| 563 | 574 | AuthenticationFailure(this, args); |
| 564 | 575 | |
| 565 | 576 | // Continue connection attempts if requested. |
| @@ -575,7 +586,7 @@ namespace GSF.ServiceProcess · 9 unmodified lines | ||
| 575 | 586 | /// </summary> |
| 576 | 587 | protected virtual void OnTelnetSessionEstablished() |
| 577 | 588 | { |
| 578 | − if (TelnetSessionEstablished != null) | |
| 589 | + if ((object)TelnetSessionEstablished != null) | |
| 579 | 590 | TelnetSessionEstablished(this, EventArgs.Empty); |
| 580 | 591 | } |
| 581 | 592 | |
| @@ -584,7 +595,7 @@ namespace GSF.ServiceProcess · 2 unmodified lines | ||
| 584 | 595 | /// </summary> |
| 585 | 596 | protected virtual void OnTelnetSessionTerminated() |
| 586 | 597 | { |
| 587 | − if (TelnetSessionTerminated != null) | |
| 598 | + if ((object)TelnetSessionTerminated != null) | |
| 588 | 599 | TelnetSessionTerminated(this, EventArgs.Empty); |
| 589 | 600 | } |
| 590 | 601 | |
| @@ -701,7 +712,7 @@ namespace GSF.ServiceProcess · 110 unmodified lines | ||
| 701 | 712 | { |
| 702 | 713 | ObjectState<ServiceState> state = response.Attachments[0] as ObjectState<ServiceState>; |
| 703 | 714 | |
| 704 | − if (state != null) | |
| 715 | + if ((object)state != null) | |
| 705 | 716 | { |
| 706 | 717 | // Notify change in service state by raising an event. |
| 707 | 718 | OnServiceStateChanged(state); |
| @@ -725,7 +736,7 @@ namespace GSF.ServiceProcess · 17 unmodified lines | ||
| 725 | 736 | { |
| 726 | 737 | ObjectState<ServiceProcessState> state = response.Attachments[0] as ObjectState<ServiceProcessState>; |
| 727 | 738 | |
| 728 | − if (state != null) | |
| 739 | + if ((object)state != null) | |
| 729 | 740 | { |
| 730 | 741 | // Notify change in process state by raising an event. |
| 731 | 742 | OnProcessStateChanged(state); |
| @@ -807,7 +818,7 @@ namespace GSF.ServiceProcess · 75 unmodified lines | ||
| 807 | 818 | if (parts.Length > 1) |
| 808 | 819 | { |
| 809 | 820 | sourceCommand = parts[0].Trim().ToTitleCase(); |
| 810 | − responseSuccess = (string.Compare(parts[1].Trim(), "Success", true) == 0); | |
| 821 | + responseSuccess = (string.Compare(parts[1].Trim(), "Success", StringComparison.OrdinalIgnoreCase) == 0); | |
| 811 | 822 | parseSucceeded = true; |
| 812 | 823 | } |
| 813 | 824 | } |