APIDocumentationCreator.Parser.ParseLine C# (CSharp) Метод

ParseLine() публичный Метод

public ParseLine ( string line ) : void
line string
Результат void
        public void ParseLine(string line)
        {
            line = line.Trim();
            line = line.Trim("\t".ToCharArray());

            if (line.StartsWith("object"))
            {
                // we're starting a new object.
                _currentInterface = null;
                _currentHelpText = "";
            }
            else if (line.StartsWith("helpstring"))
            {
                int startPos = "helpstring(\"".Length;
                int endPos = line.LastIndexOf("\"");
                int len = endPos - startPos;

                _currentHelpText = line.Substring(startPos, len);
            }
            else if (line.StartsWith("interface") && line.Contains("IDispatch"))
            {
                // extract the first word after interface.
                string [] values = line.SplitString(" ");
                string interfaceName = "";
                for (int i = 1; i < values.Length; i++ )
                {
                    string value = values[i];
                    if (value.Length > 0)
                    {
                        interfaceName = value;
                        break;
                    }

                }

                if (string.IsNullOrEmpty(interfaceName))
                {
                    throw new Exception("Could not locate interface name");
                }

                // Remove the IInterface signature.
                interfaceName = interfaceName.Substring("IInterface".Length);

                if (interfaceName == "FetchAccount")
                {
                    int i = 0;
                }

                _currentInterface = new APIInterface();
                _currentInterface.Name = interfaceName;
                _currentInterface.HelpString = _currentHelpText;

                apiInterfaces.Add(_currentInterface);
            }
            else if (line.StartsWith("[propget"))
            {
                // [propget, id(1), helpstring("Undelivered messages")] HRESULT UndeliveredMessages([out, retval] BSTR *pVal);
                if (_currentInterface == null)
                    return;

                ParsePropLine(line, false);
            }
            else if (line.StartsWith("[propput"))
            {
                // [propput, id(34), helpstring("SMTP relayer requires authentication")] HRESULT SMTPRelayerRequiresAuthentication([in] VARIANT_BOOL newVal);
                if (_currentInterface == null)
                    return;

                ParsePropLine(line, true);
            }
            else if (line.StartsWith("[id"))
            {
                if (_currentInterface == null)
                    return;

                if (line.Contains("CreateExternalDatabase"))
                {
                    int i = 0;
                }

                ParseMethodLine(line);
            }
        }

Usage Example

Пример #1
0
        static void Main(string[] args)
        {
            // Make sure that the output directory exists.
            if (!Directory.Exists(outputDirectory))
                Directory.CreateDirectory(outputDirectory);

            string fileContent = File.ReadAllText(inputFile);

            string[] lines = fileContent.SplitString(Environment.NewLine);

            Parser parser = new Parser();
            foreach (string line in lines)
            {
                parser.ParseLine(line);
            }

            HTMLGenerator generator = new HTMLGenerator();
            generator.Generate(parser, outputDirectory);
        }