Added ContainsOnlyOneOf insted of CountExistedKeys

Former-commit-id: b4dcd9ffb1
This commit is contained in:
Максим Багрянцев 2020-05-02 12:41:47 +03:00
parent e2e5ddddb9
commit 56fd0495ab

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace FFMpegCore.FFMPEG.Argument namespace FFMpegCore.FFMPEG.Argument
{ {
@ -102,8 +103,8 @@ public void Add(params Argument[] values)
/// <returns></returns> /// <returns></returns>
public bool ContainsInputOutput() public bool ContainsInputOutput()
{ {
return CountExistedKeys(typeof(InputArgument), typeof(ConcatArgument), typeof(InputPipeArgument)) == 1 && return ContainsOnlyOneOf(typeof(InputArgument), typeof(ConcatArgument), typeof(InputPipeArgument)) &&
CountExistedKeys(typeof(OutputArgument), typeof(OutputPipeArgument)) == 1; ContainsOnlyOneOf(typeof(OutputArgument), typeof(OutputPipeArgument));
} }
/// <summary> /// <summary>
@ -116,14 +117,9 @@ public bool ContainsKey(Type key)
return _args.ContainsKey(key); return _args.ContainsKey(key);
} }
public int CountExistedKeys(params Type[] types) public bool ContainsOnlyOneOf(params Type[] types)
{ {
int count = 0; return types.Count(t => _args.ContainsKey(t)) == 1;
for(int i =0; i < types.Length; i++)
if (_args.ContainsKey(types[i]))
count++;
return count;
} }
public void CopyTo(KeyValuePair<Type, Argument>[] array, int arrayIndex) public void CopyTo(KeyValuePair<Type, Argument>[] array, int arrayIndex)