From 56fd0495ab3f5f147d1594a84cd08ba4e314218d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=91=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=8F=D0=BD=D1=86=D0=B5=D0=B2?= Date: Sat, 2 May 2020 12:41:47 +0300 Subject: [PATCH] Added ContainsOnlyOneOf insted of CountExistedKeys Former-commit-id: b4dcd9ffb13819fd9671e6c60166133aa6702371 --- FFMpegCore/FFMPEG/Argument/ArgumentContainer.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/FFMpegCore/FFMPEG/Argument/ArgumentContainer.cs b/FFMpegCore/FFMPEG/Argument/ArgumentContainer.cs index 03e2014..829b511 100644 --- a/FFMpegCore/FFMPEG/Argument/ArgumentContainer.cs +++ b/FFMpegCore/FFMPEG/Argument/ArgumentContainer.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; namespace FFMpegCore.FFMPEG.Argument { @@ -102,8 +103,8 @@ public void Add(params Argument[] values) /// public bool ContainsInputOutput() { - return CountExistedKeys(typeof(InputArgument), typeof(ConcatArgument), typeof(InputPipeArgument)) == 1 && - CountExistedKeys(typeof(OutputArgument), typeof(OutputPipeArgument)) == 1; + return ContainsOnlyOneOf(typeof(InputArgument), typeof(ConcatArgument), typeof(InputPipeArgument)) && + ContainsOnlyOneOf(typeof(OutputArgument), typeof(OutputPipeArgument)); } /// @@ -116,14 +117,9 @@ public bool ContainsKey(Type key) return _args.ContainsKey(key); } - public int CountExistedKeys(params Type[] types) + public bool ContainsOnlyOneOf(params Type[] types) { - int count = 0; - for(int i =0; i < types.Length; i++) - if (_args.ContainsKey(types[i])) - count++; - - return count; + return types.Count(t => _args.ContainsKey(t)) == 1; } public void CopyTo(KeyValuePair[] array, int arrayIndex)