Beispiel #1
0
        public SnippetItem(string source)
            : this()
        {
            BuildExceptions.PathMustExist(source, "source");

            _source = new BuildDirectoryPath(source);
        }
Beispiel #2
0
        public TokenContent(string contentFile)
            : this()
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            _contentFile = new BuildFilePath(contentFile);
        }
        public virtual void Configure(BuildGroup buildGroup,
                                      string sourceFile, string destFile)
        {
            BuildExceptions.NotNull(buildGroup, "buildGroup");
            BuildExceptions.PathMustExist(sourceFile, "sourceFile");
            BuildExceptions.NotNullNotEmpty(destFile, "destFile");

            if (this.IsInitialized == false)
            {
                throw new BuildException("The configurator is not initialized.");
            }
            if (_dicConfigMap == null || _configContent == null)
            {
                throw new BuildException("There is not initialization.");
            }

            _group      = buildGroup;
            _sourceFile = sourceFile;
            _destFile   = destFile;
            string destDir = Path.GetDirectoryName(destFile);

            if (Directory.Exists(destDir) == false)
            {
                Directory.CreateDirectory(destDir);
            }
        }
Beispiel #4
0
        public void Load(string contentFile)
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            _contentFile = new BuildFilePath(contentFile);

            this.Load();
        }
Beispiel #5
0
        protected ProjectRunner(string projectFile, LoggerVerbosity verbosity)
        {
            BuildExceptions.PathMustExist(projectFile, "projectFile");

            _verbosity   = verbosity;
            _projectFile = projectFile;
            _properties  = new BuildProperties();
        }
Beispiel #6
0
        public override ConceptualContent Read(string contentFile)
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            _contentDir = Path.GetDirectoryName(contentFile);

            return(null);
        }
Beispiel #7
0
        public ReferenceDocument(string documentFile,
                                 ReferenceDocumentType documentType)
        {
            BuildExceptions.PathMustExist(documentFile, "documentFile");

            _documentFile = documentFile;
            _documentType = documentType;
        }
Beispiel #8
0
        public SnippetItem(string source, string itemId)
            : this()
        {
            BuildExceptions.PathMustExist(source, "source");

            if (!String.IsNullOrEmpty(itemId))
            {
                _itemId = itemId;
            }
            _source = new BuildDirectoryPath(source);
        }
        public ConceptualContent(string contentFile, string contentDir)
            : this()
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            if (String.IsNullOrEmpty(contentDir))
            {
                contentDir = Path.GetDirectoryName(contentFile);
            }

            _contentFile = new BuildFilePath(contentFile);
            _contentDir  = new BuildDirectoryPath(contentDir);
        }
Beispiel #10
0
        public SharedContent(string contentName, string contentFile)
            : this()
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            _contentFile = new BuildFilePath(contentFile);
            if (!String.IsNullOrEmpty(contentName))
            {
                _contentName = contentName;
            }
            else
            {
                _contentName = Path.GetFileNameWithoutExtension(contentFile);
            }
        }
Beispiel #11
0
        public bool Register(string path, bool recursive)
        {
            BuildExceptions.PathMustExist(path, "path");

            // To make matching easier, we terminate all path with backslash...
            if (!path.EndsWith("\\"))
            {
                path += "\\";
            }

            if (_registeredPaths.ContainsKey(path))
            {
                return(false);
            }

            _registeredPaths.Add(path, recursive);

            return(true);
        }
        public void Configure(ReferenceGroup group, string sourceFile,
                              string destFile)
        {
            BuildExceptions.NotNull(group, "group");
            BuildExceptions.PathMustExist(sourceFile, "sourceFile");
            BuildExceptions.NotNullNotEmpty(destFile, "destFile");

            if (this.IsInitialized == false)
            {
                throw new BuildException(
                          "The reference filter configurator is not initialized.");
            }

            _group      = group;
            _sourceFile = sourceFile;
            _destFile   = destFile;

            string destDir = Path.GetDirectoryName(destFile);

            if (Directory.Exists(destDir) == false)
            {
                Directory.CreateDirectory(destDir);
            }

            if (this.IsInitialized == false || String.IsNullOrEmpty(_sourceFile) ||
                String.IsNullOrEmpty(_destFile))
            {
                return;
            }

            XmlDocument document = new XmlDocument();

            document.Load(_sourceFile);

            XPathNavigator    navigator = document.CreateNavigator();
            XPathNodeIterator iterator  = navigator.Select("//SandcastleItem");

            int nodeCount = iterator.Count;

            XPathNavigator[] nodeNavigators = new XPathNavigator[iterator.Count];
            for (int i = 0; i < nodeNavigators.Length; i++)
            {
                iterator.MoveNext();
                nodeNavigators[i] = iterator.Current.Clone();
            }

            string           configKeyword = null;
            ConfiguratorItem configItem    = null;

            for (int i = 0; i < nodeCount; i++)
            {
                XPathNavigator nodeNavigator = nodeNavigators[i];
                configKeyword = nodeNavigator.GetAttribute("name", String.Empty);
                if (String.IsNullOrEmpty(configKeyword))
                {
                    continue;
                }

                configItem = _configContent[configKeyword];
                if (configItem != null)
                {
                    configItem.Execute(nodeNavigator);
                }
            }

            this.ApplyContents(document);

            document.Save(_destFile);
        }
        public bool WritePlatformFile(BuildContext context, string apiVersionsDir)
        {
            BuildExceptions.NotNull(context, "context");
            BuildExceptions.PathMustExist(apiVersionsDir, "apiVersionsDir");
            Debug.Assert(_sourceIndex >= 0, "The platform source index is not set");
            //Debug.Assert(_groupIndex >= 0, "The platform group index is not set");
            Debug.Assert(_listSources != null && _listSources.Count != 0,
                         "The platform does not contain any version source.");

            BuildLogger logger = context.Logger;

            if (_sourceIndex < 0)
            {
                if (logger != null)
                {
                    logger.WriteLine("The platform source index is not set.",
                                     BuildLoggerLevel.Error);
                }

                return(false);
            }

            if (_listSources == null || _listSources.Count == 0)
            {
                if (logger != null)
                {
                    logger.WriteLine("The platform does not contain any version source.",
                                     BuildLoggerLevel.Error);
                }

                return(false);
            }

            bool isSuccessful = true;

            string platformFile = null;

            // If there is a group index...
            if (_groupIndex >= 0)
            {
                // We write platform filter file name like ApiPlatform1a.xml,
                // ApiPlatform1b.xml, ApiPlatform1c.xml etc
                // "97" is the integer value of the letter "a".
                platformFile = Path.Combine(context.WorkingDirectory,
                                            String.Format("ApiPlatform{0}{1}.xml", _groupIndex,
                                                          Convert.ToChar(97 + _sourceIndex)));
            }
            else
            {
                // We write platform filter file name like ApiPlatformA.xml,
                // ApiPlatformB.xml, ApiPlatformC.xml etc
                // "65" is the integer value of the letter "A".
                platformFile = Path.Combine(context.WorkingDirectory,
                                            String.Format("ApiPlatform{0}.xml", Convert.ToChar(65 + _sourceIndex)));
            }

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;
            using (XmlWriter writer = XmlWriter.Create(platformFile, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("platforms");

                for (int i = 0; i < _listSources.Count; i++)
                {
                    ReferenceVersionSource versionSource = _listSources[i];

                    isSuccessful = this.CreatePlatformFilter(writer,
                                                             versionSource, apiVersionsDir);
                    if (!isSuccessful)
                    {
                        break;
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            if (isSuccessful)
            {
                _platformFile = platformFile;
            }

            return(isSuccessful);
        }
        public CodeSnippetContent(string contentFile)
        {
            BuildExceptions.PathMustExist(contentFile, "contentFile");

            _contentFile = new BuildFilePath(contentFile);
        }
        public virtual void Configure(string sourceFile, string destFile)
        {
            BuildExceptions.PathMustExist(sourceFile, "sourceFile");
            BuildExceptions.NotNullNotEmpty(destFile, "destFile");

            if (this.IsInitialized == false)
            {
                throw new BuildException("The configurator is not initialized.");
            }

            _sourceFile = sourceFile;
            _destFile   = destFile;

            string destDir = Path.GetDirectoryName(destFile);

            if (Directory.Exists(destDir) == false)
            {
                Directory.CreateDirectory(destDir);
            }

            XmlDocument configDoc = new XmlDocument();

            configDoc.Load(_sourceFile);

            if (_configContent != null && _configContent.IsEmpty == false)
            {
                XPathNavigator    docNavigator = configDoc.CreateNavigator();
                XPathNodeIterator iterator     = docNavigator.Select("//SandcastleItem");
                if (iterator != null && iterator.Count != 0)
                {
                    int nodeCount = iterator.Count;

                    XPathNavigator[] navigators = new XPathNavigator[iterator.Count];
                    for (int i = 0; i < navigators.Length; i++)
                    {
                        iterator.MoveNext();
                        navigators[i] = iterator.Current.Clone();
                    }

                    string           configKeyword = null;
                    ConfiguratorItem configItem    = null;
                    for (int i = 0; i < nodeCount; i++)
                    {
                        XPathNavigator navigator = navigators[i];
                        configKeyword = navigator.GetAttribute("name", String.Empty);
                        if (String.IsNullOrEmpty(configKeyword))
                        {
                            continue;
                        }

                        configItem = _configContent[configKeyword];
                        if (configItem != null)
                        {
                            configItem.Execute(navigator);
                        }
                    }
                }
            }

            this.ApplyContents(configDoc);

            configDoc.Save(_destFile);
        }