Browse Source

Added extra Converters for Mobile Devices

Frank van den Bos 1 year ago
parent
commit
88fa1ad4c4

+ 18 - 0
InABox.Mobile/InABox.Mobile.Shared/Converters/DateTimeToStringConverter.cs

@@ -0,0 +1,18 @@
+using System;
+using InABox.Core;
+
+namespace InABox.Mobile
+{
+    public class DateTimeToStringConverter: UtilityConverter<DateTime,String>
+    {
+        
+        public String EmptyText { get; set; }
+        public String FilledText { get; set; }
+
+        protected override String Convert(DateTime value)
+        {
+            return value.IsEmpty() ? EmptyText : FilledText;
+        }
+        
+    }
+}

+ 17 - 0
InABox.Mobile/InABox.Mobile.Shared/Converters/StringArrayToStringConverter.cs

@@ -0,0 +1,17 @@
+using System;
+
+namespace InABox.Mobile
+{
+    public class StringArrayToStringConverter : UtilityConverter<string[], string>
+    {
+        protected override string Convert(string[] value)
+        {
+            return value != null ? String.Join("\n", value) : "";
+        }
+
+        protected override string[] Deconvert(string value)
+        {
+            return value != null ? value.Split('\n') : new String[] { };
+        }
+    }
+}

+ 0 - 18
InABox.Mobile/InABox.Mobile.Shared/Converters/StringToBooleanConverter.cs

@@ -1,7 +1,5 @@
 using System;
 using System;
 using System.ComponentModel;
 using System.ComponentModel;
-using System.Globalization;
-using Xamarin.Forms;
 
 
 namespace InABox.Mobile
 namespace InABox.Mobile
 {
 {
@@ -23,20 +21,4 @@ namespace InABox.Mobile
         }
         }
         
         
     }
     }
-    
-    public class StringWithDefaultValueConverter : IValueConverter
-    {
-        
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            return String.IsNullOrWhiteSpace(value as String)
-                ? parameter
-                : value;
-        }
-
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            throw new NotImplementedException();
-        }
-    }
 }
 }

+ 22 - 0
InABox.Mobile/InABox.Mobile.Shared/Converters/StringWithDefaultValueConverter.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Globalization;
+using Xamarin.Forms;
+
+namespace InABox.Mobile
+{
+    public class StringWithDefaultValueConverter : IValueConverter
+    {
+        
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return String.IsNullOrWhiteSpace(value as String)
+                ? parameter
+                : value;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}