public void PreprocessPragma(string pragmaName, string args, XmlWriter writer)
        {
            string[] prefixParts = pragmaName.Split(variableSplitter, 2);
            // Check to make sure there are 2 parts and neither is an empty string.
            if (2 != prefixParts.Length)
            {
                Console.WriteLine("[Warning] Preprocessor Unknown Pragma: " + pragmaName);
            }
            string prefix = prefixParts[0];
            string pragma = prefixParts[1];

            if (String.IsNullOrEmpty(prefix) || String.IsNullOrEmpty(pragma))
            {
                Console.WriteLine("[Warning] Preprocessor Unknown Pragma: " + pragmaName);
            }

            switch (prefix)
            {
            default:
                PreprocessorExtension extension = (PreprocessorExtension)this.extensionsByPrefix[prefix];
                if (null == extension || !extension.ProcessPragma(prefix, pragma, args, writer))
                {
                    Console.WriteLine("[Warning] Preprocessor Unknown Pragma: " + pragmaName);
                }
                break;
            }
        }
        public string EvaluateFunction(string prefix, string function, string[] args)
        {
            if (String.IsNullOrEmpty(prefix))
            {
                throw new ArgumentNullException("prefix");
            }

            if (String.IsNullOrEmpty(function))
            {
                throw new ArgumentNullException("function");
            }

            switch (prefix)
            {
            case "fun":
                switch (function)
                {
                case "AutoVersion":
                    // Make sure the base version is specified
                    if (args.Length == 0 || args[0].Length == 0)
                    {
                        throw new Exception("Invalid Preprocessor Function Auto Version.");
                    }

                    // Build = days since 1/1/2000; Revision = seconds since midnight / 2
                    DateTime now        = DateTime.Now.ToUniversalTime();
                    TimeSpan tsBuild    = now - new DateTime(2000, 1, 1);
                    TimeSpan tsRevision = now - new DateTime(now.Year, now.Month, now.Day);

                    return(String.Format("{0}.{1}.{2}", args[0], (int)tsBuild.TotalDays, (int)(tsRevision.TotalSeconds / 2)));

                // Add any core defined functions here
                default:
                    return(null);
                }

            default:
                PreprocessorExtension extension = (PreprocessorExtension)this.extensionsByPrefix[prefix];
                if (null != extension)
                {
                    try
                    {
                        return(extension.EvaluateFunction(prefix, function, args));
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.Message);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
        public string GetVariableValue(string prefix, string name)
        {
            if (String.IsNullOrEmpty(prefix))
            {
                throw new ArgumentNullException("prefix");
            }

            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            switch (prefix)
            {
            case "env":
                return(Environment.GetEnvironmentVariable(name));

            case "sys":
                switch (name)
                {
                case "CURRENTDIR":
                    return(String.Concat(Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar));

                case "SOURCEFILEDIR":
                    return(String.Concat(Path.DirectorySeparatorChar));

                case "SOURCEFILEPATH":
                    return(null);

                case "PLATFORM":
                    Console.WriteLine("[Warning] Deprecated PreProc Variable: $(sys.PLATFORM), $(sys.BUILDARCH)");
                    goto case "BUILDARCH";

                case "BUILDARCH":
                    switch (this.currentPlatform)
                    {
                    case Platform.X86:
                        return("x86");

                    case Platform.X64:
                        return("x64");

                    case Platform.IA64:
                        return("ia64");

                    case Platform.ARM:
                        return("arm");

                    default:
                        throw new ArgumentException(this.currentPlatform.ToString());
                    }

                default:
                    return(null);
                }

            case "var":
                return((string)this.variables[name]);

            default:
                PreprocessorExtension extension = (PreprocessorExtension)this.extensionsByPrefix[prefix];
                if (null != extension)
                {
                    try
                    {
                        return(extension.GetVariableValue(prefix, name));
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.Message);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }