示例#1
0
        // Group: Loading Functions
        // __________________________________________________________________________


        /* Function: Load
         * Attempts to load any project information it can find in <Menu.txt>.  Unlike <Project_txt.Load()>, this doesn't take an
         * <ErrorList>.  Loading <Menu.txt> is done when it can provide a benefit but it failing to load is not an error.
         */
        public bool Load(Path path, out ProjectConfig projectConfig)
        {
            projectConfig = new ProjectConfig(PropertySource.OldMenuFile);

            using (var configFile = new ConfigFile())
            {
                ErrorList ignored    = new Errors.ErrorList();
                bool      openResult = configFile.Open(path,
                                                       PropertySource.OldMenuFile,
                                                       ConfigFile.FileFormatFlags.CondenseIdentifierWhitespace |
                                                       ConfigFile.FileFormatFlags.SupportsBraces |
                                                       ConfigFile.FileFormatFlags.MakeIdentifiersLowercase,
                                                       ignored);

                if (openResult == false)
                {
                    return(false);
                }

                Regex.Config.Subtitle  subtitleRegex  = new Regex.Config.Subtitle();
                Regex.Config.Timestamp timestampRegex = new Regex.Config.Timestamp();

                string lcIdentifier, value;

                while (configFile.Get(out lcIdentifier, out value))
                {
                    var propertyLocation = new PropertyLocation(PropertySource.OldMenuFile, path, configFile.LineNumber);

                    if (lcIdentifier == "title")
                    {
                        projectConfig.ProjectInfo.Title = value.ConvertCopyrightAndTrademark();
                        projectConfig.ProjectInfo.TitlePropertyLocation = propertyLocation;
                    }
                    else if (subtitleRegex.IsMatch(lcIdentifier))
                    {
                        projectConfig.ProjectInfo.Subtitle = value.ConvertCopyrightAndTrademark();
                        projectConfig.ProjectInfo.SubtitlePropertyLocation = propertyLocation;
                    }
                    else if (lcIdentifier == "footer" || lcIdentifier == "copyright")
                    {
                        projectConfig.ProjectInfo.Copyright = value.ConvertCopyrightAndTrademark();
                        projectConfig.ProjectInfo.CopyrightPropertyLocation = propertyLocation;
                    }
                    else if (timestampRegex.IsMatch(lcIdentifier))
                    {
                        projectConfig.ProjectInfo.TimestampCode = value;
                        projectConfig.ProjectInfo.TimestampCodePropertyLocation = propertyLocation;
                    }
                    // Otherwise just ignore the entry.
                }

                configFile.Close();
            }

            return(true);
        }
示例#2
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: Project_txt
         */
        public Project_txt()
        {
            errorList     = null;
            projectConfig = null;

            yesRegex = new Regex.Config.Yes();
            noRegex  = new Regex.Config.No();

            subtitleRegex       = new Regex.Config.Subtitle();
            timestampRegex      = new Regex.Config.Timestamp();
            tabWidthRegex       = new Regex.Config.TabWidth();
            documentedOnlyRegex = new Regex.Config.DocumentedOnly();
            autoGroupRegex      = new Regex.Config.AutoGroup();

            sourceFolderRegex               = new Regex.Config.SourceFolder();
            imageFolderRegex                = new Regex.Config.ImageFolder();
            htmlOutputFolderRegex           = new Regex.Config.HTMLOutputFolder();
            ignoredSourceFolderRegex        = new Regex.Config.IgnoredSourceFolder();
            ignoredSourceFolderPatternRegex = new Regex.Config.IgnoredSourceFolderPattern();
        }