示例#1
0
        public Boolean Add(String filename, Type importerType, Type processorType)
        {
            filename = Path.GetFullPath(filename);

            if (!File.Exists(filename))
            {
                throw new FileNotFoundException(filename);
            }

            String baseName;

            if (_overrideContentDirectory != null)
            {
                if (!filename.StartsWith(_overrideContentDirectory))
                {
                    throw new ContentEngineException("File '{0}' is outside of the defined " +
                                                     "content directory, '{1}'.", filename,
                                                     OutputDirectory);
                }

                baseName = filename.Substring(_overrideContentDirectory.Length + 1);
            }
            else
            {
                String directory = FindNearestContentProjectDirectory(filename);
                baseName = filename.Substring(directory.Length + 1);
            }

            if (_stripFileExtensions)
            {
                baseName = Path.Combine(Path.GetDirectoryName(baseName),
                                        Path.GetFileNameWithoutExtension(baseName));
            }

            QueuedContentFile q = new QueuedContentFile(filename, baseName, importerType, processorType);

            _files.Add(q.Filename, q);

            if (ItemAdded != null)
            {
                ItemAdded(q);
            }

            return(true);
        }
示例#2
0
        public Boolean Add(String filename, Type importerType, Type processorType)
        {
            filename = Path.GetFullPath(filename);

            if (!File.Exists(filename)) throw new FileNotFoundException(filename);

            String baseName;
            if (_overrideContentDirectory != null)
            {
                if (!filename.StartsWith(_overrideContentDirectory))
                {
                    throw new ContentEngineException("File '{0}' is outside of the defined " +
                                                     "content directory, '{1}'.", filename,
                                                     OutputDirectory);
                }

                baseName = filename.Substring(_overrideContentDirectory.Length + 1);
            }
            else
            {
                String directory = FindNearestContentProjectDirectory(filename);
                baseName = filename.Substring(directory.Length + 1);
            }

            if (_stripFileExtensions) baseName = Path.Combine(Path.GetDirectoryName(baseName),
                                                              Path.GetFileNameWithoutExtension(baseName));

            QueuedContentFile q = new QueuedContentFile(filename, baseName, importerType, processorType);

            _files.Add(q.Filename, q);

            if (ItemAdded != null) ItemAdded(q);

            return true;
        }