summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs')
-rw-r--r--Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs83
1 files changed, 83 insertions, 0 deletions
diff --git a/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs b/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs
new file mode 100644
index 0000000..1b813a4
--- /dev/null
+++ b/Xamarin.Forms.ControlGallery.MacOS/NativeServices.cs
@@ -0,0 +1,83 @@
+´╗┐using System;
+using System.IO;
+using Xamarin.Forms;
+using Xamarin.Forms.ControlGallery.MacOS;
+using Xamarin.Forms.Controls;
+using Xamarin.Forms.Platform.MacOS;
+
+[assembly: Dependency(typeof(TestCloudService))]
+[assembly: Dependency(typeof(StringProvider))]
+[assembly: Dependency(typeof(CacheService))]
+[assembly: ExportRenderer(typeof(DisposePage), typeof(DisposePageRenderer))]
+[assembly: ExportRenderer(typeof(DisposeLabel), typeof(DisposeLabelRenderer))]
+
+namespace Xamarin.Forms.ControlGallery.MacOS
+{
+ public class CacheService : ICacheService
+ {
+ public void ClearImageCache()
+ {
+ var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+ var cache = Path.Combine(documents, ".config", ".isolated-storage", "ImageLoaderCache");
+ foreach (var file in Directory.GetFiles(cache))
+ {
+ File.Delete(file);
+ }
+ }
+ }
+
+ public class DisposePageRenderer : PageRenderer
+ {
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ ((DisposePage)Element).SendRendererDisposed();
+ }
+ base.Dispose(disposing);
+
+ }
+ }
+
+ public class DisposeLabelRenderer : LabelRenderer
+ {
+ protected override void Dispose(bool disposing)
+ {
+
+ if (disposing)
+ {
+ ((DisposeLabel)Element).SendRendererDisposed();
+ }
+ base.Dispose(disposing);
+ }
+ }
+
+ public class StringProvider : IStringProvider
+ {
+ public string CoreGalleryTitle
+ {
+ get { return "iOS Core Gallery"; }
+ }
+ }
+
+ public class TestCloudService : ITestCloudService
+ {
+ public bool IsOnTestCloud()
+ {
+ var isInTestCloud = Environment.GetEnvironmentVariable("XAMARIN_TEST_CLOUD");
+
+ return isInTestCloud != null && isInTestCloud.Equals("1");
+ }
+
+ public string GetTestCloudDeviceName()
+ {
+ return Environment.GetEnvironmentVariable("XTC_DEVICE_NAME");
+ }
+
+ public string GetTestCloudDevice()
+ {
+ return Environment.GetEnvironmentVariable("XTC_DEVICE");
+ }
+ }
+}
+