예제 #1
0
        private void UpdateReferences(TableData table, Dictionary <string, List <string> > descriptions, List <RepositoryReference> references)
        {
            for (int ii = 0; ii < table.Count; ii++)
            {
                var reference = new RepositoryReference();

                reference.BrowseName     = null;
                reference.DataType       = null;
                reference.Documentation  = null;
                reference.ModellingRule  = null;
                reference.NodeClass      = NodeClass.Unspecified;
                reference.ReferenceType  = null;
                reference.TypeDefinition = null;
                reference.ValueRank      = ValueRanks.Scalar;

                var cell = table.GetCell("ReferenceType", ii);

                if (cell != null)
                {
                    reference.ReferenceType = new RepositoryLink()
                    {
                        Name = cell.Text,
                        Path = cell.Link
                    };
                }

                cell = table.GetCell("NodeClass", ii);

                if (cell != null && !String.IsNullOrEmpty(cell.Text))
                {
                    if (!Enum.TryParse <Opc.Ua.NodeClass>(cell.Text, out reference.NodeClass))
                    {
                        reference.NodeClass = Opc.Ua.NodeClass.Unspecified;
                    }
                }

                cell = table.GetCell("BrowseName", ii);

                if (cell != null && !String.IsNullOrEmpty(cell.Text))
                {
                    var name = cell.Text;
                    name = name.Replace("&lt;", "<");
                    name = name.Replace("&gt;", ">");
                    reference.BrowseName = name;
                }

                cell = table.GetCell("DataType", ii);

                if (cell != null && !String.IsNullOrEmpty(cell.Text))
                {
                    var dataType = cell.Text;

                    if (dataType.EndsWith("[]"))
                    {
                        reference.ValueRank = ValueRanks.OneDimension;
                        dataType            = dataType.Substring(0, dataType.Length - 2);
                        dataType            = dataType.Trim();
                    }

                    reference.DataType = new RepositoryLink()
                    {
                        Name = dataType,
                        Path = cell.Link
                    };
                }

                cell = table.GetCell("TypeDefinition", ii);

                if (cell != null && !String.IsNullOrEmpty(cell.Text))
                {
                    reference.TypeDefinition = new RepositoryLink()
                    {
                        Name = cell.Text,
                        Path = cell.Link
                    };
                }

                cell = table.GetCell("ModellingRule", ii);

                if (cell != null && !String.IsNullOrEmpty(cell.Text))
                {
                    reference.ModellingRule = new RepositoryLink()
                    {
                        Name = cell.Text,
                        Path = cell.Link
                    };
                }

                List <string> description = null;

                if (descriptions.TryGetValue(reference.BrowseName, out description))
                {
                    reference.Documentation = description;
                }

                references.Add(reference);
            }
        }
예제 #2
0
        private void WriteMethod(StreamWriter writer, RepositoryReference reference)
        {
            var name = reference.BrowseName;

            if (name.Contains("<") || name.Contains(">"))
            {
                return;
            }

            bool hasArguments = (reference.InputArguments != null && reference.InputArguments.Count > 0) || (reference.OutputArguments != null && reference.OutputArguments.Count > 0);

            writer.WriteLine($"### <a name=\"{name}\"></a>{name}");
            WriteParagraphs(writer, reference.Documentation, false);

            const string indent = "    ";

            writer.WriteLine($"**Signature**");
            writer.WriteLine($"```");
            writer.Write($"{indent}{name}(");

            if (reference.InputArguments != null && reference.InputArguments.Count > 0)
            {
                writer.WriteLine();

                foreach (var arg in reference.InputArguments)
                {
                    writer.WriteLine($"{indent}{indent}[in]  {arg.DataType.Name} {arg.Name}");
                }
            }

            if (reference.OutputArguments != null && reference.OutputArguments.Count > 0)
            {
                foreach (var arg in reference.OutputArguments)
                {
                    writer.WriteLine($"{indent}{indent}[out] {arg.DataType.Name} {arg.Name}");
                }
            }

            writer.WriteLine($"{indent});");
            writer.WriteLine($"```");

            if (hasArguments)
            {
                writer.WriteLine();
                writer.WriteLine($"|Argument|Description|");
                writer.WriteLine($"|---|---|");

                if (reference.InputArguments != null && reference.InputArguments.Count > 0)
                {
                    foreach (var arg in reference.InputArguments)
                    {
                        writer.Write($"|{arg.Name}|");
                        WriteParagraphs(writer, arg.Documentation, true);
                        writer.WriteLine($"|");
                    }
                }

                if (reference.OutputArguments != null && reference.OutputArguments.Count > 0)
                {
                    foreach (var arg in reference.OutputArguments)
                    {
                        writer.Write($"|{arg.Name}|");
                        WriteParagraphs(writer, arg.Documentation, true);
                        writer.WriteLine($"|");
                    }
                }

                writer.WriteLine();
            }

            if (reference.StatusCodes != null && reference.StatusCodes.Count > 0)
            {
                writer.WriteLine($"**Method Result Codes**");
                writer.WriteLine();
                writer.WriteLine($"|Result Code|Description|");
                writer.WriteLine($"|---|---|");

                foreach (var statusCode in reference.StatusCodes)
                {
                    writer.Write($"|{statusCode.Code}|");
                    WriteParagraphs(writer, statusCode.Documentation, true);
                    writer.WriteLine($"|");
                }

                writer.WriteLine();
            }
        }