Exemple #1
0
        /// <summary>
        /// Gets the <see cref="FullMethodDescription"/> for the method declared by the <see cref="CallBefore"/> attribute.
        /// </summary>
        /// <param name="callBefore">The call before.</param>
        /// <param name="mainMethod">The main method.</param>
        /// <param name="parametersIndex">Index of the parameters.</param>
        /// <returns>The <see cref="FullMethodDescription"/> for the method declared by the <see cref="CallBefore"/> attribute.</returns>
        private FullMethodDescription GetCallBeforeFullMethodDescription(CallBefore callBefore, FullMethodDescription mainMethod, string parametersIndex)
        {
            MethodInfo                 methodInfo                 = mainMethod.ComponentObject.GetType().GetMethod(callBefore.Method);
            MethodParametersLoader     methodParametersLoader     = new MethodParametersLoader();
            MethodsManagementUtilities methodsManagementUtilities = new MethodsManagementUtilities();
            string           fullId           = methodsManagementUtilities.GetMainFullId(mainMethod) + callBefore.Id;
            MethodParameters methodParameters = methodParametersLoader.LoadMethodParameters(mainMethod.ComponentObject, methodInfo, fullId, parametersIndex);

            FullMethodDescription result = this.GetFullMethodDescription(mainMethod.ComponentObject, methodInfo, mainMethod.StepType, mainMethod.Text, methodParameters, string.Empty, 0, callBefore.Delay, callBefore.Timeout, callBefore.ExecutionOrder, callBefore.Id, mainMethod);

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Gets the call chain defined by the <see cref="CallBefore"/> attributes.
        /// </summary>
        /// <param name="mainMethodDescription">The main method description.</param>
        /// <param name="parametersIndex">Index of the parameters.</param>
        /// <returns>A <see cref="List"/> of <see cref="FullMethodDescription"/> object. Each element represent one of the element in the call chain defined by the <see cref="CallBefore"/> attributes.</returns>
        private List <FullMethodDescription> GetCallBeforeListFullMethodsDescriptions(FullMethodDescription mainMethodDescription, string parametersIndex)
        {
            List <FullMethodDescription> result = new List <FullMethodDescription>();

            object[] customCallBeforeAttributes = mainMethodDescription.Method.GetCustomAttributes(typeof(CallBefore), true);
            foreach (object callBeforeAttribute in customCallBeforeAttributes)
            {
                CallBefore callBefore = (CallBefore)callBeforeAttribute;
                if (callBefore.Method != null && !callBefore.Method.Equals(string.Empty))
                {
                    FullMethodDescription        callBeforeFullMethodDescription        = this.GetCallBeforeFullMethodDescription(callBefore, mainMethodDescription, parametersIndex);
                    List <FullMethodDescription> listOfCallBeforeFullMethodDescriptions = this.GetCallBeforeListFullMethodsDescriptions(callBeforeFullMethodDescription, parametersIndex);
                    result.AddRange(listOfCallBeforeFullMethodDescriptions);
                    result.Add(callBeforeFullMethodDescription);
                }
            }

            result.Sort();
            return(result);
        }