diff --git a/src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs b/src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs
index 62a77b4b6..d816bf034 100644
--- a/src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs
+++ b/src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs
@@ -54,7 +54,7 @@ private bool CheckAccess()
public virtual void BeginOnUIThread(System.Action action)
{
ValidateDispatcher();
- var dummy = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
+ _ = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
}
///
diff --git a/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/HttpUtility.cs b/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/HttpUtility.cs
index 80e6c430f..8fd3710f4 100644
--- a/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/HttpUtility.cs
+++ b/src/Caliburn.Micro.Platform/Platforms/Xamarin.Forms/HttpUtility.cs
@@ -44,7 +44,6 @@ public override string ToString()
if (count == 0)
return "";
StringBuilder sb = new StringBuilder();
- var keys = this.Keys;
foreach (var key in this.Keys)
{
sb.AppendFormat("{0}={1}&", key, this[key]);
diff --git a/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs b/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs
index 4e4003a1b..7c07982da 100644
--- a/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs
+++ b/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs
@@ -1,5 +1,4 @@
-//
-// Copyright (c) 2012 Tim Heuer
+// Copyright (c) 2012 Tim Heuer
//
// Licensed under the Microsoft Public License (Ms-PL) (the "License");
// you may not use this file except in compliance with the License.
@@ -12,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-//
using System;
using System.Globalization;
@@ -49,8 +47,8 @@ public async static Task GetManifestVisualElementsAsync()
SmallLogoUri = new Uri(string.Format("ms-appx:///{0}", vel.Attribute("Square30x30Logo").Value.Replace(@"\", @"/"))),
BackgroundColorAsString = vel.Attribute("BackgroundColor").Value
}).FirstOrDefault();
-
- if (visualElementNode == null)
+
+ if (visualElementNode == null)
throw new ArgumentNullException("Could not parse the VisualElements from the app manifest.");
return visualElementNode;
@@ -79,7 +77,7 @@ private static Windows.UI.Color ToColor(string hexValue)
// in order to prevent parsing failures
if (String.Equals(hexValue, "transparent", StringComparison.OrdinalIgnoreCase))
return Windows.UI.Colors.Transparent;
-
+
hexValue = hexValue.Replace("#", string.Empty);
// some loose validation (not bullet-proof)
@@ -88,23 +86,14 @@ private static Windows.UI.Color ToColor(string hexValue)
throw new ArgumentException("This does not appear to be a proper hex color number");
}
- byte a = 255;
- byte r = 255;
- byte g = 255;
- byte b = 255;
+ byte a = (hexValue.Length == 8) ? byte.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber) : (byte)255;
- int startPosition = 0;
- // the case where alpha is provided
- if (hexValue.Length == 8)
- {
- a = byte.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber);
- startPosition = 2;
- }
+ int startPosition = (hexValue.Length == 8) ? 2 : 0;
- r = byte.Parse(hexValue.Substring(startPosition, 2), NumberStyles.HexNumber);
- g = byte.Parse(hexValue.Substring(startPosition + 2, 2), NumberStyles.HexNumber);
- b = byte.Parse(hexValue.Substring(startPosition + 4, 2), NumberStyles.HexNumber);
+ byte r = byte.Parse(hexValue.Substring(startPosition, 2), NumberStyles.HexNumber);
+ byte g = byte.Parse(hexValue.Substring(startPosition + 2, 2), NumberStyles.HexNumber);
+ byte b = byte.Parse(hexValue.Substring(startPosition + 4, 2), NumberStyles.HexNumber);
return Windows.UI.Color.FromArgb(a, r, g, b);
}
diff --git a/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs b/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs
index e4892ed13..fef62caeb 100644
--- a/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs
+++ b/src/Caliburn.Micro.Platform/XamlPlatformProvider.cs
@@ -1,4 +1,5 @@
-namespace Caliburn.Micro {
+namespace Caliburn.Micro
+{
using System;
using System.Collections.Generic;
using System.Threading;
@@ -19,7 +20,8 @@
///
/// A implementation for the XAML platfrom.
///
- public class XamlPlatformProvider : IPlatformProvider {
+ public class XamlPlatformProvider : IPlatformProvider
+ {
#if WINDOWS_UWP
private readonly CoreDispatcher dispatcher;
#else
@@ -29,7 +31,8 @@ public class XamlPlatformProvider : IPlatformProvider {
///
/// Initializes a new instance of the class.
///
- public XamlPlatformProvider() {
+ public XamlPlatformProvider()
+ {
#if WINDOWS_UWP
dispatcher = Window.Current.Dispatcher;
#elif AVALONIA
@@ -47,16 +50,19 @@ public XamlPlatformProvider() {
///
/// Indicates whether or not the framework is in design-time mode.
///
- public virtual bool InDesignMode {
+ public virtual bool InDesignMode
+ {
get { return View.InDesignMode; }
}
- private void ValidateDispatcher() {
+ private void ValidateDispatcher()
+ {
if (dispatcher == null)
throw new InvalidOperationException("Not initialized with dispatcher.");
}
- private bool CheckAccess() {
+ private bool CheckAccess()
+ {
#if WINDOWS_UWP
return dispatcher == null || Window.Current != null;
#else
@@ -68,10 +74,11 @@ private bool CheckAccess() {
/// Executes the action on the UI thread asynchronously.
///
/// The action to execute.
- public virtual void BeginOnUIThread(System.Action action) {
+ public virtual void BeginOnUIThread(System.Action action)
+ {
ValidateDispatcher();
#if WINDOWS_UWP
- var dummy = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
+ _ = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
#elif AVALONIA
dispatcher.Post(action);
#else
@@ -84,7 +91,8 @@ public virtual void BeginOnUIThread(System.Action action) {
///
/// The action to execute.
///
- public virtual Task OnUIThreadAsync(Func action) {
+ public virtual Task OnUIThreadAsync(Func action)
+ {
ValidateDispatcher();
#if WINDOWS_UWP
return dispatcher.RunTaskAsync(action);
@@ -100,19 +108,24 @@ public virtual Task OnUIThreadAsync(Func action) {
///
/// The action to execute.
///
- public virtual void OnUIThread(System.Action action) {
+ public virtual void OnUIThread(System.Action action)
+ {
if (CheckAccess())
action();
- else {
+ else
+ {
#if WINDOWS_UWP
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action()).AsTask().Wait();
#else
Exception exception = null;
- System.Action method = () => {
- try {
+ System.Action method = () =>
+ {
+ try
+ {
action();
}
- catch(Exception ex) {
+ catch (Exception ex)
+ {
exception = ex;
}
};
@@ -120,7 +133,7 @@ public virtual void OnUIThread(System.Action action) {
dispatcher.Invoke(method);
if (exception != null)
- throw new System.Reflection.TargetInvocationException("An error occurred while dispatching a call to the UI Thread", exception);
+ throw new System.Reflection.TargetInvocationException("An error occurred while dispatching a call to the UI Thread", exception);
#endif
}
}
@@ -138,7 +151,8 @@ public virtual void OnUIThread(System.Action action) {
/// The WindowManager marks that element as a framework-created element so that it can determine what it created vs. what was intended by the developer.
/// Calling GetFirstNonGeneratedView allows the framework to discover what the original element was.
///
- public virtual object GetFirstNonGeneratedView(object view) {
+ public virtual object GetFirstNonGeneratedView(object view)
+ {
return View.GetFirstNonGeneratedView(view);
}
@@ -158,9 +172,11 @@ public virtual object GetFirstNonGeneratedView(object view) {
///
/// The view.
/// The handler.
- public virtual void ExecuteOnFirstLoad(object view, Action