Пример #1
0
        /// <param name="attr">Attribute of method</param>
        /// <param name="method">Current actual/real method name</param>
        /// <param name="className">Actual class name</param>
        public NodeInfo(MethodAttribute attr, string method, string className = null)
            : this(attr.Name, attr.Description, new NodeIdent(attr.Name, method, className), InfoType.Method)
        {
            try {
                Signature  = aboutMethod(attr.Return, attr.Arguments);
                displaying = displayMethod(attr.Return, attr.Arguments);
                Name       = displaying;

                //TODO:
                if (attr.Arguments != null && attr.Arguments.Length > 0)
                {
                    if (attr.Arguments[attr.Arguments.Length - 1].type == CValueType.Input)
                    {
                        Name = Name.Substring(0, displaying.LastIndexOf(',')) + "): ]";
                    }
                }
            }
            catch (Exception ex) {
                Log.Warn("NodeInfo-MethodAttribute: '{0}'", ex.Message);
            }
        }
Пример #2
0
 /// <summary>
 /// Formatting of the method for displaying
 /// </summary>
 /// <param name="ret">Return value</param>
 /// <param name="args">Arguments of method</param>
 /// <returns></returns>
 private string displayMethod(CValueType ret, MethodAttribute.TArguments[] args)
 {
     string aStr = (args != null && args.Length > 0)? String.Join(", ", args.Select(p => p.name)) : _type(CValueType.Void);
     return String.Format("{0}({1})", Name, aStr);
 }
Пример #3
0
        /// <param name="attr">Attribute of method</param>
        /// <param name="method">Current actual/real method name</param>
        /// <param name="className">Actual class name</param>
        public NodeInfo(MethodAttribute attr, string method, string className = null)
            : this(attr.Name, attr.Description, new NodeIdent(attr.Name, method, className), InfoType.Method)
        {
            try {
                Signature   = aboutMethod(attr.Return, attr.Arguments);
                displaying  = displayMethod(attr.Return, attr.Arguments);
                Name        = displaying;

                //TODO:
                if(attr.Arguments != null && attr.Arguments.Length > 0) {
                    if(attr.Arguments[attr.Arguments.Length - 1].type == CValueType.Input) {
                        Name = Name.Substring(0, displaying.LastIndexOf(',')) + "): ]";
                    }
                }
            }
            catch(Exception ex) {
                Log.Warn("NodeInfo-MethodAttribute: '{0}'", ex.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// Builds the technical description of the method
        /// </summary>
        /// <param name="ret">Return value</param>
        /// <param name="args">Arguments of method</param>
        /// <returns></returns>
        private string aboutMethod(CValueType ret, MethodAttribute.TArguments[] args)
        {
            string retString = _type(ret);

            if(args == null || args.Length < 1) {
                return String.Format("{0} {1}({2})\n", retString, Name, _type(CValueType.Void));
            }

            if(args[0].name == null) {
                return String.Format("{0} {1}({2})", retString, Name, String.Join(", ", args.Select(p => _type(p.type))));
            }

            string argsString       = String.Join(", ", args.Select(p => String.Format("{0} {1}", _type(p.type), p.name)));
            string argsDescription  = String.Join("\n* ", args.Select(p => String.Format("{0} - {1}", p.name, p.description)));

            return String.Format("{0} {1}({2})\n* {3}", retString, Name, argsString, argsDescription);
        }