Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void ForStreamAttribute_Verify()
        {
            Assert.True(AttributeValidation.AttributeTypeEquals(typeof(ForStreamTestType), typeof(VideoStream)));

            Assert.False(AttributeValidation.AttributeTypeEquals(typeof(ForStreamTestType), typeof(AudioStream)));
        }
Ejemplo n.º 5
0
 public void AddAttribute(string element, AttributeValidation attribute)
 {
     _container.AddAttribute(element, attribute);
 }
Ejemplo n.º 6
0
 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>());
 }
Ejemplo n.º 7
0
 public void Process(XElement attributeElement)
 {
     var attribute = AttributeValidation.Parse(attributeElement);
 }