From dd0bb71ace438188b14a4eec5d8edad2a5771436 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Tue, 16 Oct 2018 00:42:54 +0900 Subject: [PATCH] [Tizen] Cleanup Code (#4080) --- .../Cells/ImageCellRenderer.cs | 1 - Xamarin.Forms.Platform.Tizen/Forms.cs | 4 +- Xamarin.Forms.Platform.Tizen/FormsApplication.cs | 4 +- Xamarin.Forms.Platform.Tizen/GestureDetector.cs | 36 ++--------------- Xamarin.Forms.Platform.Tizen/GestureHandler.cs | 2 +- Xamarin.Forms.Platform.Tizen/Log/Log.cs | 47 ++++++---------------- Xamarin.Forms.Platform.Tizen/Native/Dialog.cs | 1 - Xamarin.Forms.Platform.Tizen/Native/Entry.cs | 11 ++--- Xamarin.Forms.Platform.Tizen/Native/ListView.cs | 10 ++--- Xamarin.Forms.Platform.Tizen/Native/Scroller.cs | 7 +--- Xamarin.Forms.Platform.Tizen/Native/Span.cs | 8 +--- .../NativeValueConverterService.cs | 2 +- Xamarin.Forms.Platform.Tizen/Platform.cs | 6 +-- .../Renderers/MasterDetailContainer.cs | 7 ++-- .../Renderers/NavigationPageRenderer.cs | 6 +-- .../Renderers/VisualElementRenderer.cs | 46 +++++++-------------- Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs | 1 - .../TizenIsolatedStorageFile.cs | 18 ++++----- .../TizenPlatformServices.cs | 6 +-- 19 files changed, 69 insertions(+), 154 deletions(-) diff --git a/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs index dfeeee0..b9865d2 100644 --- a/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Cells/ImageCellRenderer.cs @@ -6,7 +6,6 @@ namespace Xamarin.Forms.Platform.Tizen public class ImageCellRenderer : TextCellRenderer { const int _defaultHeight = 55; - Dictionary _realizedViews = new Dictionary(); public ImageCellRenderer() : this(Device.Idiom == TargetIdiom.Watch ? "1icon_2text" : "default") { diff --git a/Xamarin.Forms.Platform.Tizen/Forms.cs b/Xamarin.Forms.Platform.Tizen/Forms.cs index 7d3b9df..97dfc78 100644 --- a/Xamarin.Forms.Platform.Tizen/Forms.cs +++ b/Xamarin.Forms.Platform.Tizen/Forms.cs @@ -209,10 +209,9 @@ namespace Xamarin.Forms.Platform.Tizen // In .NETCore, AppDomain feature is not supported. // The list of assemblies returned by AppDomain.GetAssemblies() method should be registered manually. // The assembly of the executing application and referenced assemblies of it are added into the list here. - // TODO: AppDomain is comming back in NETStandard2.0. This logic should be changed at that time. TizenPlatformServices.AppDomain.CurrentDomain.RegisterAssemblyRecursively(application.GetType().GetTypeInfo().Assembly); - Device.PlatformServices = new TizenPlatformServices(); ; + Device.PlatformServices = new TizenPlatformServices(); if (Device.info != null) { ((TizenDeviceInfo)Device.info).Dispose(); @@ -233,7 +232,6 @@ namespace Xamarin.Forms.Platform.Tizen }); } - // TODO: We should consider various tizen profiles such as TV, Wearable and so on. string profile = ((TizenDeviceInfo)Device.Info).Profile; if (profile == "mobile") { diff --git a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs index 5999e5f..c8d1442 100644 --- a/Xamarin.Forms.Platform.Tizen/FormsApplication.cs +++ b/Xamarin.Forms.Platform.Tizen/FormsApplication.cs @@ -102,12 +102,12 @@ namespace Xamarin.Forms.Platform.Tizen if (null == MainWindow) { - throw new NullReferenceException("MainWindow is not prepared. This method should be called in OnCreated()."); + throw new InvalidOperationException("MainWindow is not prepared. This method should be called in OnCreated()."); } if (null == application) { - throw new ArgumentNullException("application"); + throw new ArgumentNullException(nameof(application)); } _application = application; Application.Current = application; diff --git a/Xamarin.Forms.Platform.Tizen/GestureDetector.cs b/Xamarin.Forms.Platform.Tizen/GestureDetector.cs index cdf6bd1..896f4b0 100644 --- a/Xamarin.Forms.Platform.Tizen/GestureDetector.cs +++ b/Xamarin.Forms.Platform.Tizen/GestureDetector.cs @@ -11,16 +11,14 @@ namespace Xamarin.Forms.Platform.Tizen { internal class GestureDetector { - IDictionary> _handlerCache = new Dictionary>(); + readonly IDictionary> _handlerCache = new Dictionary>(); readonly IVisualElementRenderer _renderer; GestureLayer _gestureLayer; double _doubleTapTime = 0; double _longTapTime = 0; - int _horizontalSwipeTime = 0; - int _verticalSwipeTime = 0; bool _inputTransparent = false; - bool _isEnabled = true; + bool _isEnabled; View View => _renderer.Element as View; @@ -74,7 +72,7 @@ namespace Xamarin.Forms.Platform.Tizen { foreach (var handler in handlers) { - (handler as GestureHandler).PropertyChanged -= OnGestureRecognizerPropertyChanged; + handler.PropertyChanged -= OnGestureRecognizerPropertyChanged; } } _handlerCache.Clear(); @@ -474,34 +472,6 @@ namespace Xamarin.Forms.Platform.Tizen } } - void OnFlickStarted(EGestureType type, object data) - { - var lineData = (GestureLayer.LineData)data; - _horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp); - _verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp); - OnGestureStarted(type, data); - } - - void OnFlickCompleted(EGestureType type, object data) - { - var lineData = (GestureLayer.LineData)data; - _horizontalSwipeTime = Convert.ToInt32(lineData.HorizontalSwipeTimestamp - _horizontalSwipeTime); - _verticalSwipeTime = Convert.ToInt32(lineData.VerticalSwipeTimestamp - _verticalSwipeTime); - var cache = _handlerCache; - - if (cache.ContainsKey(type)) - { - foreach (var handler in cache[type]) - { - if ((handler.Timeout * 1000) >= _horizontalSwipeTime || - (handler.Timeout * 1000) >= _verticalSwipeTime) - (handler as IGestureController)?.SendCompleted(View, data); - else - (handler as IGestureController)?.SendCanceled(View, data); - } - } - } - #endregion GestureCallback GestureHandler CreateHandler(IGestureRecognizer recognizer) diff --git a/Xamarin.Forms.Platform.Tizen/GestureHandler.cs b/Xamarin.Forms.Platform.Tizen/GestureHandler.cs index d89bea5..52d504e 100644 --- a/Xamarin.Forms.Platform.Tizen/GestureHandler.cs +++ b/Xamarin.Forms.Platform.Tizen/GestureHandler.cs @@ -18,7 +18,7 @@ namespace Xamarin.Forms.Platform.Tizen Recognizer.PropertyChanged += OnRecognizerPropertyChanged; } - public virtual event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangedEventHandler PropertyChanged; protected abstract void OnStarted(View sender, object data); diff --git a/Xamarin.Forms.Platform.Tizen/Log/Log.cs b/Xamarin.Forms.Platform.Tizen/Log/Log.cs index 63305e2..087394f 100644 --- a/Xamarin.Forms.Platform.Tizen/Log/Log.cs +++ b/Xamarin.Forms.Platform.Tizen/Log/Log.cs @@ -8,40 +8,17 @@ namespace Xamarin.Forms.Platform.Tizen /// public static class Log { - static String _tag = "Xamarin"; - - static ILogger _logger = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger(); /// /// Gets or sets the log tag. /// - public static String Tag - { - get - { - return _tag; - } - set - { - _tag = value; - } - } + public static string Tag { get; set; } = "Xamarin"; - /// - /// Gets or sets the logger used to report messages. - /// It's DlogLogger on a Tizen platform, ConsoleLogger on any other. - /// - public static ILogger Logger - { - get - { - return _logger; - } - set - { - _logger = value; - } - } + /// + /// Gets or sets the logger used to report messages. + /// It's DlogLogger on a Tizen platform, ConsoleLogger on any other. + /// + public static ILogger Logger { get; set; } = IsTizen() ? (ILogger)new DlogLogger() : (ILogger)new ConsoleLogger(); public static void Debug(string message, Guardian _ = default(Guardian), @@ -49,7 +26,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Debug(_tag, message, file, func, line); + Logger.Debug(Tag, message, file, func, line); } public static void Debug(string message, @@ -203,7 +180,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Verbose(_tag, message, file, func, line); + Logger.Verbose(Tag, message, file, func, line); } public static void Verbose(string message, @@ -357,7 +334,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Info(_tag, message, file, func, line); + Logger.Info(Tag, message, file, func, line); } public static void Info(string message, @@ -511,7 +488,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Warn(_tag, message, file, func, line); + Logger.Warn(Tag, message, file, func, line); } public static void Warn(string message, @@ -665,7 +642,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Error(_tag, message, file, func, line); + Logger.Error(Tag, message, file, func, line); } public static void Error(string message, @@ -819,7 +796,7 @@ namespace Xamarin.Forms.Platform.Tizen [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) { - _logger.Fatal(_tag, message, file, func, line); + Logger.Fatal(Tag, message, file, func, line); } public static void Fatal(string message, diff --git a/Xamarin.Forms.Platform.Tizen/Native/Dialog.cs b/Xamarin.Forms.Platform.Tizen/Native/Dialog.cs index 668bb64..15f70cd 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Dialog.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Dialog.cs @@ -244,7 +244,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native part = "button2"; break; - case ButtonPosition.Negative: default: part = "button1"; break; diff --git a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs index 1a08aff..27670e3 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Entry.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Entry.cs @@ -12,8 +12,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// public class Entry : EEntry, IMeasurable, IBatchable { - static readonly int s_VariationNormal = 0; - static readonly int s_VariationSignedAndDecimal = 3; + const int VariationNormal = 0; + const int VariationSignedAndDecimal = 3; /// /// Holds the formatted text of the entry. @@ -395,7 +395,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// Keyboard type to be used. void ApplyKeyboard(Keyboard keyboard) { - SetInternalKeyboard(_keyboard = keyboard); + _keyboard = keyboard; + SetInternalKeyboard(keyboard); } /// @@ -414,13 +415,13 @@ namespace Xamarin.Forms.Platform.Tizen.Native SetInputPanelEnabled(true); SetInputPanelLayout(InputPanelLayout.NumberOnly); // InputPanelVariation is used to allow using deciaml point. - InputPanelVariation = s_VariationSignedAndDecimal; + InputPanelVariation = VariationSignedAndDecimal; } else { SetInputPanelEnabled(true); SetInputPanelLayout((InputPanelLayout)keyboard); - InputPanelVariation = s_VariationNormal; + InputPanelVariation = VariationNormal; } } diff --git a/Xamarin.Forms.Platform.Tizen/Native/ListView.cs b/Xamarin.Forms.Platform.Tizen/Native/ListView.cs index 0da3c88..c60c186 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/ListView.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/ListView.cs @@ -134,13 +134,13 @@ namespace Xamarin.Forms.Platform.Tizen.Native /// /// Adds elements to the list and defines its presentation based on Cell type. /// - /// IEnumerable on Cell collection. + /// IEnumerable on Cell collection. /// Cell before which new items will be placed. /// Null value may also be passed as this parameter, which results in appending new items to the end. /// - public void AddSource(IEnumerable _source, Cell beforeCell = null) + public void AddSource(IEnumerable source, Cell beforeCell = null) { - foreach (var data in _source) + foreach (var data in source) { GroupList groupList = data as GroupList; if (groupList != null) @@ -148,7 +148,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native AddGroupItem(groupList, beforeCell); foreach (var item in groupList) { - AddItem(item as Cell, groupList.HeaderContent); + AddItem(item, groupList.HeaderContent); } } else @@ -451,7 +451,7 @@ namespace Xamarin.Forms.Platform.Tizen.Native if (renderer == null) { Log.Error("Cell type is not handled: {0}", cell.GetType()); - throw new ArgumentNullException("Unsupported cell type"); + throw new ArgumentException("Unsupported cell type"); } renderer.SetGroupMode(isGroup); diff --git a/Xamarin.Forms.Platform.Tizen/Native/Scroller.cs b/Xamarin.Forms.Platform.Tizen/Native/Scroller.cs index 57191ff..aef32a4 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Scroller.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Scroller.cs @@ -7,7 +7,6 @@ namespace Xamarin.Forms.Platform.Tizen.Native public class Scroller : EScroller { TaskCompletionSource _animationTaskComplateSource; - SmartEvent _scrollAnimationStart, _scrollAnimationStop; bool _isAnimation = false; public Scroller(EvasObject parent) : base(parent) @@ -17,10 +16,8 @@ namespace Xamarin.Forms.Platform.Tizen.Native protected override void OnRealized() { base.OnRealized(); - _scrollAnimationStart = new SmartEvent(this, RealHandle, "scroll,anim,start"); - _scrollAnimationStop = new SmartEvent(this, RealHandle, "scroll,anim,stop"); - _scrollAnimationStart.On += (s, e) => _isAnimation = true; - _scrollAnimationStop.On += (s, e) => + new SmartEvent(this, RealHandle, "scroll,anim,start").On += (s, e) => _isAnimation = true; + new SmartEvent(this, RealHandle, "scroll,anim,stop").On += (s, e) => { if (_animationTaskComplateSource != null) { diff --git a/Xamarin.Forms.Platform.Tizen/Native/Span.cs b/Xamarin.Forms.Platform.Tizen/Native/Span.cs index 4e32682..6ed930e 100644 --- a/Xamarin.Forms.Platform.Tizen/Native/Span.cs +++ b/Xamarin.Forms.Platform.Tizen/Native/Span.cs @@ -134,17 +134,11 @@ namespace Xamarin.Forms.Platform.Tizen.Native internal string GetMarkupText() { StringBuilder sb = new StringBuilder(); - - sb.AppendFormat(""); - sb.Append(GetDecoratedText()); - sb.Append(""); - return sb.ToString(); } diff --git a/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs b/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs index 72d124d..52919cb 100644 --- a/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs +++ b/Xamarin.Forms.Platform.Tizen/NativeValueConverterService.cs @@ -11,7 +11,7 @@ namespace Xamarin.Forms.Platform.Tizen public bool ConvertTo(object value, Type toType, out object nativeValue) { nativeValue = null; - if (typeof(EObject).IsInstanceOfType(value) && toType.IsAssignableFrom(typeof(View))) + if ((value is EObject) && toType.IsAssignableFrom(typeof(View))) { nativeValue = ((EObject)value).ToView(); return true; diff --git a/Xamarin.Forms.Platform.Tizen/Platform.cs b/Xamarin.Forms.Platform.Tizen/Platform.cs index d7a09f9..2f78f26 100644 --- a/Xamarin.Forms.Platform.Tizen/Platform.cs +++ b/Xamarin.Forms.Platform.Tizen/Platform.cs @@ -86,9 +86,9 @@ namespace Xamarin.Forms.Platform.Tizen bool _disposed; Native.Dialog _pageBusyDialog; int _pageBusyCount; - Naviframe _internalNaviframe; + readonly Naviframe _internalNaviframe; - HashSet _alerts = new HashSet(); + readonly HashSet _alerts = new HashSet(); public event EventHandler RootNativeViewChanged; @@ -120,8 +120,6 @@ namespace Xamarin.Forms.Platform.Tizen public bool HasAlpha { get; set; } - Action BackPressedAction { get; set; } - Task CurrentModalNavigationTask { get; set; } TaskCompletionSource CurrentTaskCompletionSource { get; set; } IPageController CurrentPageController => _navModel.CurrentPage as IPageController; diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailContainer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailContainer.cs index e77fcc1..19ae542 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailContainer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/MasterDetailContainer.cs @@ -2,12 +2,13 @@ namespace Xamarin.Forms.Platform.Tizen.Renderers { - public class MasterDetailContainer : ElmSharp.Box + public class MasterDetailContainer : ElmSharp.Box, IDisposable { - MasterDetailPage _parent; + readonly MasterDetailPage _parent; + readonly bool _isMaster; + VisualElement _childView; bool _disposed; - bool _isMaster; bool _hasAppearedToParent; IPageController PageController => ChildView as IPageController; diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs index 9a91f70..d5ae8a4 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs @@ -469,9 +469,9 @@ namespace Xamarin.Forms.Platform.Tizen void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre) { if (nre.BeforePage == null) - throw new ArgumentNullException("before"); + throw new ArgumentException("BeforePage is null"); if (nre.Page == null) - throw new ArgumentNullException("page"); + throw new ArgumentException("Page is null"); _naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title)); UpdateHasNavigationBar(nre.Page); @@ -494,7 +494,7 @@ namespace Xamarin.Forms.Platform.Tizen EvasObject CreateNavItem(Page page) { - View titleView = NavigationPage.GetTitleView(page) as View; + View titleView = NavigationPage.GetTitleView(page); EvasObject nativeView = null; if (titleView != null) { diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs index 672a6e4..bc3bf74 100644 --- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs @@ -18,26 +18,15 @@ namespace Xamarin.Forms.Platform.Tizen /// public abstract class VisualElementRenderer : IVisualElementRenderer, IEffectControlProvider where TElement : VisualElement { - /// - /// Holds registered element changed handlers. - /// readonly List> _elementChangedHandlers = new List>(); - /// - /// Flags which control status of renderer. - /// - VisualElementRendererFlags _flags = VisualElementRendererFlags.None; - - /// - /// Holds the native view. - /// - EvasObject _view; + readonly Dictionary> _propertyHandlersWithInit = new Dictionary>(); - Dictionary> _propertyHandlersWithInit = new Dictionary>(); + readonly Dictionary _propertyHandlers = new Dictionary(); - Dictionary _propertyHandlers = new Dictionary(); + readonly HashSet _batchedProperties = new HashSet(); - HashSet _batchedProperties = new HashSet(); + VisualElementRendererFlags _flags = VisualElementRendererFlags.None; bool _movedCallbackEnabled = false; @@ -119,13 +108,7 @@ namespace Xamarin.Forms.Platform.Tizen } } - public EvasObject NativeView - { - get - { - return _view; - } - } + public EvasObject NativeView { get; private set; } protected bool IsDisposed => _flags.HasFlag(VisualElementRendererFlags.Disposed); @@ -140,10 +123,6 @@ namespace Xamarin.Forms.Platform.Tizen /// the memory that the was occupying. public void Dispose() { - // This is the reason why I call SendDisappearing() here. - // When OnChildRemove is called first like how it is called in Navigation.PopToRootAsync(), - // you can not controll using SendDisappearing() on the lower class. - (Element as IPageController)?.SendDisappearing(); Dispose(true); GC.SuppressFinalize(this); } @@ -186,7 +165,7 @@ namespace Xamarin.Forms.Platform.Tizen { if (newElement == null) { - throw new ArgumentNullException("newElement"); + throw new ArgumentNullException(nameof(newElement)); } TElement oldElement = Element; @@ -228,7 +207,7 @@ namespace Xamarin.Forms.Platform.Tizen TElement tElement = element as TElement; if (tElement == null) { - throw new ArgumentException("Element is not of type " + typeof(TElement), "Element"); + throw new ArgumentException("Element is not of type " + typeof(TElement), nameof(element)); } SetElement(tElement); } @@ -278,6 +257,11 @@ namespace Xamarin.Forms.Platform.Tizen if (disposing) { + // This is the reason why I call SendDisappearing() here. + // When OnChildRemove is called first like how it is called in Navigation.PopToRootAsync(), + // you can not controll using SendDisappearing() on the lower class. + (Element as IPageController)?.SendDisappearing(); + if (Element != null) { Element.PropertyChanged -= OnElementPropertyChanged; @@ -310,7 +294,7 @@ namespace Xamarin.Forms.Platform.Tizen { NativeView.Deleted -= NativeViewDeleted; NativeView.Unrealize(); - _view = null; + NativeView = null; } if (_customFocusManager.IsValueCreated) @@ -365,8 +349,6 @@ namespace Xamarin.Forms.Platform.Tizen controller.EffectControlProvider = this; } } - - // TODO: handle the event } /// @@ -438,7 +420,7 @@ namespace Xamarin.Forms.Platform.Tizen widget.Focused -= OnFocused; widget.Unfocused -= OnUnfocused; } - _view = control; + NativeView = control; if (NativeView != null) { NativeView.Deleted += NativeViewDeleted; diff --git a/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs b/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs index e042d08..8b77520 100644 --- a/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs +++ b/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs @@ -25,7 +25,6 @@ namespace Xamarin.Forms.Platform.Tizen _dictionary[Device.Styles.ListItemDetailTextStyleKey] = GetStyleByKey(Device.Styles.ListItemDetailTextStyleKey); } - //TODO: need Tizen API to get system values Style GetStyleByKey(string key) { Style style = null; diff --git a/Xamarin.Forms.Platform.Tizen/TizenIsolatedStorageFile.cs b/Xamarin.Forms.Platform.Tizen/TizenIsolatedStorageFile.cs index a1c15be..e1f4674 100644 --- a/Xamarin.Forms.Platform.Tizen/TizenIsolatedStorageFile.cs +++ b/Xamarin.Forms.Platform.Tizen/TizenIsolatedStorageFile.cs @@ -8,7 +8,7 @@ namespace Xamarin.Forms.Platform.Tizen { internal class TizenIsolatedStorageFile : IIsolatedStorageFile { - string _rootPath; + readonly string _rootPath; internal TizenIsolatedStorageFile() { @@ -18,7 +18,7 @@ namespace Xamarin.Forms.Platform.Tizen public void CreateDirectory(string path) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); Directory.CreateDirectory(Path.Combine(_rootPath, path)); } @@ -31,9 +31,9 @@ namespace Xamarin.Forms.Platform.Tizen public void MoveFile(string source, string dest) { if (source == null) - throw new ArgumentNullException("source"); + throw new ArgumentNullException(nameof(source)); if (dest == null) - throw new ArgumentNullException("dest"); + throw new ArgumentNullException(nameof(dest)); File.Move(Path.Combine(_rootPath, source), Path.Combine(_rootPath, dest)); } @@ -41,7 +41,7 @@ namespace Xamarin.Forms.Platform.Tizen public void DeleteFile(string path) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); if (path.Trim().Length == 0) throw new ArgumentException("An empty path is not valid."); @@ -51,7 +51,7 @@ namespace Xamarin.Forms.Platform.Tizen public bool DirectoryExists(string path) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); return Directory.Exists(Path.Combine(_rootPath, path)); } @@ -63,7 +63,7 @@ namespace Xamarin.Forms.Platform.Tizen public bool FileExists(string path) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); return File.Exists(Path.Combine(_rootPath, path)); } @@ -75,7 +75,7 @@ namespace Xamarin.Forms.Platform.Tizen public DateTimeOffset GetLastWriteTime(string path) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); if (path.Trim().Length == 0) throw new ArgumentException("An empty path is not valid."); @@ -104,7 +104,7 @@ namespace Xamarin.Forms.Platform.Tizen public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share) { if (path == null) - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); if (path.Trim().Length == 0) throw new ArgumentException("An empty path is not valid."); diff --git a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs index 247735f..f635b3a 100644 --- a/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs +++ b/Xamarin.Forms.Platform.Tizen/TizenPlatformServices.cs @@ -70,7 +70,7 @@ namespace Xamarin.Forms.Platform.Tizen pt = Device.Idiom == TargetIdiom.TV ? 84 : (Device.Idiom == TargetIdiom.Watch ? 36 : 31); break; default: - throw new ArgumentOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(size)); } return Forms.ConvertToDPFont(pt); } @@ -83,7 +83,7 @@ namespace Xamarin.Forms.Platform.Tizen } TAppControl tAppControl = new TAppControl() { Operation = "%", Uri = uri.AbsoluteUri }; var matchedApplications = TAppControl.GetMatchedApplicationIds(tAppControl); - if (matchedApplications.Count() > 0) + if (matchedApplications.Any()) { TAppControl.SendLaunchRequest(tAppControl); return; @@ -178,7 +178,7 @@ namespace Xamarin.Forms.Platform.Tizen { public static AppDomain CurrentDomain { get; private set; } - List _assemblies; + readonly List _assemblies; static AppDomain() { -- 2.7.4