Exemplo n.º 1
0
        /// <summary>
        /// Generates ports' description in the following format: "Name [Type]: Description (Default value)"
        /// </summary>
        /// <param name="nodeModel">The node holding the ports to describe</param>
        /// <returns>The description of all the ports in the node</returns>
        private void GetPortsDescription(IDotsNodeModel nodeModel)
        {
            var runtimeNode = nodeModel.Node;
            var nodeType    = runtimeNode.GetType();
            var fields      = nodeType.GetFields(BindingFlags.Instance | BindingFlags.Public);
            var inputs      = fields.Where(f => typeof(IInputDataPort).IsAssignableFrom(f.FieldType) ||
                                           typeof(IInputTriggerPort).IsAssignableFrom(f.FieldType)).ToList();
            var outputs = fields.Where(f => typeof(IOutputDataPort).IsAssignableFrom(f.FieldType) ||
                                       typeof(IOutputTriggerPort).IsAssignableFrom(f.FieldType)).ToList();

            SectionTitle("Ports", 2);

            AppendSection("Inputs", inputs, this);
            AppendSection("Outputs", outputs, this);
        }
Exemplo n.º 2
0
        private static string GetNodeDescription(IDotsNodeModel nodeModel)
        {
            var runtimeNode = nodeModel.Node;
            var nodeType    = runtimeNode.GetType();

            if (nodeType.GetInterfaces().Any(x =>
                                             x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IHasExecutionType <>)))
            {
                var getType = nodeType.GetProperty("Type")?.GetMethod;
                var value   = getType?.Invoke(runtimeNode, new object[] {});
                var attrs   = nodeType.GetCustomAttributes <NodeDescriptionAttribute>();
                return(attrs.FirstOrDefault(a => a.Type.Equals(value))?.Description);
            }

            return(nodeType.GetCustomAttribute <NodeDescriptionAttribute>()?.Description);
        }
Exemplo n.º 3
0
        public void DocumentNode(SearcherItem searcherItem, IDotsNodeModel baseDotsNodeModel)
        {
            var title = Attribute.IsDefined(baseDotsNodeModel.Node.GetType(), typeof(WorkInProgressAttribute))
                ? $"{searcherItem.Name} [WIP]"
                : searcherItem.Name;

            SectionTitle(title, 1);
            var nodeDescription = GetNodeDescription(baseDotsNodeModel);

            if (!String.IsNullOrEmpty(nodeDescription))
            {
                Paragraph(nodeDescription);
            }

            GetPortsDescription(baseDotsNodeModel);
        }