コード例 #1
0
 /// <summary>
 /// Creates an instance of the class
 /// </summary>
 /// <param name="parent">affected netoffice core</param>
 /// <exception cref="ArgumentNullException">argument is null</exception>
 internal CoreFactories(Core parent)
 {
     if (null == parent)
     {
         throw new ArgumentException("parent");
     }
     Parent              = parent;
     FactoryAssemblies   = new FactoryList();
     DependentAssemblies = new List <DependentAssembly>();
 }
コード例 #2
0
        /// <summary>
        /// Parses the next element in the file stream.
        /// </summary>
        /// <exception cref="FileNotLoadedException">
        /// Thrown if part of the next element has not been downloaded yet.
        /// </exception>
        /// <returns>An asynchronous Task to which will yield the next Element.</returns>
        public async Task <EbmlElement?> ParseNextElement(EbmlElement?parent = null)
        {
            var position = DataAccessor.Position;
            // Throws FileNotLoadedException if the file has not been loaded at the position
            var id = await ParseNextId().ConfigureAwait(false);

            // Throws FileNotLoadedException if the file has not been loaded at the position
            var dataSize = await ParseNextVInt().ConfigureAwait(false);

            var factory = FactoryList.GetValueOrDefault(id.Size);
            var element = factory?.Create(dataSize, position, parent);

            if (element != null)
            {
                return(element);
            }

            if (ShouldLog)
            {
                ConsoleExtension.WriteWarning($"No factory found for element {id.Size:X} at position: {position}");
            }
            DataAccessor.Position = position + dataSize.ByteSize + dataSize.DataSize + id.ByteSize;
            return(null);
        }