示例#1
0
        internal static PluginMethod Create(IAgentPlugin plugin, MethodInfo methodInfo)
        {
            PluginMethodAttribute methodAttribute = methodInfo.GetCustomAttribute <PluginMethodAttribute>();

            if (!IsValidMethodAttribute(methodAttribute))
            {
                return(null);
            }

            if (!IsValidSignature(methodInfo))
            {
                return(null);
            }

            return(new PluginMethod(plugin, methodAttribute.HttpMethod, methodInfo));
        }
示例#2
0
        /// <summary>
        /// Validate the method attribute for supported Http Method
        /// </summary>
        /// <param name="methodAttribute">The plugin method attribute</param>
        /// <returns>true if the attribute is valid and supported,</returns>
        private static bool IsValidMethodAttribute(PluginMethodAttribute methodAttribute)
        {
            if (methodAttribute == null)
            {
                return(false);
            }

            switch (methodAttribute.HttpMethod)
            {
            case "GET":
            case "PUT":
                break;

            default:
                return(false);
            }

            return(true);
        }