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); }
private void ExtractData(XElement complexTypeElement, ComplexType type) { var innerElements = complexTypeElement.Elements(); var sequenceElement = innerElements.SingleOrDefault(e => e.Name.LocalName == "sequence"); if (sequenceElement == null) { throw new Exception($"Не найден элемент sequence для complexType {complexTypeElement}"); } // Get content var content = GetContent(innerElements); type.Content = content; // Get attributes var attributeDescriptions = innerElements.Where(e => e.Name.LocalName == "attribute"); var attributes = attributeDescriptions.Select(a => AttributeValidation.Parse(a)).ToArray(); type.Attributes.AddRange(attributes); }
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))); }
public void AddAttribute(string element, AttributeValidation attribute) { _container.AddAttribute(element, attribute); }
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>()); }
public void Process(XElement attributeElement) { var attribute = AttributeValidation.Parse(attributeElement); }