Example #1
0
        /// <summary>
        /// Adds information about subsequent modifying fluent interface style calls on an object (like
        /// foo.With(...).With(...))
        /// </summary>
        public static void AddModifyingCalls(object treeElement, ApiCall apiCall, APIList values)
        {
            var methods = treeElement.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance);

            foreach (var value in values)
            {
                var methodName = "With" + value.Name.ProperCase();
                if (!methods.Any(m => m.Name == methodName))
                {
                    throw new NotSupportedException( );
                }
                methodName = "." + methodName;
                apiCall.AddModifyingCall(new MethodCall(methodName, ArgList.Create(value)));
            }
        }