public ForStreamCollection <TCollection> Add <TItem>(TItem item) where TItem : TCollection { var applierType = item.GetType(); if (!AttributeValidation.AttributeTypeEquals(applierType, _restrictedType)) { throw new ForStreamInvalidException(applierType, _restrictedType); } if (Contains(item)) { throw new InvalidOperationException(string.Format("A member '{0}' already exists in the collection.", applierType.Name)); } _collection.Add(item); return(this); }
public ForStreamCollection <TCollection> Merge <TItem>(TItem item, FFmpegMergeOptionType optionType) where TItem : TCollection { var applierType = item.GetType(); if (!AttributeValidation.AttributeTypeEquals(applierType, _restrictedType)) { throw new ForStreamInvalidException(applierType, _restrictedType); } var indexOfItem = IndexOf(item); if (indexOfItem != -1 && optionType == FFmpegMergeOptionType.NewWins) { _collection.RemoveAt(indexOfItem); _collection.Insert(indexOfItem, item); } else if (indexOfItem == -1) { _collection.Add(item); } return(this); }
public void ForStreamAttribute_Verify() { Assert.True(AttributeValidation.AttributeTypeEquals(typeof(ForStreamTestType), typeof(VideoStream))); Assert.False(AttributeValidation.AttributeTypeEquals(typeof(ForStreamTestType), typeof(AudioStream))); }
private void TestAppliesTo <TFilter>(bool iVideo, bool iAudio) where TFilter : IFilter { Assert.True(iVideo == AttributeValidation.AttributeTypeEquals <TFilter, VideoStream>()); Assert.True(iAudio == AttributeValidation.AttributeTypeEquals <TFilter, AudioStream>()); }