Enhanced readability of Display related codes
authorcoderhyme <jhyo.kim@samsung.com>
Wed, 28 Jun 2017 06:36:00 +0000 (15:36 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Wed, 28 Jun 2017 06:36:00 +0000 (15:36 +0900)
Change-Id: Ie478ab2f6c1a1aa5d1bb79cce3fa6c8c74732332
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia.Camera/Camera/Camera.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
src/Tizen.Multimedia/Common/Display.cs

index 7b4014b..3824c52 100755 (executable)
@@ -364,15 +364,9 @@ namespace Tizen.Multimedia
 
         private void ReplaceDisplay(Display newDisplay)
         {
-            if (_display != null)
-            {
-                _display.Owner = null;
-            }
+            _display?.SetOwner(null);
             _display = newDisplay;
-            if (_display != null)
-            {
-                _display.Owner = this;
-            }
+            _display?.SetOwner(this);
         }
 
         /// <summary>
@@ -397,17 +391,16 @@ namespace Tizen.Multimedia
             {
                 ValidateState(CameraState.Created);
 
-                if (value != null && value.Owner != null)
+                if (value?.Owner != null)
                 {
                     if (ReferenceEquals(this, value.Owner))
                     {
                         return;
                     }
-                    else
-                    {
-                        throw new ArgumentException("The display has already been assigned to another.");
-                    }
+
+                    throw new ArgumentException("The display has already been assigned to another.");
                 }
+
                 CameraErrorFactory.ThrowIfError(SetDisplay(value), "Failed to set the camera display");
 
                 ReplaceDisplay(value);
index ea85757..363181e 100644 (file)
@@ -353,7 +353,6 @@ namespace Tizen.Multimedia
 
         private PlayerErrorCode SetDisplay(Display display)
         {
-            Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
             if (display == null)
             {
                 Log.Info(PlayerLog.Tag, "set display to none");
@@ -365,15 +364,9 @@ namespace Tizen.Multimedia
 
         private void ReplaceDisplay(Display newDisplay)
         {
-            if (_display != null)
-            {
-                _display.Owner = null;
-            }
+            _display?.SetOwner(null);
             _display = newDisplay;
-            if (_display != null)
-            {
-                _display.Owner = this;
-            }
+            _display?.SetOwner(this);
         }
 
         /// <summary>
@@ -392,25 +385,20 @@ namespace Tizen.Multimedia
             }
             set
             {
-                Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
                 ValidatePlayerState(PlayerState.Idle);
 
-                if (value != null && value.Owner != null)
+                if (value?.Owner != null)
                 {
                     if (ReferenceEquals(this, value.Owner))
                     {
                         return;
                     }
-                    else
-                    {
-                        throw new ArgumentException("The display has already been assigned to another.");
-                    }
-                }
 
+                    throw new ArgumentException("The display has already been assigned to another.");
+                }
                 SetDisplay(value).ThrowIfFailed("Failed to set the display to the player");
 
                 ReplaceDisplay(value);
-                Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
             }
         }
 
index 8c77d94..91360c0 100644 (file)
@@ -86,10 +86,18 @@ namespace Tizen.Multimedia
 
         private DisplayType Type { get; }
 
-        internal object Owner
+        private object _owner;
+
+        internal object Owner => _owner;
+
+        internal void SetOwner(object newOwner)
         {
-            get;
-            set;
+            if (_owner != null && newOwner != null)
+            {
+                throw new ArgumentException("The display has already been assigned to another.");
+            }
+
+            _owner = newOwner;
         }
 
         internal ErrorType ApplyTo<ErrorType>(IDisplayable<ErrorType> target)