[Multimedia] Added paramName to every ValidateEnum call. (#83)
authorcoderhyme <jhyo.kim@samsung.com>
Mon, 29 Jan 2018 01:49:59 +0000 (10:49 +0900)
committerGitHub <noreply@github.com>
Mon, 29 Jan 2018 01:49:59 +0000 (10:49 +0900)
This is used in the ArgumentException constructor which is thrown in the method.

Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia.Camera/Camera/CameraDisplaySettings.cs
src/Tizen.Multimedia.Camera/Camera/CameraSettings.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerDisplaySettings.cs
src/Tizen.Multimedia.MediaPlayer/Player/StreamInfo.cs
src/Tizen.Multimedia.Vision/MediaVision/BarcodeDetectionConfiguration.cs
src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerationConfiguration.cs
src/Tizen.Multimedia.Vision/MediaVision/BarcodeGenerator.cs
src/Tizen.Multimedia.Vision/MediaVision/BarcodeImageConfiguration.cs
src/Tizen.Multimedia.Vision/MediaVision/FaceRecognitionConfiguration.cs
src/Tizen.Multimedia/Common.Internal/ValdiationUtil.cs

index 31788ae..041bb85 100755 (executable)
@@ -56,7 +56,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraDisplayMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraDisplayMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetMode(_camera.GetHandle(), value),
                     "Failed to set camera display mode.");
             }
@@ -111,7 +112,7 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(Rotation), value);
+                ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
 
                 CameraErrorFactory.ThrowIfError(Native.SetRotation(_camera.GetHandle(), value),
                     "Failed to set display rotation.");
index 4cdb384..d98d7f3 100755 (executable)
@@ -130,7 +130,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetAutoFocusMode(_camera.GetHandle(), value),
                     "Failed to set camera autofocus mode.");
             }
@@ -292,7 +293,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetExposureMode(_camera.GetHandle(), value),
                     "Failed to set camera exposure mode.");
             }
@@ -386,7 +388,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value);
+                ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetWhitebalance(_camera.GetHandle(), value),
                     "Failed to set camera whitebalance.");
             }
@@ -412,7 +415,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value);
+                ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetIso(_camera.GetHandle(), value),
                     "Failed to set camera Iso level.");
             }
@@ -465,7 +469,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraFps), value);
+                ValidationUtil.ValidateEnum(typeof(CameraFps), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetPreviewFps(_camera.GetHandle(), value),
                     "Failed to set preview fps.");
             }
@@ -533,7 +538,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
+                ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(SetPreviewPixelFormat(_camera.GetHandle(), value),
                     "Failed to set preview format.");
             }
@@ -583,7 +589,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
+                ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(SetCaptureFormat(_camera.GetHandle(), value),
                     "Failed to set capture format.");
             }
@@ -658,7 +665,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetTheaterMode(_camera.GetHandle(), value),
                     "Failed to set camera theater mode.");
             }
@@ -682,7 +690,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetEffect(_camera.GetHandle(), value),
                     "Failed to set camera effect.");
             }
@@ -706,7 +715,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetSceneMode(_camera.GetHandle(), value),
                     "Failed to set camera scene mode.");
             }
@@ -730,7 +740,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetFlashMode(_camera.GetHandle(), value),
                     "Failed to set camera flash mode.");
             }
@@ -770,7 +781,7 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(Rotation), value);
+                ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
 
                 CameraErrorFactory.ThrowIfError(Native.SetStreamRotation(_camera.GetHandle(), value),
                     "Failed to set camera stream rotation.");
@@ -825,7 +836,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value);
+                ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetHdrMode(_camera.GetHandle(), value),
                     "Failed to set camera hdr mode.");
             }
@@ -909,7 +921,7 @@ namespace Tizen.Multimedia
         {
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraPtzType), value);
+                ValidationUtil.ValidateEnum(typeof(CameraPtzType), value, nameof(value));
 
                 CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
                     "Failed to set camera ptz type.");
@@ -927,6 +939,7 @@ namespace Tizen.Multimedia
         public void SetPan(CameraPtzMoveType type, int panStep)
         {
             ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
+
             CameraErrorFactory.ThrowIfError(Native.SetPan(_camera.GetHandle(), type, panStep),
                 "Failed to set the camera pan type.");
         }
@@ -1152,7 +1165,8 @@ namespace Tizen.Multimedia
 
             set
             {
-                ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value);
+                ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value, nameof(value));
+
                 CameraErrorFactory.ThrowIfError(Native.SetTagOrientation(_camera.GetHandle(), value),
                     "Failed to set camera tag orientation.");
             }
index e2a4742..39f2e81 100644 (file)
@@ -158,7 +158,7 @@ namespace Tizen.Multimedia
             {
                 ValidateNotDisposed();
 
-                ValidationUtil.ValidateEnum(typeof(AudioLatencyMode), value);
+                ValidationUtil.ValidateEnum(typeof(AudioLatencyMode), value, nameof(value));
 
                 NativePlayer.SetAudioLatencyMode(Handle, value).
                     ThrowIfFailed(this, "Failed to set the audio latency mode of the player");
index 6ae5419..971ecb0 100644 (file)
@@ -71,7 +71,7 @@ namespace Tizen.Multimedia
             }
             set
             {
-                ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
+                ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value, nameof(value));
 
                 Native.SetMode(Player.Handle, value).
                     ThrowIfFailed(Player, "Failed to set display mode");
@@ -125,7 +125,7 @@ namespace Tizen.Multimedia
             }
             set
             {
-                ValidationUtil.ValidateEnum(typeof(Rotation), value);
+                ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(value));
 
                 Native.SetRotation(Player.Handle, value).
                     ThrowIfFailed(Player, "Failed to set the rotation state of the display");
index a38079f..f1066b0 100644 (file)
@@ -353,7 +353,7 @@ namespace Tizen.Multimedia
         {
             Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
-            ValidationUtil.ValidateEnum(typeof(StreamMetadataKey), key);
+            ValidationUtil.ValidateEnum(typeof(StreamMetadataKey), key, nameof(key));
 
             IntPtr ptr = IntPtr.Zero;
 
index 3868c21..4e4b041 100755 (executable)
@@ -50,7 +50,8 @@ namespace Tizen.Multimedia.Vision
             }
             set
             {
-                ValidationUtil.ValidateEnum(typeof(BarcodeDetectionTarget), value);
+                ValidationUtil.ValidateEnum(typeof(BarcodeDetectionTarget), value, nameof(value));
+
                 Set(KeyAttrTarget, (int)value);
             }
         }
index dea0603..aaf7f79 100755 (executable)
@@ -53,7 +53,8 @@ namespace Tizen.Multimedia.Vision
             }
             set
             {
-                ValidationUtil.ValidateEnum(typeof(Visibility), value);
+                ValidationUtil.ValidateEnum(typeof(Visibility), value, nameof(value));
+
                 Set(KeyTextAttr, (int)value);
             }
         }
index 6533de5..03038bb 100755 (executable)
@@ -39,7 +39,7 @@ namespace Tizen.Multimedia.Vision
                 throw new ArgumentNullException(nameof(message));
             }
 
-            ValidationUtil.ValidateEnum(typeof(BarcodeType), type);
+            ValidationUtil.ValidateEnum(typeof(BarcodeType), type, nameof(type));
 
             MediaVisionSource source = new MediaVisionSource();
             try
@@ -197,7 +197,7 @@ namespace Tizen.Multimedia.Vision
                 throw new ArgumentNullException(nameof(imageConfig));
             }
 
-            ValidationUtil.ValidateEnum(typeof(BarcodeType), type);
+            ValidationUtil.ValidateEnum(typeof(BarcodeType), type, nameof(type));
 
             InteropBarcode.GenerateImage(EngineConfiguration.GetHandle(config), message,
                 imageConfig.Width, imageConfig.Height, type, qrMode, qrEcc, qrVersion,
index e82f109..410cf44 100755 (executable)
@@ -66,7 +66,7 @@ namespace Tizen.Multimedia.Vision
                 throw new ArgumentNullException(nameof(path));
             }
 
-            ValidationUtil.ValidateEnum(typeof(BarcodeImageFormat), imageFormat);
+            ValidationUtil.ValidateEnum(typeof(BarcodeImageFormat), imageFormat, nameof(imageFormat));
 
             Size = size;
             Path = path;
index c599357..9131053 100755 (executable)
@@ -50,7 +50,8 @@ namespace Tizen.Multimedia.Vision
             }
             set
             {
-                ValidationUtil.ValidateEnum(typeof(FaceRecognitionModelType), value);
+                ValidationUtil.ValidateEnum(typeof(FaceRecognitionModelType), value, nameof(value));
+
                 Set(KeyModelType, (int)value);
             }
         }
index b2b7bf6..96507c2 100644 (file)
@@ -21,14 +21,6 @@ namespace Tizen.Multimedia
 {
     internal static class ValidationUtil
     {
-        internal static void ValidateEnum(Type enumType, object value)
-        {
-            if (!Enum.IsDefined(enumType, value))
-            {
-                throw new ArgumentException($"Invalid { enumType.Name } value : { value }");
-            }
-        }
-
         internal static void ValidateEnum(Type enumType, object value, string paramName)
         {
             if (!Enum.IsDefined(enumType, value))