Пример #1
0
        /// <summary>
        /// Copies the properties of a <see cref="ContentItem"/>.
        /// </summary>
        /// <param name="source">The source item.</param>
        /// <param name="target">The target item.</param>
        public static void CopyContentItem(ContentItem source, ContentItem target)
        {
            if (source == null)
            throw new ArgumentNullException("source");
              if (target == null)
            throw new ArgumentNullException("target");

              target.Name = source.Name;
              target.Identity = source.Identity;
              foreach (var entry in source.OpaqueData)
            target.OpaqueData.Add(entry.Key, entry.Value);
        }
Пример #2
0
        public void OnBuild(string sourceFile)
        {
            // Make sure the source file is absolute.
            if (!Path.IsPathRooted(sourceFile))
                sourceFile = Path.Combine(Directory.GetCurrentDirectory(), sourceFile);

            // Remove duplicates... keep this new one.
            var previous = _content.FindIndex(e => string.Equals(e.SourceFile, sourceFile, StringComparison.InvariantCultureIgnoreCase));
            if (previous != -1)
                _content.RemoveAt(previous);

            // Create the item for processing later.
            var item = new ContentItem
            {
                SourceFile = sourceFile, 
                Importer = Importer, 
                Processor = Processor,
                ProcessorParams = new OpaqueDataDictionary()
            };
            _content.Add(item);

            // Copy the current processor parameters blind as we
            // will validate and remove invalid parameters during
            // the build process later.
            foreach (var pair in _processorParams)
                item.ProcessorParams.Add(pair.Key, pair.Value);
        }