SEBWIN-219: Used awesome new C# language feature for type checks.
This commit is contained in:
		
							parent
							
								
									24c5ea3ba9
								
							
						
					
					
						commit
						ea97930033
					
				
					 10 changed files with 40 additions and 40 deletions
				
			
		|  | @ -103,9 +103,9 @@ namespace SafeExamBrowser.Core.Communication | |||
| 
 | ||||
| 				if (IsAuthorized(message?.CommunicationToken)) | ||||
| 				{ | ||||
| 					if (message is SimpleMessage) | ||||
| 					if (message is SimpleMessage simpleMessage) | ||||
| 					{ | ||||
| 						response = OnReceive((message as SimpleMessage).Purport); | ||||
| 						response = OnReceive(simpleMessage.Purport); | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
|  |  | |||
|  | @ -15,14 +15,14 @@ namespace SafeExamBrowser.Core.Logging | |||
| 	{ | ||||
| 		public string Format(ILogContent content) | ||||
| 		{ | ||||
| 			if (content is ILogText) | ||||
| 			if (content is ILogText text) | ||||
| 			{ | ||||
| 				return (content as ILogText).Text; | ||||
| 				return text.Text; | ||||
| 			} | ||||
| 
 | ||||
| 			if (content is ILogMessage) | ||||
| 			if (content is ILogMessage message) | ||||
| 			{ | ||||
| 				return FormatLogMessage(content as ILogMessage); | ||||
| 				return FormatLogMessage(message); | ||||
| 			} | ||||
| 
 | ||||
| 			throw new NotImplementedException($"The default formatter is not yet implemented for log content of type {content.GetType()}!"); | ||||
|  |  | |||
|  | @ -93,9 +93,9 @@ namespace SafeExamBrowser.UserInterface.Classic | |||
| 
 | ||||
| 		private void InitializeBrowserWindow(IBrowserControl browserControl) | ||||
| 		{ | ||||
| 			if (browserControl is System.Windows.Forms.Control) | ||||
| 			if (browserControl is System.Windows.Forms.Control control) | ||||
| 			{ | ||||
| 				BrowserControlHost.Child = browserControl as System.Windows.Forms.Control; | ||||
| 				BrowserControlHost.Child = control; | ||||
| 			} | ||||
| 
 | ||||
| 			Closing += (o, args) => closing?.Invoke(); | ||||
|  |  | |||
|  | @ -83,9 +83,9 @@ namespace SafeExamBrowser.UserInterface.Classic.Controls | |||
| 
 | ||||
| 			foreach (var child in LayoutsStackPanel.Children) | ||||
| 			{ | ||||
| 				if (child is KeyboardLayoutButton) | ||||
| 				if (child is KeyboardLayoutButton keyboardLayoutButton) | ||||
| 				{ | ||||
| 					(child as KeyboardLayoutButton).IsCurrent = false; | ||||
| 					keyboardLayoutButton.IsCurrent = false; | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,25 +29,25 @@ namespace SafeExamBrowser.UserInterface.Classic | |||
| 
 | ||||
| 		public void AddApplication(IApplicationButton button) | ||||
| 		{ | ||||
| 			if (button is UIElement) | ||||
| 			if (button is UIElement uiElement) | ||||
| 			{ | ||||
| 				ApplicationStackPanel.Children.Add(button as UIElement); | ||||
| 				ApplicationStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		public void AddNotification(INotificationButton button) | ||||
| 		{ | ||||
| 			if (button is UIElement) | ||||
| 			if (button is UIElement uiElement) | ||||
| 			{ | ||||
| 				NotificationStackPanel.Children.Add(button as UIElement); | ||||
| 				NotificationStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		public void AddSystemControl(ISystemControl control) | ||||
| 		{ | ||||
| 			if (control is UIElement) | ||||
| 			if (control is UIElement uiElement) | ||||
| 			{ | ||||
| 				SystemControlStackPanel.Children.Add(control as UIElement); | ||||
| 				SystemControlStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | @ -82,9 +82,9 @@ namespace SafeExamBrowser.UserInterface.Classic | |||
| 		{ | ||||
| 			foreach (var child in SystemControlStackPanel.Children) | ||||
| 			{ | ||||
| 				if (child is ISystemControl) | ||||
| 				if (child is ISystemControl systemControl) | ||||
| 				{ | ||||
| 					(child as ISystemControl).Close(); | ||||
| 					systemControl.Close(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
|  | @ -15,14 +15,14 @@ namespace SafeExamBrowser.UserInterface.Classic.Utilities | |||
| 	{ | ||||
| 		public string Format(ILogContent content) | ||||
| 		{ | ||||
| 			if (content is ILogText) | ||||
| 			if (content is ILogText text) | ||||
| 			{ | ||||
| 				return (content as ILogText).Text; | ||||
| 				return text.Text; | ||||
| 			} | ||||
| 
 | ||||
| 			if (content is ILogMessage) | ||||
| 			if (content is ILogMessage message) | ||||
| 			{ | ||||
| 				return FormatLogMessage(content as ILogMessage); | ||||
| 				return FormatLogMessage(message); | ||||
| 			} | ||||
| 
 | ||||
| 			throw new NotImplementedException($"The runtime window formatter is not yet implemented for log content of type {content.GetType()}!"); | ||||
|  |  | |||
|  | @ -33,13 +33,13 @@ namespace SafeExamBrowser.UserInterface.Classic.ViewModels | |||
| 
 | ||||
| 		public void Notify(ILogContent content) | ||||
| 		{ | ||||
| 			if (content is ILogText) | ||||
| 			if (content is ILogText text) | ||||
| 			{ | ||||
| 				AppendLogText(content as ILogText); | ||||
| 				AppendLogText(text); | ||||
| 			} | ||||
| 			else if (content is ILogMessage) | ||||
| 			else if (content is ILogMessage message) | ||||
| 			{ | ||||
| 				AppendLogMessage(content as ILogMessage); | ||||
| 				AppendLogMessage(message); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
|  |  | |||
|  | @ -91,9 +91,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 | |||
| 
 | ||||
| 		private void InitializeBrowserWindow(IBrowserControl browserControl) | ||||
| 		{ | ||||
| 			if (browserControl is System.Windows.Forms.Control) | ||||
| 			if (browserControl is System.Windows.Forms.Control control) | ||||
| 			{ | ||||
| 				BrowserControlHost.Child = browserControl as System.Windows.Forms.Control; | ||||
| 				BrowserControlHost.Child = control; | ||||
| 			} | ||||
| 
 | ||||
| 			Closing += (o, args) => closing?.Invoke(); | ||||
|  |  | |||
|  | @ -29,25 +29,25 @@ namespace SafeExamBrowser.UserInterface.Windows10 | |||
| 
 | ||||
| 		public void AddApplication(IApplicationButton button) | ||||
| 		{ | ||||
| 			if (button is UIElement) | ||||
| 			if (button is UIElement uiElement) | ||||
| 			{ | ||||
| 				ApplicationStackPanel.Children.Add(button as UIElement); | ||||
| 				ApplicationStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		public void AddNotification(INotificationButton button) | ||||
| 		{ | ||||
| 			if (button is UIElement) | ||||
| 			if (button is UIElement uiElement) | ||||
| 			{ | ||||
| 				NotificationStackPanel.Children.Add(button as UIElement); | ||||
| 				NotificationStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		public void AddSystemControl(ISystemControl control) | ||||
| 		{ | ||||
| 			if (control is UIElement) | ||||
| 			if (control is UIElement uiElement) | ||||
| 			{ | ||||
| 				SystemControlStackPanel.Children.Add(control as UIElement); | ||||
| 				SystemControlStackPanel.Children.Add(uiElement); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | @ -82,9 +82,9 @@ namespace SafeExamBrowser.UserInterface.Windows10 | |||
| 		{ | ||||
| 			foreach (var child in SystemControlStackPanel.Children) | ||||
| 			{ | ||||
| 				if (child is ISystemControl) | ||||
| 				if (child is ISystemControl systemControl) | ||||
| 				{ | ||||
| 					(child as ISystemControl).Close(); | ||||
| 					systemControl.Close(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
|  | @ -33,13 +33,13 @@ namespace SafeExamBrowser.UserInterface.Windows10.ViewModels | |||
| 
 | ||||
| 		public void Notify(ILogContent content) | ||||
| 		{ | ||||
| 			if (content is ILogText) | ||||
| 			if (content is ILogText text) | ||||
| 			{ | ||||
| 				AppendLogText(content as ILogText); | ||||
| 				AppendLogText(text); | ||||
| 			} | ||||
| 			else if (content is ILogMessage) | ||||
| 			else if (content is ILogMessage message) | ||||
| 			{ | ||||
| 				AppendLogMessage(content as ILogMessage); | ||||
| 				AppendLogMessage(message); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 dbuechel
						dbuechel