예제 #1
0
        /// <summary>
        /// Registers a method with the method collection. If the method
        /// already exists it will be updated
        /// </summary>
        /// <param name="method"></param>
        public void Register(IMacroMethod method)
        {
            var idx = -1;
            for (var i = 0; i < this._methods.Count; i++)
            {
                if (!this._methods[i].Name.Equals(method.Name, StringComparison.InvariantCultureIgnoreCase)) continue;

                idx = i;
                break;
            }

            if (idx >= 0)
            {
                this._methods[idx] = method;
            }
            else
            {
                this._methods.Add(method);
            }
        }
예제 #2
0
 /// <summary>
 /// Implements <see cref="IEquatable{IMacroMethod}"/> Equals method
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(IMacroMethod other)
 {
     return this.Equals(other.Name);
 }
    /// <summary>
    /// Returns method help (return type, name and parameters), highlites current parameter.
    /// </summary>
    /// <param name="method">Method object</param>
    /// <param name="paramNumber">Number of the parameter which should be highlighted</param>
    /// <param name="withoutFirstParam">If true, first parameter is not rendered</param>
    private static string GetMethodString(IMacroMethod method, int paramNumber, bool withoutFirstParam)
    {
        string currentParamComment = "";
        string currentParamName = "";
        string parameters = "";

        int startParam = (withoutFirstParam ? 1 : 0);
        if (method.Parameters != null)
        {
            for (int i = startParam; i < method.Parameters.Count; i++)
            {
                IMacroMethodParam p = method.Parameters[i];
                string paramtype = null;
                if (p.IsParams)
                {
                    paramtype = "params " + p.Type.Name + "[]";
                }
                else
                {
                    paramtype = p.Type.Name;
                }
                string param = paramtype + " " + p.Name;
                if (i >= method.MinimumParameters)
                {
                    param = "<i>" + param + "</i>";
                }
                int index = i - startParam;
                if ((index == paramNumber) || (p.IsParams && (index <= paramNumber)))
                {
                    currentParamName = p.Name;
                    currentParamComment = p.Comment;
                    param = "<strong>" + param + "</strong>";
                }
                parameters += ", " + param;
            }
        }
        if (parameters != "")
        {
            parameters = parameters.Substring(2);
        }

        string type = (method.Type == null ? "object" : method.Type.Name);
        string methodComment = (string.IsNullOrEmpty(method.Comment) ? "" : "<strong>" + method.Comment + "</strong><br/><br />");
        string paramComment = (string.IsNullOrEmpty(currentParamComment) ? "" : "<br/><br/><strong>" + currentParamName + ":&nbsp;</strong>" + currentParamComment);

        return methodComment + type + " " + method.Name + "(" + parameters + ")" + paramComment;
    }