Exemplo n.º 1
0
        /// <summary>
        /// Createa a new tool method instance.
        /// </summary>
        /// <param name="tool">The tool.</param>
        /// <param name="id">The tool method identifier.</param>
        /// <param name="name">The method name.</param>
        /// <param name="description">The method description.</param>
        /// <param name="action">The action.</param>
        public ToolMethod(Tool tool, Guid id, string name, string description, ToolMethodAction action)
        {
            // Validate the arguments.
            if (null == tool) throw new ArgumentNullException("tool");
            if (null == action) throw new ArgumentNullException("action");

            this.tool = tool;
            this.id = new ToolMethodId(tool.Info.Id.Guid, tool.Info.Id.Version, id);
            this.name = name;
            this.description = description;
            this.action = action;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Try and parse the specified string into a tool identifier.
        /// </summary>
        /// <param name="value">The string value.</param>
        /// <param name="id">The tool identifier.</param>
        /// <returns><b>True</b> if the parsing was successful, <b>false</b> otherwise.</returns>
        public static bool TryParse(string value, out ToolMethodId id)
        {
            // Split the tool information between identifier and version.
            string[] str = value.Split(',');

            id = default(ToolMethodId);

            // If the information does not have exactly two parameters, throw an exception.
            if (3 != str.Length) return false;

            Guid guidTool;
            Version version;
            Guid guidMethod;

            // Try parse the GUID.
            if (!Guid.TryParse(str[0], out guidTool)) return false;
            // Try parse the version.
            if (!Version.TryParse(str[1], out version)) return false;
            // Try parse the version.
            if (!Guid.TryParse(str[2], out guidMethod)) return false;

            // Create the new tool identifier.
            id = new ToolMethodId(guidTool, version, guidMethod);

            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Tries to parse the specified string into a tool method trigger and a method identifier.
        /// </summary>
        /// <param name="value">The string value.</param>
        /// <param name="triggerId">The trigger identifier.</param>
        /// <param name="methodId">The method identifier.</param>
        /// <returns><b>True</b> if the parsing was successful, <b>false</b> otherwise.</returns>
        public static bool TryParse(string value, out Guid triggerId, out ToolMethodId methodId)
        {
            // Split the string value using the pipe.
            string[] tokens = value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            // If the number of tokens is 2.
            if (tokens.Length == 2)
            {
                // Parse the trigger and method identifiers.
                bool resultTrigger = Guid.TryParse(tokens[0], out triggerId);
                bool resultMethod = ToolMethodId.TryParse(tokens[1], out methodId);
                // Return the result.
                return resultTrigger && resultMethod;
            }

            // Set the default values.
            triggerId = default(Guid);
            methodId = default(ToolMethodId);

            // Return false.
            return false;
        }